mirror of
https://github.com/fosrl/pangolin.git
synced 2025-06-22 05:13:38 +02:00
all resources at the base domain closes #137
This commit is contained in:
parent
0840c166ab
commit
e475c1ea50
15 changed files with 496 additions and 141 deletions
62
server/setup/scripts/1.0.0-beta12.ts
Normal file
62
server/setup/scripts/1.0.0-beta12.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
import db from "@server/db";
|
||||
import { configFilePath1, configFilePath2 } from "@server/lib/consts";
|
||||
import { sql } from "drizzle-orm";
|
||||
import fs from "fs";
|
||||
import yaml from "js-yaml";
|
||||
|
||||
export default async function migration() {
|
||||
console.log("Running setup script 1.0.0-beta.12...");
|
||||
|
||||
try {
|
||||
// Determine which config file exists
|
||||
const filePaths = [configFilePath1, configFilePath2];
|
||||
let filePath = "";
|
||||
for (const path of filePaths) {
|
||||
if (fs.existsSync(path)) {
|
||||
filePath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!filePath) {
|
||||
throw new Error(
|
||||
`No config file found (expected config.yml or config.yaml).`
|
||||
);
|
||||
}
|
||||
|
||||
// Read and parse the YAML file
|
||||
let rawConfig: any;
|
||||
const fileContents = fs.readFileSync(filePath, "utf8");
|
||||
rawConfig = yaml.load(fileContents);
|
||||
|
||||
if (!rawConfig.flags) {
|
||||
rawConfig.flags = {};
|
||||
}
|
||||
|
||||
rawConfig.flags.allow_base_domain_resources = true;
|
||||
|
||||
// Write the updated YAML back to the file
|
||||
const updatedYaml = yaml.dump(rawConfig);
|
||||
fs.writeFileSync(filePath, updatedYaml, "utf8");
|
||||
|
||||
console.log(`Added new config option: allow_base_domain_resources`);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`Unable to add new config option: allow_base_domain_resources. This is not critical.`
|
||||
);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
try {
|
||||
db.transaction((trx) => {
|
||||
trx.run(sql`ALTER TABLE 'resources' ADD 'isBaseDomain' integer;`);
|
||||
});
|
||||
|
||||
console.log(`Added new column: isBaseDomain`);
|
||||
} catch (e) {
|
||||
console.log("Unable to add new column: isBaseDomain");
|
||||
throw e;
|
||||
}
|
||||
|
||||
console.log("Done.");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue