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:
parent
532b7bb5e3
commit
c47e0192ff
2 changed files with 24 additions and 1 deletions
|
@ -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;
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue