reform
reform copied to clipboard
postgres: reform-db fails on 'unique' constraint
General description of the problem
Reform does not generate models for tables with UNIQUE
constraint in body of CREATE TABLE
Code snippets to reproduce the problem
CREATE TABLE some_table
(
id SERIAL PRIMARY KEY NOT NULL,
special_field INTEGER NOT NULL,
UNIQUE (id, special_field)
);
>reform-db -db-driver=postgres -db-source="..." init
>reform-db: Expected single column primary key, got 2
The next code works:
CREATE TABLE some_table
(
id SERIAL PRIMARY KEY NOT NULL,
special_field INTEGER NOT NULL
);
CREATE UNIQUE INDEX pg_unique_some_table_id_special_field ON some_table (id, special_field);
I think the root cause is the same as in https://github.com/go-reform/reform/issues/237. It should be fixed in 1.4.1. May you check please?