Skip to content

[pat] Fix expiration time auto-udpate #15097

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 1 commit into from
Dec 1, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Dec 1, 2022

Description

Previous PR wouldn't fix it on a DB which already has existing data

Related Issue(s)

Fixes #

How to test

  1. On this PR, in a workspace leeway build components/gitpod-db/go:init-testdb
  2. Connect to the local db mysql -h 127.0.0.1 -P 23306 -u root -D gitpod --select-limit=200 --safe-updates -p, pw: test
  3. mysql> show columns from d_b_personal_access_token;
+----------------+--------------+------+-----+----------------------+--------------------------------+
| Field          | Type         | Null | Key | Default              | Extra                          |
+----------------+--------------+------+-----+----------------------+--------------------------------+
| id             | varchar(255) | NO   | PRI | NULL                 |                                |
| userId         | varchar(255) | NO   | MUL | NULL                 |                                |
| hash           | varchar(255) | NO   | MUL | NULL                 |                                |
| name           | varchar(255) | NO   |     | NULL                 |                                |
| scopes         | text         | NO   |     | NULL                 |                                |
| expirationTime | timestamp(6) | NO   |     | CURRENT_TIMESTAMP(6) |                                |
| createdAt      | timestamp(6) | NO   | MUL | CURRENT_TIMESTAMP(6) |                                |
| _lastModified  | timestamp(6) | NO   | MUL | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP(6) |
| deleted        | tinyint(4)   | NO   |     | 0                    |                                |
+----------------+--------------+------+-----+----------------------+--------------------------------+

Release Notes

NONE

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

@easyCZ easyCZ requested a review from a team December 1, 2022 11:01
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Dec 1, 2022
@easyCZ easyCZ force-pushed the mp/pat-fix-expiration-time-auto-update branch from 2deab69 to b0ebea0 Compare December 1, 2022 11:02
export class PersonalAccessTokenFixExpirationTimeAutoUpdate1669892320740 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE ${TABLE_NAME} CHANGE expirationTime expirationTime timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6)`,
Copy link
Member

@AlexTugarev AlexTugarev Dec 1, 2022

Choose a reason for hiding this comment

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

I was about to ask the question, but the ✅ came in and I lost track :-(

☝🏻 there is one expirationTime too much in the statement.

Copy link
Member Author

Choose a reason for hiding this comment

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

The change statement takes from and to arguments. Here we're changing the same one so both are set to the same column name
https://www.tutorialspoint.com/how-do-i-remove-on-update-current-timestamp-from-an-existing-column-in-mysql

Copy link
Member

@AlexTugarev AlexTugarev Dec 1, 2022

Choose a reason for hiding this comment

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

The change statement takes from and to arguments.

🤦🏻‍♂️ was reading "alter table ... modify". got it.

@easyCZ easyCZ mentioned this pull request Dec 1, 2022
4 tasks
@roboquat roboquat merged commit db4f0fc into main Dec 1, 2022
@roboquat roboquat deleted the mp/pat-fix-expiration-time-auto-update branch December 1, 2022 12:53
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Dec 2, 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/S team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants