mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
chore: update schema
This commit is contained in:
parent
96ae79c37c
commit
fc5d575dd2
3 changed files with 4 additions and 15 deletions
|
@ -11,7 +11,7 @@ const alteration: AlterationScript = {
|
||||||
tenant_id varchar(21) not null
|
tenant_id varchar(21) not null
|
||||||
references tenants (id) on update cascade on delete cascade,
|
references tenants (id) on update cascade on delete cascade,
|
||||||
id varchar(21) not null,
|
id varchar(21) not null,
|
||||||
email varchar(256) not null,
|
email varchar(128) not null,
|
||||||
token varchar(256) not null,
|
token varchar(256) not null,
|
||||||
context jsonb not null default '{}'::jsonb,
|
context jsonb not null default '{}'::jsonb,
|
||||||
status varchar(64) not null default 'active',
|
status varchar(64) not null default 'active',
|
||||||
|
@ -20,11 +20,7 @@ const alteration: AlterationScript = {
|
||||||
primary key (id)
|
primary key (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create index one_time_token__id on one_time_tokens (tenant_id, id);
|
create index one_time_token__email_status on one_time_tokens (tenant_id, email, status);
|
||||||
|
|
||||||
create index one_time_token__email on one_time_tokens (tenant_id, email);
|
|
||||||
|
|
||||||
create unique index one_time_token__active_unique on one_time_tokens (tenant_id, email, token) where status = 'active';
|
|
||||||
`);
|
`);
|
||||||
|
|
||||||
await applyTableRls(pool, 'one_time_tokens');
|
await applyTableRls(pool, 'one_time_tokens');
|
||||||
|
|
|
@ -2,15 +2,12 @@ import { type ToZodObject } from '@logto/connector-kit';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
export type OneTimeTokenContext = {
|
export type OneTimeTokenContext = {
|
||||||
// Declare the appIds that users can sign-up to.
|
|
||||||
applicationIds?: string[];
|
|
||||||
// Used for organization JIT provisioning.
|
// Used for organization JIT provisioning.
|
||||||
jitOrganizationIds?: string[];
|
jitOrganizationIds?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const oneTimeTokenContextGuard = z
|
export const oneTimeTokenContextGuard = z
|
||||||
.object({
|
.object({
|
||||||
applicationIds: z.string().array(),
|
|
||||||
jitOrganizationIds: z.string().array(),
|
jitOrganizationIds: z.string().array(),
|
||||||
})
|
})
|
||||||
.partial() satisfies ToZodObject<OneTimeTokenContext>;
|
.partial() satisfies ToZodObject<OneTimeTokenContext>;
|
||||||
|
|
|
@ -4,7 +4,7 @@ create table one_time_tokens (
|
||||||
tenant_id varchar(21) not null
|
tenant_id varchar(21) not null
|
||||||
references tenants (id) on update cascade on delete cascade,
|
references tenants (id) on update cascade on delete cascade,
|
||||||
id varchar(21) not null,
|
id varchar(21) not null,
|
||||||
email varchar(256) not null,
|
email varchar(128) not null,
|
||||||
token varchar(256) not null,
|
token varchar(256) not null,
|
||||||
context jsonb /* @use OneTimeTokenContext */ not null default '{}'::jsonb,
|
context jsonb /* @use OneTimeTokenContext */ not null default '{}'::jsonb,
|
||||||
status varchar(64) /* @use OneTimeTokenStatus */ not null default 'active',
|
status varchar(64) /* @use OneTimeTokenStatus */ not null default 'active',
|
||||||
|
@ -13,8 +13,4 @@ create table one_time_tokens (
|
||||||
primary key (id)
|
primary key (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
create index one_time_token__id on one_time_tokens (tenant_id, id);
|
create index one_time_token__email_status on one_time_tokens (tenant_id, email, status);
|
||||||
|
|
||||||
create index one_time_token__email on one_time_tokens (tenant_id, email);
|
|
||||||
|
|
||||||
create unique index one_time_token__active_unique on one_time_tokens (tenant_id, email, token) where status = 'active';
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue