0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-17 22:04:19 -05:00

feat(schemas): add unique constrain to the SSO connectorName field (#4974)

add unique constrain to the SSO connectorName field
This commit is contained in:
simeng-li 2023-11-28 13:55:47 +08:00 committed by GitHub
parent 532b7bb5e3
commit c47e0192ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,21 @@
import { sql } from 'slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
const alteration: AlterationScript = {
up: async (pool) => {
await pool.query(sql`
alter table sso_connectors
add constraint sso_connectors__connector_name__unique
unique (tenant_id, connector_name);
`);
},
down: async (pool) => {
await pool.query(sql`
alter table sso_connectors
drop constraint sso_connectors__connector_name__unique;
`);
},
};
export default alteration;

View file

@ -18,7 +18,9 @@ create table sso_connectors (
sync_profile boolean not null default FALSE,
/** When the SSO connector was created. */
created_at timestamptz not null default(now()),
primary key (id)
primary key (id),
constraint sso_connectors__connector_name__unique
unique (tenant_id, connector_name)
);
create index sso_connectors__id