Skip to content

Commit 154e1af

Browse files
committed
added autocomplete script to post migration scripts
1 parent 0b174b8 commit 154e1af

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cli/macrostrat/cli/database/mariadb/postgresql_migration/pgloader-post-script.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,20 @@ UPDATE macrostrat_temp.cols SET poly_geom = ST_SetSRID(poly_geom, 4326);
6767

6868
ALTER TABLE macrostrat_temp.intervals ADD COLUMN rank integer;
6969

70+
--remove duplicates from autocomplete table coming from Mariadb
71+
72+
WITH dupes AS (
73+
SELECT
74+
ctid
75+
FROM (
76+
SELECT
77+
ctid,
78+
ROW_NUMBER() OVER (PARTITION BY name, type, category ORDER BY id) AS row_num
79+
FROM
80+
macrostrat_temp.autocomplete
81+
) sub
82+
WHERE row_num > 1
83+
)
84+
DELETE FROM macrostrat_temp.autocomplete
85+
WHERE ctid IN (SELECT ctid FROM dupes);
86+

0 commit comments

Comments
 (0)