eslint format

This commit is contained in:
2023-06-22 17:39:19 +02:00
parent a49fd1f5bb
commit aa96ada505
+24 -24
View File
@@ -1,13 +1,13 @@
import { promises as fs } from "fs"; import { promises as fs } from 'fs'
import { import {
FileMigrationProvider, FileMigrationProvider,
Kysely, Kysely,
Migrator, Migrator,
PostgresDialect, PostgresDialect
} from "kysely"; } from 'kysely'
import * as path from "path"; import * as path from 'path'
import { Pool } from "pg"; import { Pool } from 'pg'
import Database from "./model"; import type Database from './model'
async function migrateToLatest () { async function migrateToLatest () {
const db = new Kysely<Database>({ const db = new Kysely<Database>({
@@ -16,37 +16,37 @@ async function migrateToLatest() {
host: process.env.POSTGRES_HOST, host: process.env.POSTGRES_HOST,
database: process.env.POSTGRES_DATABASE, database: process.env.POSTGRES_DATABASE,
user: process.env.POSTGRES_USER, user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD, password: process.env.POSTGRES_PASSWORD
}), })
}), })
}); })
const migrator = new Migrator({ const migrator = new Migrator({
db, db,
provider: new FileMigrationProvider({ provider: new FileMigrationProvider({
fs, fs,
path, path,
migrationFolder: path.join(__dirname, "./migrations"), migrationFolder: path.join(__dirname, './migrations')
}), })
}); })
const { error, results } = await migrator.migrateToLatest(); const { error, results } = await migrator.migrateToLatest()
results?.forEach((it) => { results?.forEach((it) => {
if (it.status === "Success") { if (it.status === 'Success') {
console.log(`migration "${it.migrationName}" was executed successfully`); console.log(`migration "${it.migrationName}" was executed successfully`)
} else if (it.status === "Error") { } else if (it.status === 'Error') {
console.error(`failed to execute migration "${it.migrationName}"`); console.error(`failed to execute migration "${it.migrationName}"`)
} }
}); })
if (error) { if (error) {
console.error("failed to migrate"); console.error('failed to migrate')
console.error(error); console.error(error)
process.exit(1); process.exit(1)
} }
await db.destroy(); await db.destroy()
} }
export default migrateToLatest; export default migrateToLatest