rake-db 2.33.11 → 2.33.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2135,7 +2135,7 @@ const wrapWithEnhancingError = async (text, values, promise) => {
|
|
|
2135
2135
|
try {
|
|
2136
2136
|
return await promise;
|
|
2137
2137
|
} catch (err) {
|
|
2138
|
-
if (err && typeof err === "object" && "message" in err && typeof err.message === "string" && err.constructor.name === "PostgresError") {
|
|
2138
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string" && (err.constructor.name === "PostgresError" || err.constructor.name === "DatabaseError")) {
|
|
2139
2139
|
err.message += `\nSQL: ${text}${values ? `\nVariables: ${JSON.stringify(values)}` : ""}`;
|
|
2140
2140
|
throw new err.constructor(err);
|
|
2141
2141
|
}
|
|
@@ -2609,13 +2609,11 @@ const getMaybeTransactionAdapter = (db) => "$getAdapter" in db ? db.$getAdapter(
|
|
|
2609
2609
|
const runSqlInSavePoint = async (db, sql, code) => {
|
|
2610
2610
|
const adapter = getMaybeTransactionAdapter(db);
|
|
2611
2611
|
try {
|
|
2612
|
-
|
|
2612
|
+
const query = () => adapter.query(sql);
|
|
2613
|
+
await (adapter.isInTransaction() ? adapter.savepoint("s", query) : query());
|
|
2613
2614
|
return "done";
|
|
2614
2615
|
} catch (err) {
|
|
2615
|
-
if (err.code === code)
|
|
2616
|
-
if (adapter.isInTransaction()) await adapter.query(`ROLLBACK TO SAVEPOINT s`);
|
|
2617
|
-
return "already";
|
|
2618
|
-
}
|
|
2616
|
+
if (err.code === code) return "already";
|
|
2619
2617
|
throw err;
|
|
2620
2618
|
}
|
|
2621
2619
|
};
|
|
@@ -2745,17 +2743,14 @@ const deleteMigratedVersion = async (adapter, version, name, config) => {
|
|
|
2745
2743
|
var NoMigrationsTableError = class extends Error {};
|
|
2746
2744
|
const getMigratedVersionsMap = async (ctx, adapter, config, renameTo) => {
|
|
2747
2745
|
const table = migrationsSchemaTableSql(adapter, config);
|
|
2748
|
-
const
|
|
2746
|
+
const queryVersion = () => adapter.arrays(`SELECT * FROM ${table} ORDER BY version`);
|
|
2749
2747
|
let result;
|
|
2750
2748
|
try {
|
|
2751
|
-
if (
|
|
2752
|
-
result = await
|
|
2753
|
-
if (inTransaction) await adapter.query(`RELEASE SAVEPOINT check_migrations_table`);
|
|
2749
|
+
if (adapter.isInTransaction()) result = await adapter.savepoint("check_migrations_table", queryVersion);
|
|
2750
|
+
else result = await queryVersion();
|
|
2754
2751
|
} catch (err) {
|
|
2755
|
-
if (err.code === "42P01")
|
|
2756
|
-
|
|
2757
|
-
throw new NoMigrationsTableError();
|
|
2758
|
-
} else throw err;
|
|
2752
|
+
if (err.code === "42P01") throw new NoMigrationsTableError();
|
|
2753
|
+
else throw err;
|
|
2759
2754
|
}
|
|
2760
2755
|
if (!result.fields[1]) {
|
|
2761
2756
|
const { migrations } = await getMigrations(ctx, config, true);
|