Migration failing on test db

I just did
RAILS_ENV=test rake db:drop db:create db:migrate

== 20200520084648 AddRatingTypes: migrating ===================================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedColumn: ERROR:  column posts.cached_version does not exist
LINE 1: ...ts"."updated_at", "posts"."reply_to_post_number", "posts"."c...
                                                             ^
HINT:  Perhaps you meant to reference the column "posts.baked_version".
/Users/faiz/discenv/discourse/plugins/discourse-ratings/db/migrate/20200520084648_add_rating_types.rb:6:in `up'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:29:in `migrate'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:56:in `migrate'
/Users/faiz/discenv/discourse/lib/tasks/db.rake:209:in `block in <main>'

Caused by:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column posts.cached_version does not exist
LINE 1: ...ts"."updated_at", "posts"."reply_to_post_number", "posts"."c...
                                                             ^
HINT:  Perhaps you meant to reference the column "posts.baked_version".
/Users/faiz/discenv/discourse/plugins/discourse-ratings/db/migrate/20200520084648_add_rating_types.rb:6:in `up'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:29:in `migrate'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:56:in `migrate'
/Users/faiz/discenv/discourse/lib/tasks/db.rake:209:in `block in <main>'

Caused by:
PG::UndefinedColumn: ERROR:  column posts.cached_version does not exist
LINE 1: ...ts"."updated_at", "posts"."reply_to_post_number", "posts"."c...
                                                             ^
HINT:  Perhaps you meant to reference the column "posts.baked_version".
/Users/faiz/discenv/discourse/plugins/discourse-ratings/db/migrate/20200520084648_add_rating_types.rb:6:in `up'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/Users/faiz/discenv/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:29:in `migrate'
/Users/faiz/discenv/discourse/lib/migration/safe_migrate.rb:56:in `migrate'
/Users/faiz/discenv/discourse/lib/tasks/db.rake:209:in `block in <main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Similar thing reported on meta: Travis builds failing posts.cached_version does not exist - dev - Discourse Meta

Pretty sure its something related to discourse internals.

cc @angus

Hm try running the commands separately

1 Like

Sure…will try and get back.

No luck…

Calling reset_column_information on the relevant tables proved to be the fix. Closing this one.

1 Like