Skip to content

Commit 5ac32bf

Browse files
jhfclaude
andcommitted
fix: Replace stale enterprise_group references with power_group in later migrations
Migration 20260223185108 (remove_invalid_codes) does CREATE OR REPLACE VIEW statistical_unit_def with hardcoded 'enterprise_group' enum casts and enterprise_group_id column references. Since the seed migration renamed these to power_group/power_group_id, this migration would fail at apply time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bfeab2c commit 5ac32bf

3 files changed

+13
-13
lines changed

migrations/20260203134134_remove_duplicate_valid_range_gist_indices.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ DROP INDEX IF EXISTS public.ix_legal_unit_valid_range;
1616
DROP INDEX IF EXISTS public.ix_establishment_valid_range;
1717
DROP INDEX IF EXISTS public.ix_activity_valid_range;
1818
DROP INDEX IF EXISTS public.ix_contact_valid_range;
19-
DROP INDEX IF EXISTS public.ix_enterprise_group_valid_range;
19+
-- power_group (formerly enterprise_group) is non-temporal, no index to drop
2020
DROP INDEX IF EXISTS public.ix_location_valid_range;
2121
DROP INDEX IF EXISTS public.ix_person_for_unit_valid_range;
2222
DROP INDEX IF EXISTS public.ix_stat_for_unit_valid_range;

migrations/20260223185108_remove_invalid_codes_from_derive_pipeline.down.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,13 +1215,13 @@ FROM external_ident ei
12151215
JOIN external_ident_type eit ON ei.type_id = eit.id
12161216
WHERE ei.enterprise_id IS NOT NULL
12171217
UNION ALL
1218-
SELECT 'enterprise_group'::statistical_unit_type AS unit_type,
1219-
ei.enterprise_group_id AS unit_id,
1218+
SELECT 'power_group'::statistical_unit_type AS unit_type,
1219+
ei.power_group_id AS unit_id,
12201220
eit.code AS type_code,
12211221
COALESCE(ei.ident, ei.idents::text::character varying) AS ident
12221222
FROM external_ident ei
12231223
JOIN external_ident_type eit ON ei.type_id = eit.id
1224-
WHERE ei.enterprise_group_id IS NOT NULL) all_idents
1224+
WHERE ei.power_group_id IS NOT NULL) all_idents
12251225
GROUP BY all_idents.unit_type, all_idents.unit_id
12261226
), tag_paths_agg AS (
12271227
SELECT all_tags.unit_type,
@@ -1248,12 +1248,12 @@ FROM tag_for_unit tfu
12481248
JOIN tag t ON tfu.tag_id = t.id
12491249
WHERE tfu.enterprise_id IS NOT NULL
12501250
UNION ALL
1251-
SELECT 'enterprise_group'::statistical_unit_type AS unit_type,
1252-
tfu.enterprise_group_id AS unit_id,
1251+
SELECT 'power_group'::statistical_unit_type AS unit_type,
1252+
tfu.power_group_id AS unit_id,
12531253
t.path
12541254
FROM tag_for_unit tfu
12551255
JOIN tag t ON tfu.tag_id = t.id
1256-
WHERE tfu.enterprise_group_id IS NOT NULL) all_tags
1256+
WHERE tfu.power_group_id IS NOT NULL) all_tags
12571257
GROUP BY all_tags.unit_type, all_tags.unit_id
12581258
), data AS (
12591259
SELECT timeline_establishment.unit_type,

migrations/20260223185108_remove_invalid_codes_from_derive_pipeline.up.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,13 @@ FROM external_ident ei
12081208
JOIN external_ident_type eit ON ei.type_id = eit.id
12091209
WHERE ei.enterprise_id IS NOT NULL
12101210
UNION ALL
1211-
SELECT 'enterprise_group'::statistical_unit_type AS unit_type,
1212-
ei.enterprise_group_id AS unit_id,
1211+
SELECT 'power_group'::statistical_unit_type AS unit_type,
1212+
ei.power_group_id AS unit_id,
12131213
eit.code AS type_code,
12141214
COALESCE(ei.ident, ei.idents::text::character varying) AS ident
12151215
FROM external_ident ei
12161216
JOIN external_ident_type eit ON ei.type_id = eit.id
1217-
WHERE ei.enterprise_group_id IS NOT NULL) all_idents
1217+
WHERE ei.power_group_id IS NOT NULL) all_idents
12181218
GROUP BY all_idents.unit_type, all_idents.unit_id
12191219
), tag_paths_agg AS (
12201220
SELECT all_tags.unit_type,
@@ -1241,12 +1241,12 @@ FROM tag_for_unit tfu
12411241
JOIN tag t ON tfu.tag_id = t.id
12421242
WHERE tfu.enterprise_id IS NOT NULL
12431243
UNION ALL
1244-
SELECT 'enterprise_group'::statistical_unit_type AS unit_type,
1245-
tfu.enterprise_group_id AS unit_id,
1244+
SELECT 'power_group'::statistical_unit_type AS unit_type,
1245+
tfu.power_group_id AS unit_id,
12461246
t.path
12471247
FROM tag_for_unit tfu
12481248
JOIN tag t ON tfu.tag_id = t.id
1249-
WHERE tfu.enterprise_group_id IS NOT NULL) all_tags
1249+
WHERE tfu.power_group_id IS NOT NULL) all_tags
12501250
GROUP BY all_tags.unit_type, all_tags.unit_id
12511251
), data AS (
12521252
SELECT timeline_establishment.unit_type,

0 commit comments

Comments
 (0)