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

ChannelToken migration #17885

Merged
merged 1 commit into from
Sep 22, 2017
Merged

ChannelToken migration #17885

merged 1 commit into from
Sep 22, 2017

Conversation

Bjvanminnen
Copy link
Contributor

First in a series of migrations around ChannelTokens. Overarching plan is as follows

  1. [migration] Create new (indexed) column in channel_tokens called storage_id
  2. [code change] Update code to write both user_id and storage_id columns for new rows
  3. [migration] Backfill storage_id, derived by decrypting channel column. On production this will be managed via a script that batches updates. In other envs this will involve a migration.
  4. [migration] Make storage_id non-nullable, make user_id/channel nullable (now that all rows should be backfilled and new rows are getting storage_id from 2
  5. [code change] Stop using channel/user_id, use storage_id instead
  6. [migration] Delete channel/user_id columns

class AddStorageIdToChannelTokens < ActiveRecord::Migration[5.0]
def change
add_column :channel_tokens, :storage_id, :integer
add_index :channel_tokens, :storage_id

Choose a reason for hiding this comment

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

Can you include the query changes to validate the index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

This looks like the right plan to me.

@Bjvanminnen Bjvanminnen merged commit b360b2a into staging Sep 22, 2017
@Bjvanminnen Bjvanminnen deleted the channelTokensMigrations branch September 22, 2017 18:45
@Bjvanminnen
Copy link
Contributor Author

For posterity, the migration step of the DTP that contained this PR took ~3 minutes (based on slack logs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants