Fix migration timestamp order causing table creation dependency failures#11
Merged
Fix migration timestamp order causing table creation dependency failures#11
Conversation
Co-authored-by: Acidicts <111660544+Acidicts@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two migrations attempted to modify
organisation_rolesbefore the table was created, causingSQLite3::SQLException: no such table: organisation_rolesduring deployment.Changes
Renamed
20260315123456_add_name_to_organisation_roles.rb→20260316222820_add_name_to_organisation_roles.rbRenamed
20260316120000_rename_default_role_in_organisation_roles.rb→20260317000002_rename_default_role_in_organisation_roles.rbdefault_rolecolumn is added in20260317000001Migration execution order
The
namecolumn is required by the backfill migration'sOrganisationRole.find_or_create_by!(name: "...")calls, andis_default_roledepends on renamingdefault_roleafter it exists.Original prompt
This section details on the original issue you should resolve
<issue_title>Coolify Logs Issue</issue_title>
<issue_description>
2026-03-18T10:55:59.205582027Z bin/rails aborted!
2026-03-18T10:55:59.205662082Z StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
2026-03-18T10:55:59.205673953Z
2026-03-18T10:55:59.205679268Z SQLite3::SQLException: no such table: organisation_roles:
2026-03-18T10:55:59.205684305Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:55:59.206274933Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:55:59.206303970Z
2026-03-18T10:55:59.206340785Z Caused by:
2026-03-18T10:55:59.206346230Z ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: organisation_roles: (ActiveRecord::StatementInvalid)
2026-03-18T10:55:59.206351933Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:55:59.209133967Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:55:59.209185244Z
2026-03-18T10:55:59.209303318Z Caused by:
2026-03-18T10:55:59.209344466Z SQLite3::SQLException: no such table: organisation_roles: (SQLite3::SQLException)
2026-03-18T10:55:59.209355059Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:55:59.209360781Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:55:59.209587559Z Tasks: TOP => db:prepare
2026-03-18T10:55:59.209891614Z (See full trace by running task with --trace)
2026-03-18T10:55:59.227473701Z Migrating to AddNameToOrganisationRoles (20260315123456)
2026-03-18T10:55:59.227513071Z == 20260315123456 AddNameToOrganisationRoles: migrating =======================
2026-03-18T10:55:59.227522127Z -- add_column(:organisation_roles, :name, :string, {null: false, default: ""})
2026-03-18T10:56:04.913505718Z bin/rails aborted!
2026-03-18T10:56:04.913603940Z StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
2026-03-18T10:56:04.913616570Z
2026-03-18T10:56:04.913623533Z SQLite3::SQLException: no such table: organisation_roles:
2026-03-18T10:56:04.913630681Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:56:04.913883959Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:56:04.913903625Z
2026-03-18T10:56:04.913910551Z Caused by:
2026-03-18T10:56:04.914042551Z ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: organisation_roles: (ActiveRecord::StatementInvalid)
2026-03-18T10:56:04.914056069Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:56:04.915943048Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:56:04.915971067Z
2026-03-18T10:56:04.915985048Z Caused by:
2026-03-18T10:56:04.915990271Z SQLite3::SQLException: no such table: organisation_roles: (SQLite3::SQLException)
2026-03-18T10:56:04.915995585Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:56:04.916952621Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:56:04.917197621Z Tasks: TOP => db:prepare
2026-03-18T10:56:04.917211213Z (See full trace by running task with --trace)
2026-03-18T10:56:04.935007745Z Migrating to AddNameToOrganisationRoles (20260315123456)
2026-03-18T10:56:04.935083856Z == 20260315123456 AddNameToOrganisationRoles: migrating =======================
2026-03-18T10:56:04.935094522Z -- add_column(:organisation_roles, :name, :string, {null: false, default: ""})
2026-03-18T10:56:09.820713691Z bin/rails aborted!
2026-03-18T10:56:09.820801635Z StandardError: An error has occurred, this and all later migrations canceled: (StandardError)
2026-03-18T10:56:09.820815672Z
2026-03-18T10:56:09.820822135Z SQLite3::SQLException: no such table: organisation_roles:
2026-03-18T10:56:09.820842561Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:56:09.821004561Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:56:09.821601782Z
2026-03-18T10:56:09.821662115Z Caused by:
2026-03-18T10:56:09.821676615Z ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: organisation_roles: (ActiveRecord::StatementInvalid)
2026-03-18T10:56:09.821684671Z ALTER TABLE "organisation_roles" ADD "name" varchar DEFAULT '' NOT NULL
2026-03-18T10:56:09.825080259Z /rails/db/migrate/20260315123456_add_name_to_organisation_roles.rb:3:in 'AddNameToOrganisationRoles#change'
2026-03-18T10:56:09.825127388Z
2026-03-18T10:56:09.825158944Z Caused by:
2026-03-18T10:56:09...