bety icon indicating copy to clipboard operation
bety copied to clipboard

pfts: make name a key

Open gsrohde opened this issue 10 years ago • 5 comments

  • ~~consolidate rows with equal names~~
  • [x] Add NOT NULL and uniqueness constraints
  • ~~Constrain name to contain no whitespace~~

Duplicate {name, modeltype_id}

ebi_production=# SELECT ARRAY_AGG(id), name FROM pfts GROUP BY name, modeltype_id HAVING COUNT(*) > 1;

shows that there are no violations of this constraint

Key constraints

Run

ALTER TABLE pfts ALTER COLUMN name SET NOT NULL;
ALTER TABLE pfts ADD CONSTRAINT unique_name_per_model UNIQUE (name, modeltype_id);

Value constraint

Is there any reason to allow whitespace in names? If not:

ALTER TABLE pfts ADD CONSTRAINT no_whitespace_in_name CHECK(name !~ '\s');

gsrohde avatar Jan 27 '15 23:01 gsrohde

name of pft does not have to be unique, we can have a populus per model, i think a good constraint would be (name, modetype_id)

robkooper avatar Jan 28 '15 02:01 robkooper

Good idea @robkooper - there are no duplicates when name, modeltype_id are used

@gsrohde i've updated the original issue to reflect this change - should be ready to implement.

dlebauer avatar Jan 28 '15 03:01 dlebauer

white spaces can be in the name.

robkooper avatar Feb 26 '15 00:02 robkooper

The same constraint has been added twice in two different migrations:

ADD CONSTRAINT unique_names_per_modeltype UNIQUE(name, modeltype_id)

ADD CONSTRAINT unique_name_per_model UNIQUE (name, modeltype_id)

One of these (the latter) should be removed.

gsrohde avatar May 12 '15 22:05 gsrohde

Still need to deal with duplicate constraint mentioned in previous comment.

gsrohde avatar Nov 03 '15 18:11 gsrohde