Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(db): restore unique migration prefixes (#8372)

Multica Eve24fecdd91b2a
diff --git a/server/internal/migrations/migrations_lint_test.go b/server/internal/migrations/migrations_lint_test.go
index 60cfb20342..5488bbfb22 100644
--- a/server/internal/migrations/migrations_lint_test.go
+++ b/server/internal/migrations/migrations_lint_test.go
@@ -14,9 +14,8 @@ func TestMigrationNumericPrefixesAreUnique(t *testing.T) {
files := migrationFilesForLint(t, "*.up.sql")
// Migrations through 128 contain historical duplicate numeric prefixes.
- // Main also shipped the two exact 468 stems below before this lint landed.
- // Preserve their ledger identities; reject any additional collision, including
- // a third 468 migration. The runner identifies migrations by full stem.
+ // From 129 onward, keep the numeric sequence unique so release tooling and
+ // operators can identify one schema change unambiguously by its number.
const firstUniqueMigrationNumber = 129
stemByNumber := make(map[int]string)
for _, file := range files {
@@ -33,9 +32,6 @@ func TestMigrationNumericPrefixesAreUnique(t *testing.T) {
continue
}
if previous, exists := stemByNumber[number]; exists {
- if previous == "468_comment_deleted_at" && stem == "468_drop_reference_only_column" {
- continue
- }
t.Errorf("migrations %s and %s share numeric prefix %s", previous, stem, prefix)
continue
}
diff --git a/server/migrations/468_comment_deleted_at.down.sql b/server/migrations/471_comment_deleted_at.down.sql
similarity index 100%
rename from server/migrations/468_comment_deleted_at.down.sql
rename to server/migrations/471_comment_deleted_at.down.sql
diff --git a/server/migrations/468_comment_deleted_at.up.sql b/server/migrations/471_comment_deleted_at.up.sql
similarity index 58%
rename from server/migrations/468_comment_deleted_at.up.sql
rename to server/migrations/471_comment_deleted_at.up.sql
index 8b09ff9a2f..e91a08716e 100644
--- a/server/migrations/468_comment_deleted_at.up.sql
+++ b/server/migrations/471_comment_deleted_at.up.sql
@@ -5,5 +5,7 @@
-- is gone. The application owns that lifecycle; nothing here relies on the
-- legacy parent_id cascade.
--
--- Nullable with no default, so this is a metadata-only change.
-ALTER TABLE comment ADD COLUMN deleted_at TIMESTAMPTZ NULL;
+-- Nullable with no default, so this is a metadata-only change. IF NOT EXISTS
+-- lets development databases that applied this migration under its original
+-- unreleased 468 stem advance to the corrected ledger version safely.
+ALTER TABLE comment ADD COLUMN IF NOT EXISTS deleted_at TIMESTAMPTZ NULL;