reform icon indicating copy to clipboard operation
reform copied to clipboard

postgres: reform-db fails on 'unique' constraint

Open fpawel opened this issue 5 years ago • 1 comments

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);

fpawel avatar Feb 24 '19 19:02 fpawel

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?

AlekSi avatar Aug 31 '20 04:08 AlekSi