@nextcode/postgres-migrator
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -33,6 +33,6 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.sql ` | ||
yield this.sql.unsafe(` | ||
CREATE UNIQUE INDEX "${this.tableName}__version" | ||
ON "${this.tableName}" ("version"); | ||
`; | ||
`); | ||
}); | ||
@@ -42,3 +42,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.sql ` | ||
yield this.sql.unsafe(` | ||
CREATE TABLE "${this.tableName}" ( | ||
@@ -50,3 +50,3 @@ "id" SERIAL NOT NULL, | ||
) | ||
`; | ||
`); | ||
yield this.createIndex(); | ||
@@ -57,5 +57,5 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.sql ` | ||
yield this.sql.unsafe(` | ||
DROP INDEX IF EXISTS "${this.tableName}__version" | ||
`; | ||
`); | ||
}); | ||
@@ -65,5 +65,5 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const result = yield this.sql ` | ||
const result = yield this.sql.unsafe(` | ||
SELECT version FROM "${this.tableName}" | ||
`; | ||
`); | ||
return result.map((row) => row.version); | ||
@@ -74,7 +74,7 @@ }); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sql ` | ||
yield sql.unsafe(` | ||
INSERT INTO | ||
"${this.tableName}"("version", "timestamp") | ||
VALUES(${version}, current_timestamp) | ||
`; | ||
VALUES($1, current_timestamp) | ||
`, [version]); | ||
}); | ||
@@ -84,6 +84,6 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield sql ` | ||
yield sql.unsafe(` | ||
DELETE FROM "${this.tableName}" | ||
WHERE version = ${version} | ||
`; | ||
WHERE version = $1 | ||
`, [version]); | ||
}); | ||
@@ -129,6 +129,6 @@ } | ||
FROM pg_database | ||
WHERE datname = '${database}' | ||
WHERE datname = ${database} | ||
`; | ||
if (result.length === 0) { | ||
yield sql `CREATE DATABASE "${database}"`; | ||
yield sql.unsafe(`CREATE DATABASE ${database}`); | ||
} | ||
@@ -152,3 +152,3 @@ } | ||
if (result.length > 0) { | ||
yield sql `DROP DATABASE "${database}"`; | ||
yield sql.unsafe(`DROP DATABASE ${database}`); | ||
} | ||
@@ -164,3 +164,3 @@ } | ||
yield this.dropIndex(); | ||
yield this.sql `DROP TABLE IF EXISTS "${this.tableName}"`; | ||
yield this.sql.unsafe(`DROP TABLE IF EXISTS ${this.tableName}`); | ||
}); | ||
@@ -167,0 +167,0 @@ } |
{ | ||
"name": "@nextcode/postgres-migrator", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Postgres migration package with zero dependencies", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94613