diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 087d8668..63a13530 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -721,11 +721,11 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); "unitmodelid bigint null references aunitmodel(id), unithasownaddress bool, boughthere bool, purchasedfromvendorid bigint null references avendor(id), " + "receipt text null, purchaseddate timestamp null, description text null, replacedbyunitid bigint null references aunit(id), " + "overridemodelwarranty bool, warrantylength integer null, warrantyterms text null, usesbanking bool, metered bool, lifetimewarranty bool, " + - "text1 text null, text2 text null, text3 text null, text4 text null " + - " )"); + "text1 text null, text2 text null, text3 text null, text4 text null, " + + "CONSTRAINT UNQ_UnitSerialModelId UNIQUE (serial, unitmodelid) " + + " )"); - - // await ExecQueryAsync("CREATE UNIQUE INDEX aunit_name_id_idx ON aunit (id, name);"); + await ExecQueryAsync("CREATE UNIQUE INDEX aunit_serial_id_idx ON aunit (id, serial);"); await ExecQueryAsync("CREATE INDEX aunit_tags ON aunit using GIN(tags)");