Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[db][usage] Add d_b_billed_session table migration and Go definitions #11868

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Aug 4, 2022

Description

Add d_b_billed_session table migration and Go definitions

Related Issue(s)

Fixes #11867

How to test

In /components/usage/pkg/db run go test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@roboquat roboquat added size/L and removed size/M labels Aug 4, 2022
@laushinka laushinka force-pushed the janrie/billed-sessions branch 3 times, most recently from 15b968b to e04ef72 Compare August 4, 2022 09:50
@laushinka laushinka marked this pull request as ready for review August 4, 2022 09:50
@laushinka laushinka requested a review from a team August 4, 2022 09:50
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 4, 2022
teamID := uuid.New().String()
teamAttributionID := db.NewTeamAttributionID(teamID)

instance := dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we create a WorkspaceInstance record here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you ask it I realize it's actually unnecessary 😬 Will remove it, thanks!

InvoiceID: "some-invoice-ID",
}

tx := conn.Create(billedSession)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also delete the created record at the end of the test. For other DB models, there are helpers (in dbtest package) that do this automatically by hooking into the t *testing.T when the test finishes.

@easyCZ easyCZ self-assigned this Aug 4, 2022
export class BilledSession1659601647550 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
"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;",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we specify an enum type, so that we can constrain system to be either "stripe" or "chargebee"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping the column as string, and the in code ensuring an Enum is slightly more extensible for the future.

@roboquat roboquat added size/M and removed size/L labels Aug 4, 2022

import { MigrationInterface, QueryRunner } from "typeorm";

export class BilledSession1659601647550 implements MigrationInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you generate this migration? My own process for generating a migration for a new table using typeorm is somewhat convoluted 😬

I think there is an opportunity to improve the README here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, it's this README instead of the one you linked above. Definitely an opportunity to improve how we point to the right docs 🙈

@andrew-farries
Copy link
Contributor

/hold

Co-authored-by: Laurie T. Malau <laurie@gitpod.io>
@roboquat roboquat merged commit 9519ee4 into main Aug 4, 2022
@roboquat roboquat deleted the janrie/billed-sessions branch August 4, 2022 12:26
@roboquat roboquat added the deployed: webapp Meta team change is running in production label Aug 5, 2022
@roboquat roboquat added the deployed Change is completely running in production label Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create d_b_billed_sessions in the server and related object models in the BillingService
5 participants