Skip to content

Commit fd6cec3

Browse files
jankeromnesLaurie T. Malau
andcommitted
[db][usage] Add d_b_billed_session table migration and Go definitions
Co-authored-by: Laurie T. Malau <[email protected]>
1 parent 63f3bb7 commit fd6cec3

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import { MigrationInterface, QueryRunner } from "typeorm";
8+
9+
export class BilledSession1659601647550 implements MigrationInterface {
10+
public async up(queryRunner: QueryRunner): Promise<void> {
11+
await queryRunner.query(
12+
"CREATE TABLE IF NOT EXISTS `d_b_billed_session` (`instanceId` char(36) NOT NULL, `from` varchar(255) NOT NULL, `to` varchar(255) NOT NULL DEFAULT '', `system` varchar(255) NOT NULL, `invoiceId` varchar(255) NOT NULL DEFAULT '', `deleted` tinyint(4) NOT NULL DEFAULT '0', `_lastModified` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), PRIMARY KEY (`instanceId`, `from`), KEY `ind_dbsync` (`_lastModified`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;",
13+
);
14+
}
15+
16+
public async down(queryRunner: QueryRunner): Promise<void> {}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License-AGPL.txt in the project root for license information.
4+
5+
package db
6+
7+
import (
8+
"time"
9+
10+
"github.com/google/uuid"
11+
)
12+
13+
// BilledSession represents the underlying DB object
14+
type BilledSession struct {
15+
InstanceID uuid.UUID `gorm:"primary_key;column:instanceId;type:char;size:36;" json:"instanceId"`
16+
From VarcharTime `gorm:"primary_key;column:from;type:varchar;size:255;" json:"from"`
17+
To VarcharTime `gorm:"column:to;type:varchar;size:255;" json:"to"`
18+
System string `gorm:"column:sytem;type:varchar;size:255;" json:"system"`
19+
InvoiceID string `gorm:"column:invoiceId;type:varchar;size:255;" json:"invoiceId"`
20+
LastModified time.Time `gorm:"column:_lastModified;type:timestamp;default:CURRENT_TIMESTAMP(6);" json:"_lastModified"`
21+
22+
// deleted is restricted for use by db-sync
23+
_ bool `gorm:"column:deleted;type:tinyint;default:0;" json:"deleted"`
24+
}

0 commit comments

Comments
 (0)