Skip to content

Commit da1dadd

Browse files
authored
fix(db): resolve goose version collision between today's migrations (#3369)
Two migrations merged today share the goose version `20260723120000` (`set_tier_max_disk_size` from #3350 and `rename_default_team_names_to_project` from #3334). Goose panics on duplicate versions at collection time, so since the second merge **every** goose invocation fails — all DB-touching test shards on every open PR, and any deploy-time migration step. Renumbers the later-merged one to `20260723172400` (its merge time). This is safe precisely because of the failure mode: no goose run since the collision could have applied it anywhere, so no environment has it recorded under the old version; the earlier migration keeps its number and its applied history. Flagging as the likely root cause of ARM64 test-shard failures on currently-open PRs (observed on #3368) and of any migration-step failures in deploys since 17:24Z.
1 parent ac26e15 commit da1dadd

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
-- +goose Up
2+
-- +goose StatementBegin
3+
-- Data-only migration: rename generator-produced default team names to the
4+
-- project naming introduced by the dashboard-api provisioning change [EN-1885].
5+
-- Matches ONLY the two exact forms the old generator ever produced
6+
-- (provisioning/names.go): the bare form is exact-matched, the possessive
7+
-- form is suffix-anchored. Customer-chosen names that merely contain the
8+
-- phrase (e.g. 'My Default Team Stuff') are untouched.
9+
--
10+
-- Rollback map: affected rows are captured into
11+
-- public._backup_teams_default_team_rename atomically with the update, in
12+
-- this same transaction. Restore (if ever needed):
13+
-- UPDATE public.teams t SET name = b.old_name
14+
-- FROM public._backup_teams_default_team_rename b WHERE t.id = b.id;
15+
-- A follow-up migration drops the backup table after the soak period.
16+
--
17+
-- Idempotent: a re-run matches zero rows (both output forms fail the
18+
-- predicates) and ON CONFLICT keeps the original capture.
19+
DO $$
20+
DECLARE
21+
backed_up INT;
22+
bare_renamed INT;
23+
possessive_renamed INT;
24+
BEGIN
25+
CREATE TABLE IF NOT EXISTS public._backup_teams_default_team_rename (
26+
id uuid PRIMARY KEY,
27+
old_name text NOT NULL,
28+
captured_at timestamptz NOT NULL DEFAULT now()
29+
);
30+
31+
INSERT INTO public._backup_teams_default_team_rename (id, old_name)
32+
SELECT id, name
33+
FROM public.teams
34+
WHERE name = 'Default Team'
35+
OR name LIKE '%''s Default Team'
36+
ON CONFLICT (id) DO NOTHING;
37+
GET DIAGNOSTICS backed_up = ROW_COUNT;
38+
39+
UPDATE public.teams
40+
SET name = 'Personal Project'
41+
WHERE name = 'Default Team';
42+
GET DIAGNOSTICS bare_renamed = ROW_COUNT;
43+
44+
UPDATE public.teams
45+
SET name = regexp_replace(name, '''s Default Team$', '''s Project')
46+
WHERE name LIKE '%''s Default Team';
47+
GET DIAGNOSTICS possessive_renamed = ROW_COUNT;
48+
49+
RAISE NOTICE 'rename_default_team_names_to_project: backed up %, bare renamed %, possessive renamed %',
50+
backed_up, bare_renamed, possessive_renamed;
51+
END $$;
52+
-- +goose StatementEnd
53+
54+
-- +goose Down
55+
-- Intentional no-op: a pattern-based reverse would rewrite any team
56+
-- legitimately named 'Personal Project' / '...''s Project' before this
57+
-- migration ran. Exact restore uses the backup table (see Up comment);
58+
-- catastrophic rollback is an AlloyDB point-in-time restore.
59+
SELECT 1;

0 commit comments

Comments
 (0)