Fix creacion de tabla + exit 0
This commit is contained in:
27
src/index.ts
27
src/index.ts
@@ -120,7 +120,7 @@ async function getCurrentVersion(db: Pool, versionTable: string) {
|
||||
`)
|
||||
return lastVersion.rows[0]
|
||||
} catch (e) {
|
||||
console.error("Error leyendo la tabla de versiones ", versionTable, e)
|
||||
console.error("[x] Error leyendo la tabla de versiones ", versionTable, e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,11 +133,11 @@ async function initVersionTable(db: Pool, versionTable: string) {
|
||||
|
||||
const ddlCreateVersionTable = `
|
||||
CREATE TABLE IF NOT EXISTS ${versionTable} (
|
||||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
version TEXT PRIMARY KEY, -- version semantica x.x.x,
|
||||
notes TEXT,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
stable BOOLEAN DEFAULT FALSE -- Si la version ha sido testada y se puede desplegar
|
||||
id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
version TEXT, -- version semantica x.x.x,
|
||||
notes TEXT,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
|
||||
stable BOOLEAN DEFAULT FALSE -- Si la version ha sido testada y se puede desplegar
|
||||
);
|
||||
`
|
||||
|
||||
@@ -154,10 +154,11 @@ async function initVersionTable(db: Pool, versionTable: string) {
|
||||
|
||||
try {
|
||||
await client.query("BEGIN")
|
||||
|
||||
await client.query(ddlCreateVersionTable)
|
||||
await client.query(insertFistValue)
|
||||
await client.query("COMMIT")
|
||||
|
||||
await client.query("BEGIN")
|
||||
await client.query(insertFistValue)
|
||||
await client.query("COMMIT")
|
||||
return 0
|
||||
} catch (e) {
|
||||
@@ -298,6 +299,14 @@ async function main() {
|
||||
migrationDir: args.migrations,
|
||||
versionTable: args.versionTable
|
||||
})
|
||||
return 0
|
||||
}
|
||||
|
||||
main().then(e => console.log(e)).catch(console.error)
|
||||
main()
|
||||
.then(e => {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user