mirror of
https://github.com/fosrl/pangolin.git
synced 2025-09-01 07:20:06 +02:00
add sql migration
This commit is contained in:
parent
e11748fe30
commit
d8183bfd0d
2 changed files with 24 additions and 3 deletions
|
@ -1,9 +1,13 @@
|
||||||
app:
|
app:
|
||||||
dashboard_url: "http://localhost:3002"
|
dashboard_url: "http://localhost:3002"
|
||||||
base_domain: "localhost"
|
|
||||||
log_level: "info"
|
log_level: "info"
|
||||||
save_logs: false
|
save_logs: false
|
||||||
|
|
||||||
|
domains:
|
||||||
|
domain1:
|
||||||
|
base_domain: "example.com"
|
||||||
|
cert_resolver: "letsencrypt"
|
||||||
|
|
||||||
server:
|
server:
|
||||||
external_port: 3000
|
external_port: 3000
|
||||||
internal_port: 3001
|
internal_port: 3001
|
||||||
|
@ -14,7 +18,6 @@ server:
|
||||||
resource_session_request_param: "p_session_request"
|
resource_session_request_param: "p_session_request"
|
||||||
|
|
||||||
traefik:
|
traefik:
|
||||||
cert_resolver: "letsencrypt"
|
|
||||||
http_entrypoint: "web"
|
http_entrypoint: "web"
|
||||||
https_entrypoint: "websecure"
|
https_entrypoint: "websecure"
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,25 @@ export default async function migration() {
|
||||||
console.log(`Running setup script ${version}...`);
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db.transaction((trx) => {});
|
db.transaction((trx) => {
|
||||||
|
trx.run(sql`CREATE TABLE 'domains' (
|
||||||
|
'domainId' text PRIMARY KEY NOT NULL,
|
||||||
|
'baseDomain' text NOT NULL,
|
||||||
|
'configManaged' integer DEFAULT false NOT NULL
|
||||||
|
);`);
|
||||||
|
|
||||||
|
trx.run(sql`CREATE TABLE 'orgDomains' (
|
||||||
|
'orgId' text NOT NULL,
|
||||||
|
'domainId' text NOT NULL,
|
||||||
|
FOREIGN KEY ('orgId') REFERENCES 'orgs'('orgId') ON UPDATE no action ON DELETE cascade,
|
||||||
|
FOREIGN KEY ('domainId') REFERENCES 'domains'('domainId') ON UPDATE no action ON DELETE cascade
|
||||||
|
);`);
|
||||||
|
|
||||||
|
trx.run(
|
||||||
|
sql`ALTER TABLE 'resources' ADD 'domainId' text REFERENCES domains(domainId);`
|
||||||
|
);
|
||||||
|
trx.run(sql`ALTER TABLE 'orgs' DROP COLUMN 'domain';`);
|
||||||
|
});
|
||||||
|
|
||||||
console.log(`Migrated database schema`);
|
console.log(`Migrated database schema`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue