Skip to content

[usage] Rename misnamed column in usage table #11353

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

Merged
merged 2 commits into from
Jul 14, 2022

Conversation

andrew-farries
Copy link
Contributor

@andrew-farries andrew-farries commented Jul 13, 2022

Description

Change the name of the workspaceId column to instanceId in the d_b_workspace_instance_usage table as that's what it stores.

As there is no production data in this table the migration is simply to drop the table and recreate it.

/hold because this is based on #11343.

Related Issue(s)

Part of #10323

How to test

Connecting to the database in the preview env for this PR shows the table with the correct column name.

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@andrew-farries andrew-farries requested a review from a team July 13, 2022 15:11
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Jul 13, 2022
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-af-rename-misnamed-column.4 because the annotations in the pull request description changed
(with .werft/ from main)

@geropl geropl self-assigned this Jul 13, 2022
await queryRunner.query(`DROP TABLE \`d_b_workspace_instance_usage\``);

await queryRunner.query(
`CREATE TABLE \`d_b_workspace_instance_usage\` (\`instanceId\` char(36) NOT NULL, \`attributionId\` varchar(255) NOT NULL, \`startedAt\` timestamp(6) NOT NULL, \`stoppedAt\` timestamp(6) NULL, \`creditsUsed\` double NOT NULL, \`generationId\` int NOT NULL, \`deleted\` tinyint NOT NULL, INDEX \`IDX_1358af969a29fd9e0c6cabf37c\` (\`attributionId\`), INDEX \`IDX_25d77dfa246b93672c317e26ad\` (\`startedAt\`), INDEX \`IDX_e759ab5fcf57350da51fcf56bc\` (\`stoppedAt\`), PRIMARY KEY (\`instanceId\`)) ENGINE=InnoDB`,
Copy link
Member

Choose a reason for hiding this comment

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

Regarding indexes: We have the convention to give them human readable names, e.g. one on attributionId would be ind_attributionId, one on attributionId and creationTime ind_attributionId_creationTime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added names to the indexes and regenerated the migration.

Andrew Farries added 2 commits July 13, 2022 15:44
Rename the misnamed primary key `workspaceId` -> `instanceId`.

Usage based billing is unreleased so just drop the table and recreate it
- no data to migrate.

Also add index names.
@andrew-farries andrew-farries force-pushed the af/rename-misnamed-column branch from 00c6e66 to c90db68 Compare July 13, 2022 15:45
@andrew-farries andrew-farries requested a review from geropl July 13, 2022 15:46
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

LGTM

@andrew-farries
Copy link
Contributor Author

andrew-farries commented Jul 13, 2022

/werft run with-clean-slate-deployment=true

👍 started the job as gitpod-build-af-rename-misnamed-column.6
(with .werft/ from main)

@andrew-farries
Copy link
Contributor Author

/unhold

@roboquat roboquat merged commit 373118e into af/store-usage-data Jul 14, 2022
@roboquat roboquat deleted the af/rename-misnamed-column branch July 14, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants