Skip to content

[2.x] fix: restore 1.x migration filenames so 1.x upgrades don't re-run them - #137

Merged
imorland merged 2 commits into
2.xfrom
im/fix-duplicate-migration-names
Aug 15, 2026
Merged

imorland merged 2 commits into
2.xfrom
im/fix-duplicate-migration-names

Conversation

@imorland

Copy link
Copy Markdown
Member

Two migrations were renamed in the 2.0 refactor, so 1.x sites had no record of the new filenames and re-ran already-applied changes, failing with Duplicate column name 'published_at'. Restores both 1.x filenames and guards every step with hasColumn()/hasIndex() in both directions.

Two migrations were renamed during the 2.0 refactor:

  2026_04_17_000000_alter_polls_add_draft_columns.php
    -> 2026_05_18_000000_alter_polls_add_draft_columns.php
  2023_07_14_000002_delete_extra_polls_columns.php.disabled
    -> 2026_04_15_000000_delete_extra_polls_columns.php

Flarum tracks applied migrations by filename, so sites upgrading from
1.x had no record of the new names and re-ran migrations whose changes
were already applied, failing with:

  SQLSTATE[42S21]: Column already exists: 1060
  Duplicate column name 'published_at'

Restore both files to their 1.x filenames so previously-applied
migrations are correctly skipped, and guard every step (column adds,
drops, and the index) with hasColumn()/hasIndex() checks in both
directions. The guards cover installs that already ran the migrations
under the 2.x filenames, and repair partially-applied states.

delete_extra_polls_columns no longer uses Migration::dropColumns(),
whose generated up/down are unguarded; it is now written out longhand
with the same column definitions preserved for rollback.
@imorland
imorland requested a review from a team as a code owner August 15, 2026 07:57
@imorland imorland changed the title fix: restore 1.x migration filenames so 1.x upgrades don't re-run them [2.x] fix: restore 1.x migration filenames so 1.x upgrades don't re-run them Aug 15, 2026
@imorland
imorland merged commit 23504ad into 2.x Aug 15, 2026
23 checks passed
@imorland
imorland deleted the im/fix-duplicate-migration-names branch August 15, 2026 08:01
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.

2 participants