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

Get update_attributes working with SchemaMigration #22976

Merged
merged 1 commit into from
Jan 9, 2016

Conversation

schneems
Copy link
Member

@schneems schneems commented Jan 8, 2016

You cannot use update_attributes on models that do not have a primary key. Since SchemaMigration versions are guaranteed to be unique (they have a unique index on them) we can safely use them as a primary key.

@schneems
Copy link
Member Author

schneems commented Jan 8, 2016

cc @sgrif

@sgrif
Copy link
Contributor

sgrif commented Jan 8, 2016

You have a test that needs to be updated.

@sgrif sgrif self-assigned this Jan 8, 2016
You cannot use `update_attributes` on models that do not have a primary key. Since SchemaMigration versions are guaranteed to be unique (they have a unique index on them) we can safely use them as a primary key.
@schneems schneems force-pushed the schneems/schema-migration-primary-key branch from fca9e4f to 5715506 Compare January 8, 2016 20:29
schneems referenced this pull request Jan 8, 2016
Before this patch, using `ActiveRecord::Base.primary_key_prefix_type`
with `:table_name_with_underscore` would change the `SchemaMigration` model
to have a primary key. This resulted in broken queries for PG because it tried
to return the inserted PK (which does not exist).

Closes #15051.
Closes #15419.
@schneems
Copy link
Member Author

schneems commented Jan 8, 2016

ATP

sgrif added a commit that referenced this pull request Jan 9, 2016
…mary-key

Get update_attributes working with SchemaMigration
@sgrif sgrif merged commit 34ac8a1 into rails:master Jan 9, 2016
prathamesh-sonpatki added a commit to prathamesh-sonpatki/rails that referenced this pull request Jan 9, 2016
schneems added a commit that referenced this pull request Jan 9, 2016
…long-for-schema-migrations-version

Added missing CHANGELOG entry for #22976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants