mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 18:11:10 +10:00
36 lines
727 B
TypeScript
36 lines
727 B
TypeScript
import * as path from 'path';
|
|
import { promises as fs } from 'fs';
|
|
import pg from 'pg';
|
|
import {
|
|
Kysely,
|
|
Migrator,
|
|
PostgresDialect,
|
|
FileMigrationProvider,
|
|
} from 'kysely';
|
|
import { run } from 'kysely-migration-cli';
|
|
import * as dotenv from 'dotenv';
|
|
import { envPath } from '../helpers/utils';
|
|
|
|
dotenv.config({ path: envPath });
|
|
|
|
const migrationFolder = path.join(__dirname, './migrations');
|
|
|
|
const db = new Kysely<any>({
|
|
dialect: new PostgresDialect({
|
|
pool: new pg.Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
}) as any,
|
|
}),
|
|
});
|
|
|
|
const migrator = new Migrator({
|
|
db,
|
|
provider: new FileMigrationProvider({
|
|
fs,
|
|
path,
|
|
migrationFolder,
|
|
}),
|
|
});
|
|
|
|
run(db, migrator, migrationFolder);
|