Users reported a PostgreSQL error during a Discourse rebuild, stating that the column “token” does not exist in the “email_tokens” table. merefield and others experienced this issue, with concerns about database consistency after a failed migration. pfaffman suggested using SKIP_POST_DEPLOYMENT_MIGRATIONS as a workaround. david confirmed the issue via a database query and identified a fix in a pull request. After the fix was deployed to the tests-passed branch, users confirmed the rebuild worked successfully. aksoforever and sam thanked David for resolving the issue.
2021-12-13 08:57:12.809 UTC [902] discourse@discourse ERROR: column "token" of relation "email_tokens" does not exist
2021-12-13 08:57:12.809 UTC [902] discourse@discourse STATEMENT: ALTER TABLE email_tokens ALTER COLUMN token DROP NOT NULL
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "token" of relation "email_tokens" does not exist
For now, we were successful in starting the old container with ./launcher start app after the failed rebuild, but we don’t know whether our database is in a consistent state since the failure occurred part-way through migration.
For our peace of mind, is it known whether the database migration is fully rolled back when a failure like this occurs?
Sounds like a bug. I don’t suppose that you have SKIP_POST_DEPLOYMENT_MIGRATIONS set, so you?
Or, maybe as a work around you can set it to 1 in your app.yml, run the rebuild, and then either change it back and upgrade again or inside the container, set it to zero and migrate on the command line.