aboutsummaryrefslogtreecommitdiffstats
path: root/backend/migrate.ts
blob: f02d7e945ddc916688aadb08b8b6f23ee1d8995a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* eslint-disable @typescript-eslint/no-var-requires */
import { SlonikMigrator } from "@slonik/migrator";
import { createPool } from "slonik";
import dotenv from "dotenv";
dotenv.config();

import * as config from "./config";

// in an existing slonik project, this would usually be setup in another module
const slonik = createPool(config.postgresConnectionString); // e.g. 'postgresql://postgres:postgres@localhost:5433/postgres'

const migrator = new SlonikMigrator({
    migrationsPath: __dirname + "/migrations",
    migrationTableName: "migration",
    slonik,
    logger: console,
});

migrator.runAsCLI();