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

Backport fix sqlite migrations with custom primary keys to 5-1-stable #31361

Merged

Conversation

aellispierce
Copy link
Contributor

This backports bbacd60 which allows a record created with a custom primary key to be migrated using sqlite. Previously, while attempting to copy the table, the type of the primary key was ignored, creating a DataTypeMismatch error.

This also skips copying an index if the index name begins
with "sqlite_". Previously, copying the index for custom primary keys
would fail because they are autoindexed by sqlite, so attempting to copy them
created a duplicate index. "sqlite_" is a reserved word that indicates that the
index is an internal schema object. SQLite prohibits applications from
creating objects whose names begin with "sqlite_", so this string should
be safe to use as a check.
ref https://www.sqlite.org/fileformat2.html#intschema

cc @eileencodes

Previously, if a record was created with a custom primary key, that
table could not be migrated using sqlite. While attempting to copy the
table, the type of the primary key was ignored.

Once that was corrected, copying the indexes would fail because custom
primary keys are autoindexed by sqlite by default.

To correct that, this skips copying the index if the index name begins
with "sqlite_". This is a reserved word that indicates that the
index is an internal schema object. SQLite prohibits applications from
creating objects whose names begin with "sqlite_", so this string should
be safe to use as a check.
ref https://www.sqlite.org/fileformat2.html#intschema
@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @georgeclaghorn (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@rails-bot
Copy link

warning Warning warning

  • Pull requests are usually filed against the master branch for this repo, but this one is against 5-1-stable. Please double check that you specified the right target!

@eileencodes eileencodes merged commit 5f4b57d into rails:5-1-stable Dec 7, 2017
@heatherBoveri
Copy link

Do we have an idea on when this might be released on 5.1? Apologies if I missed reading some obvious doc somewhere

@eileencodes
Copy link
Member

It will be released when we release the next version of 5.1 (which will be 5.1.5) but I'm not sure when we're planning on releasing. We'll likely release 5.1.5 after we release 5.2.

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

5 participants