Skip to content

Commit

Permalink
chore: add SAML to application type
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyYe committed Nov 7, 2024
1 parent 302cfa0 commit b5bb11c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 40 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { sql } from '@silverhand/slonik';

import type { AlterationScript } from '../lib/types/alteration.js';

const alteration: AlterationScript = {
up: async (pool) => {
await pool.query(sql`
alter type application_type add value if not exists 'SAML';
`);
},
down: async (pool) => {
await pool.query(sql`
delete from applications where type = 'SAML';
`);

await pool.query(sql`
create type application_type_new as enum ('Native', 'SPA', 'Traditional', 'MachineToMachine', 'Protected');
alter table applications
alter column type type application_type_new
using type::text::application_type_new;
drop type application_type;
alter type application_type_new rename to application_type;
`);
},
};

export default alteration;
1 change: 0 additions & 1 deletion packages/schemas/src/seeds/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const buildDemoAppDataForTenant = (tenantId: string): Application => ({
customClientMetadata: {},
protectedAppMetadata: null,
isThirdParty: false,
isVisible: true,
createdAt: 0,
customData: {},
});
Expand Down
7 changes: 1 addition & 6 deletions packages/schemas/tables/applications.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* init_order = 1 */

create type application_type as enum ('Native', 'SPA', 'Traditional', 'MachineToMachine', 'Protected');
create type application_type as enum ('Native', 'SPA', 'Traditional', 'MachineToMachine', 'Protected', 'SAML');

create table applications (
tenant_id varchar(21) not null
Expand All @@ -16,13 +16,8 @@ create table applications (
protected_app_metadata jsonb /* @use ProtectedAppMetadata */,
custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
is_third_party boolean not null default false,
is_visible boolean not null default true,
created_at timestamptz not null default(now()),
primary key (id),
constraint check_visibility_rules check (
(is_third_party = true) OR -- Third-party applications can set any visibility
(is_visible = true) -- Non-third-party applications must remain visible
)
);

create index applications__id
Expand Down

0 comments on commit b5bb11c

Please sign in to comment.