0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

feat(schemas): init organization email domains table

This commit is contained in:
Gao Sun 2024-06-05 22:33:41 +08:00
parent ce911309da
commit d66d8c2286
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
2 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import { sql } from '@silverhand/slonik';
import type { AlterationScript } from '../lib/types/alteration.js';
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
const alteration: AlterationScript = {
up: async (pool) => {
await pool.query(sql`
create table organization_email_domains (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
/** The ID of the organization. */
organization_id varchar(21) not null
references organizations (id) on update cascade on delete cascade,
/** The email domain that will be automatically provisioned. */
email_domain varchar(128) not null,
primary key (tenant_id, organization_id, email_domain)
);
`);
await applyTableRls(pool, 'organization_email_domains');
},
down: async (pool) => {
await dropTableRls(pool, 'organization_email_domains');
await pool.query(sql`
drop table organization_email_domains
`);
},
};
export default alteration;

View file

@ -0,0 +1,13 @@
/* init_order = 2 */
/** The email domains that will be automatically provisioned for an organization. */
create table organization_email_domains (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
/** The ID of the organization. */
organization_id varchar(21) not null
references organizations (id) on update cascade on delete cascade,
/** The email domain that will be automatically provisioned. */
email_domain varchar(128) not null,
primary key (tenant_id, organization_id, email_domain)
);