djrobstep / migra

Like diff but for PostgreSQL schemas

Home Page:https://databaseci.com/docs/migra

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contraints on columns using collation cause false-positives

quantus opened this issue · comments

Migra always tries to recreate a unique constraints when the column uses collation.

Reproduction steps:

test.sql:

CREATE COLLATION "numeric" (provider = icu, locale = 'en@colNumeric=yes');
CREATE TABLE foo (
    bar character varying NOT NULL COLLATE "numeric"
);
ALTER TABLE foo ADD CONSTRAINT uq_bar UNIQUE (bar);

Run:

createdb a 
psql a < test.sql 
createdb b 
psql b < test.sql
migra --unsafe postgresql:///a postgresql:///b

Output:

alter table "public"."foo" drop constraint "uq_bar";

drop index if exists "public"."uq_bar";

CREATE UNIQUE INDEX uq_bar ON public.foo USING btree (bar);

alter table "public"."foo" add constraint "uq_bar" UNIQUE using index "uq_bar";

Thanks for filing this issue! This should be fixed as of the latest schemainspect release.