31 lines
939 B
JavaScript
31 lines
939 B
JavaScript
|
import pg from "./postgres.js";
|
||
|
import { upsertTest } from "./queries/catalog.js";
|
||
|
import { insertTestResult } from "./queries/results.js";
|
||
|
import { upsertAlertSilence } from "./queries/alerting.js";
|
||
|
import {
|
||
|
seed as catalogSeed,
|
||
|
table as catalogTable,
|
||
|
} from "./seeds/catalog-seed.js";
|
||
|
import {
|
||
|
seed as resultsSeed,
|
||
|
table as resultsTable,
|
||
|
} from "./seeds/results-seed.js";
|
||
|
import {
|
||
|
seed as alertingSeed,
|
||
|
table as alertingTable,
|
||
|
} from "./seeds/alerting-seed.js";
|
||
|
|
||
|
const database = process.env.POSTGRES_DATABASE ?? "qualiteer";
|
||
|
await pg.connect();
|
||
|
|
||
|
const resetAndSeed = async (table, getSeeds, seed) => {
|
||
|
await pg.query(`TRUNCATE ${table} RESTART IDENTITY CASCADE;`);
|
||
|
for (var s of getSeeds()) await seed(s);
|
||
|
};
|
||
|
|
||
|
await resetAndSeed(catalogTable, catalogSeed, upsertTest);
|
||
|
await resetAndSeed(resultsTable, resultsSeed, insertTestResult);
|
||
|
await resetAndSeed(alertingTable, alertingSeed, upsertAlertSilence);
|
||
|
|
||
|
process.exit();
|