-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial org table and add s2s org management apis (#210)
- Loading branch information
Showing
24 changed files
with
1,582 additions
and
17 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
server/migrations/pg/20250103143000_create_org_table.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
exports.up = function (knex) { | ||
return knex.schema.createTable( | ||
'org', | ||
function (table) { | ||
table.increments('id').primary() | ||
table.string( | ||
'name', | ||
50, | ||
).notNullable() | ||
table.string( | ||
'companyLogoUrl', | ||
250, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'fontFamily', | ||
50, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'fontUrl', | ||
250, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'layoutColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'labelColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'primaryButtonColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'primaryButtonLabelColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'primaryButtonBorderColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'secondaryButtonColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'secondaryButtonLabelColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'secondaryButtonBorderColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'criticalIndicatorColor', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'emailSenderName', | ||
20, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'termsLink', | ||
250, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'privacyPolicyLink', | ||
250, | ||
).notNullable() | ||
.defaultTo('') | ||
table.string( | ||
'createdAt', | ||
19, | ||
).notNullable() | ||
.defaultTo(knex.raw("to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS')")) | ||
table.string( | ||
'updatedAt', | ||
19, | ||
).notNullable() | ||
.defaultTo(knex.raw("to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS')")) | ||
table.string( | ||
'deletedAt', | ||
19, | ||
).defaultTo(null) | ||
}, | ||
) | ||
.then(function () { | ||
return knex.schema.raw(` | ||
CREATE UNIQUE INDEX idx_unique_org_name | ||
ON "org" ("name") | ||
WHERE "deletedAt" IS NULL; | ||
`) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex.schema.dropTable('org') | ||
} |
17 changes: 17 additions & 0 deletions
17
server/migrations/pg/20250103143500_add_org_related_scopes.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
exports.up = function (knex) { | ||
return knex('scope').insert([ | ||
{ | ||
name: 'read_org', | ||
type: 's2s', | ||
note: 'Allows a S2S app to access org-specific data without modifying it.', | ||
}, | ||
{ | ||
name: 'write_org', | ||
type: 's2s', | ||
note: 'Allows a S2S app to create, update, and delete org-specific data.', | ||
}, | ||
]) | ||
} | ||
|
||
exports.down = function () { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE TABLE [org] ( | ||
"id" integer PRIMARY KEY, | ||
"name" text NOT NULL, | ||
"companyLogoUrl" text NOT NULL DEFAULT "", | ||
"fontFamily" text NOT NULL DEFAULT "", | ||
"fontUrl" text NOT NULL DEFAULT "", | ||
"layoutColor" text NOT NULL DEFAULT "", | ||
"labelColor" text NOT NULL DEFAULT "", | ||
"primaryButtonColor" text NOT NULL DEFAULT "", | ||
"primaryButtonLabelColor" text NOT NULL DEFAULT "", | ||
"primaryButtonBorderColor" text NOT NULL DEFAULT "", | ||
"secondaryButtonColor" text NOT NULL DEFAULT "", | ||
"secondaryButtonLabelColor" text NOT NULL DEFAULT "", | ||
"secondaryButtonBorderColor" text NOT NULL DEFAULT "", | ||
"criticalIndicatorColor" text NOT NULL DEFAULT "", | ||
"emailSenderName" text NOT NULL DEFAULT "", | ||
"termsLink" text NOT NULL DEFAULT "", | ||
"privacyPolicyLink" text NOT NULL DEFAULT "", | ||
"createdAt" text DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" text DEFAULT CURRENT_TIMESTAMP, | ||
"deletedAt" text DEFAULT null | ||
); | ||
CREATE UNIQUE INDEX idx_unique_org_name ON org (name) WHERE deletedAt IS NULL; |
2 changes: 2 additions & 0 deletions
2
server/migrations/sqlite/0024_add_org_related_system_scopes.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT INTO scope ("name", "type", "note") values ('read_org', 's2s', 'Allows a S2S app to access org-specific data without modifying it.'); | ||
INSERT INTO scope ("name", "type", "note") values ('write_org', 's2s', 'Allows a S2S app to create, update, and delete org-specific data.'); |
Oops, something went wrong.