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.js
CHANGED
|
@@ -2158,7 +2158,7 @@ const wrapWithEnhancingError = async (text, values, promise) => {
|
|
|
2158
2158
|
try {
|
|
2159
2159
|
return await promise;
|
|
2160
2160
|
} catch (err) {
|
|
2161
|
-
if (err && typeof err === "object" && "message" in err && typeof err.message === "string" && err.constructor.name === "PostgresError") {
|
|
2161
|
+
if (err && typeof err === "object" && "message" in err && typeof err.message === "string" && (err.constructor.name === "PostgresError" || err.constructor.name === "DatabaseError")) {
|
|
2162
2162
|
err.message += `\nSQL: ${text}${values ? `\nVariables: ${JSON.stringify(values)}` : ""}`;
|
|
2163
2163
|
throw new err.constructor(err);
|
|
2164
2164
|
}
|
|
@@ -2632,13 +2632,11 @@ const getMaybeTransactionAdapter = (db) => "$getAdapter" in db ? db.$getAdapter(
|
|
|
2632
2632
|
const runSqlInSavePoint = async (db, sql, code) => {
|
|
2633
2633
|
const adapter = getMaybeTransactionAdapter(db);
|
|
2634
2634
|
try {
|
|
2635
|
-
|
|
2635
|
+
const query = () => adapter.query(sql);
|
|
2636
|
+
await (adapter.isInTransaction() ? adapter.savepoint("s", query) : query());
|
|
2636
2637
|
return "done";
|
|
2637
2638
|
} catch (err) {
|
|
2638
|
-
if (err.code === code)
|
|
2639
|
-
if (adapter.isInTransaction()) await adapter.query(`ROLLBACK TO SAVEPOINT s`);
|
|
2640
|
-
return "already";
|
|
2641
|
-
}
|
|
2639
|
+
if (err.code === code) return "already";
|
|
2642
2640
|
throw err;
|
|
2643
2641
|
}
|
|
2644
2642
|
};
|
|
@@ -2768,17 +2766,14 @@ const deleteMigratedVersion = async (adapter, version, name, config) => {
|
|
|
2768
2766
|
var NoMigrationsTableError = class extends Error {};
|
|
2769
2767
|
const getMigratedVersionsMap = async (ctx, adapter, config, renameTo) => {
|
|
2770
2768
|
const table = migrationsSchemaTableSql(adapter, config);
|
|
2771
|
-
const
|
|
2769
|
+
const queryVersion = () => adapter.arrays(`SELECT * FROM ${table} ORDER BY version`);
|
|
2772
2770
|
let result;
|
|
2773
2771
|
try {
|
|
2774
|
-
if (
|
|
2775
|
-
result = await
|
|
2776
|
-
if (inTransaction) await adapter.query(`RELEASE SAVEPOINT check_migrations_table`);
|
|
2772
|
+
if (adapter.isInTransaction()) result = await adapter.savepoint("check_migrations_table", queryVersion);
|
|
2773
|
+
else result = await queryVersion();
|
|
2777
2774
|
} catch (err) {
|
|
2778
|
-
if (err.code === "42P01")
|
|
2779
|
-
|
|
2780
|
-
throw new NoMigrationsTableError();
|
|
2781
|
-
} else throw err;
|
|
2775
|
+
if (err.code === "42P01") throw new NoMigrationsTableError();
|
|
2776
|
+
else throw err;
|
|
2782
2777
|
}
|
|
2783
2778
|
if (!result.fields[1]) {
|
|
2784
2779
|
const { migrations } = await getMigrations(ctx, config, true);
|