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

20210323180540_change_item_id_type_to_uuid.rb changes column type and throws any data away #339

Closed
blackrat opened this issue May 11, 2021 · 3 comments

Comments

@blackrat
Copy link
Contributor

blackrat commented May 11, 2021

This is a migration that converts the papertrail item_id from bigint to uuid by dropping the column and recreating it with random data. This will break the referential integrity of the papertrail items, rendering them useless up to the point of the migration.

The original foreign key data was lost by this migration. In addition, you can't roll back, since that will fail.

@timabell
Copy link
Contributor

This was the patch 63e38d6#diff-9c91cc95430a94f2177c34b7538ef8227fb779c91c7a8647082e1338d64003e1R5

remove_column :versions, :item_id, :bigint
remove_index :versions, column: %i[item_type item_id], if_exists: true
add_column :versions, :item_id, :uuid, default: "gen_random_uuid()", null: false

@ethanmills
Copy link
Contributor

ethanmills commented May 17, 2021

The original foreign key data was lost by this migration

There wasn't any original foreign key data to lose. Firstly, this was before we deployed to production. Secondly, since UUIDs were being cast to ints, we only had the characters of the ID before the first letter.

Is there a change you'd like here, or can we close this?

@blackrat
Copy link
Contributor Author

Close it.

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

No branches or pull requests

3 participants