eslint format
This commit is contained in:
+24
-24
@@ -1,13 +1,13 @@
|
||||
import { promises as fs } from "fs";
|
||||
import { promises as fs } from 'fs'
|
||||
import {
|
||||
FileMigrationProvider,
|
||||
Kysely,
|
||||
Migrator,
|
||||
PostgresDialect,
|
||||
} from "kysely";
|
||||
import * as path from "path";
|
||||
import { Pool } from "pg";
|
||||
import Database from "./model";
|
||||
PostgresDialect
|
||||
} from 'kysely'
|
||||
import * as path from 'path'
|
||||
import { Pool } from 'pg'
|
||||
import type Database from './model'
|
||||
|
||||
async function migrateToLatest () {
|
||||
const db = new Kysely<Database>({
|
||||
@@ -16,37 +16,37 @@ async function migrateToLatest() {
|
||||
host: process.env.POSTGRES_HOST,
|
||||
database: process.env.POSTGRES_DATABASE,
|
||||
user: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
password: process.env.POSTGRES_PASSWORD
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
const migrator = new Migrator({
|
||||
db,
|
||||
provider: new FileMigrationProvider({
|
||||
fs,
|
||||
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) => {
|
||||
if (it.status === "Success") {
|
||||
console.log(`migration "${it.migrationName}" was executed successfully`);
|
||||
} else if (it.status === "Error") {
|
||||
console.error(`failed to execute migration "${it.migrationName}"`);
|
||||
if (it.status === 'Success') {
|
||||
console.log(`migration "${it.migrationName}" was executed successfully`)
|
||||
} else if (it.status === 'Error') {
|
||||
console.error(`failed to execute migration "${it.migrationName}"`)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (error) {
|
||||
console.error("failed to migrate");
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
console.error('failed to migrate')
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await db.destroy();
|
||||
await db.destroy()
|
||||
}
|
||||
|
||||
export default migrateToLatest;
|
||||
export default migrateToLatest
|
||||
|
||||
Reference in New Issue
Block a user