Run explorer migration statements separately
This commit is contained in:
@@ -9,7 +9,15 @@ async function main() {
|
||||
const pool = createPool();
|
||||
const sqlPath = path.resolve(__dirname, "../migrations/001_init.sql");
|
||||
const sql = await readFile(sqlPath, "utf8");
|
||||
await pool.query(sql);
|
||||
const statements = sql
|
||||
.split(/;\s*\n/g)
|
||||
.map((statement) => statement.trim())
|
||||
.filter((statement) => statement.length > 0);
|
||||
|
||||
for (const statement of statements) {
|
||||
await pool.query(statement);
|
||||
}
|
||||
|
||||
await pool.end();
|
||||
console.log(`Applied migration ${sqlPath}`);
|
||||
}
|
||||
@@ -18,4 +26,3 @@ main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user