Guides: Explain reset_column_information in Chapter "Migrations and Seed Data" #51918
GitToTheHub
started this conversation in
Docs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Chapter Migrations and Seed Data should add the explanation of reset_column_information.
I had 12 migrations to migrate in a production database and was wondering, why the migration was failing when setting reference data for existing data with the migration, after a new reference column was added with
add_reference
. The error was:ActiveModel::MissingAttributeError: can't write unknown attribute 'activity_id'
After executing
rails db:migrate
a second time, without changing something on the migration, the migration was successful.In the Rails forum I found someone with the same Issue. The solution was to call
reset_column_information
on the table, which was modified before withadd_column
. For me the solution is to call it afteradd_reference
.This issue here is for documentation. I will make a PR for this.
Beta Was this translation helpful? Give feedback.
All reactions