sequelize-auto icon indicating copy to clipboard operation
sequelize-auto copied to clipboard

Treat a single column, nonnull unique index as a primary key if no primary key was found

Open hhowe29 opened this issue 2 years ago • 0 comments

Don't ask how, but we have to deal with some legacy MSSQL tables that look like this:

create table foo
(
    foo_id  integer not null,
    name  varchar(50)
);

create unique index if not exists idx_foo_id
on foo (foo_id);

Modify auto-builder.ts to detect this joyous occasion and treat foo_id as a primary key. This is similar to the logic for #480 , and that block of cod would be a good insertion point for this logic. The indexes are loaded just above that.

hhowe29 avatar Mar 11 '23 19:03 hhowe29