mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
feat(schemas): init organization email domains table
This commit is contained in:
parent
ce911309da
commit
d66d8c2286
2 changed files with 44 additions and 0 deletions
|
@ -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;
|
13
packages/schemas/tables/organization_email_domains.sql
Normal file
13
packages/schemas/tables/organization_email_domains.sql
Normal 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)
|
||||||
|
);
|
Loading…
Add table
Reference in a new issue