Skip to content

Rails: Backfill existing workspaces with PATs

MR: Backfill existing workspaces with PATs (!131516 - merged)

Description

In Add workspace variables table and add PAT to wo... (!129688 - merged) , we introduced personal_access_token_id column to the workspaces table. In order to enforce NOT NULL constraints on this column, we need to first backfill the existing data.

Create a Post DB migration to perform the following -

  • For each workspace(regardless of their actual_state), create a personal access token associated to the user owning the workspace.
  • This PAT should have an expiry date = workspace's start time + workspace's timeout . This will ensure that the data is consistent and the tokens are expired for most of the affected records(as it should be).
  • Update the workspace's personal_access_token_id to the ID of the PAT generated.
  • Validate that there is no row in workspaces table with a NULL personal_access_token_id

There will never be scenario where the user who owns the workspace does not exist because we have a cascade foreign key relationship between the two. If a user has been deleted, then all workspaces associated with the user are also deleted.

More information at Rails: Enforce not null constraints for workspa... (#422149 - closed)

Acceptance Criteria

  • All rows in workspaces table have a non-NULL and valid personal_access_token_id

Technical Requirements

TODO: Fill out or delete [If applicable, please list out any technical requirements for this feature/enhancement.]

Design Requirements

TODO: Fill out or delete [If applicable, please provide a link to the design specifications for this feature/enhancement.]

Impact Assessment

TODO: Fill out or delete [Please describe the impact this feature/enhancement will have on the user experience and/or the product as a whole.]

Edited by Alper Akgun