Skip to content

Fix migration timestamp order causing table creation dependency failures#11

Merged
Acidicts merged 2 commits intomainfrom
claude/fix-organisation-roles-error
Mar 18, 2026
Merged

Fix migration timestamp order causing table creation dependency failures#11
Acidicts merged 2 commits intomainfrom
claude/fix-organisation-roles-error

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Mar 18, 2026

Two migrations attempted to modify organisation_roles before the table was created, causing SQLite3::SQLException: no such table: organisation_roles during deployment.

Changes

  • Renamed 20260315123456_add_name_to_organisation_roles.rb20260316222820_add_name_to_organisation_roles.rb

    • Now runs after table creation and relationship fixes
  • Renamed 20260316120000_rename_default_role_in_organisation_roles.rb20260317000002_rename_default_role_in_organisation_roles.rb

    • Now runs after default_role column is added in 20260317000001

Migration execution order

20260316000001 - create_organisation_roles
20260316000002 - create_role_permissions
20260316222819 - fix_organisation_role_and_role_permissions
20260316222820 - add_name_to_organisation_roles          ← fixed
20260317000000 - backfill_organisation_signing_user_roles
20260317000001 - add_default_role_to_organisation_role
20260317000002 - rename_default_role_in_organisation_roles ← fixed

The name column is required by the backfill migration's OrganisationRole.find_or_create_by!(name: "...") calls, and is_default_role depends on renaming default_role after 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...

Co-authored-by: Acidicts <111660544+Acidicts@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] [COOL-LOGS] Fix migration error for organisation_roles table Fix migration timestamp order causing table creation dependency failures Mar 18, 2026
@Claude Claude AI requested a review from Acidicts March 18, 2026 11:00
@Acidicts Acidicts requested a review from Copilot March 18, 2026 17:16
@Acidicts Acidicts marked this pull request as ready for review March 18, 2026 17:17
@Acidicts Acidicts merged commit c34d728 into main Mar 18, 2026
8 of 10 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coolify Logs Issue

3 participants