rake-db 2.10.23 → 2.10.25
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 +15 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -148,17 +148,28 @@ const setAdminCredentialsToOptions = async (options, create) => {
|
|
|
148
148
|
}));
|
|
149
149
|
};
|
|
150
150
|
const createSchemaMigrations = async (db, config) => {
|
|
151
|
-
var _a, _b;
|
|
151
|
+
var _a, _b, _c;
|
|
152
|
+
const { schema } = db;
|
|
153
|
+
if (schema && schema !== "public") {
|
|
154
|
+
try {
|
|
155
|
+
await db.query(`CREATE SCHEMA "${schema}"`);
|
|
156
|
+
(_a = config.logger) == null ? void 0 : _a.log(`Created schema ${schema}`);
|
|
157
|
+
} catch (err) {
|
|
158
|
+
if (err.code !== "42P06") {
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
152
163
|
try {
|
|
153
164
|
await db.query(
|
|
154
165
|
`CREATE TABLE ${quoteWithSchema({
|
|
155
166
|
name: config.migrationsTable
|
|
156
167
|
})} ( version TEXT NOT NULL )`
|
|
157
168
|
);
|
|
158
|
-
(
|
|
169
|
+
(_b = config.logger) == null ? void 0 : _b.log("Created versions table");
|
|
159
170
|
} catch (err) {
|
|
160
171
|
if (err.code === "42P07") {
|
|
161
|
-
(
|
|
172
|
+
(_c = config.logger) == null ? void 0 : _c.log("Versions table exists");
|
|
162
173
|
} else {
|
|
163
174
|
throw err;
|
|
164
175
|
}
|
|
@@ -2294,7 +2305,7 @@ const execute = async (options, sql) => {
|
|
|
2294
2305
|
}
|
|
2295
2306
|
};
|
|
2296
2307
|
const createOrDrop = async (options, adminOptions, config, args) => {
|
|
2297
|
-
var _a, _b, _c, _d
|
|
2308
|
+
var _a, _b, _c, _d;
|
|
2298
2309
|
const params = getDatabaseAndUserFromOptions(options);
|
|
2299
2310
|
const result = await execute(
|
|
2300
2311
|
setAdapterOptions(adminOptions, { database: "postgres" }),
|
|
@@ -2332,21 +2343,6 @@ Don't use this command for database service providers, only for a local db.`;
|
|
|
2332
2343
|
if (!args.create)
|
|
2333
2344
|
return;
|
|
2334
2345
|
const db = new Adapter(options);
|
|
2335
|
-
const { schema } = db;
|
|
2336
|
-
if (schema) {
|
|
2337
|
-
db.schema = void 0;
|
|
2338
|
-
try {
|
|
2339
|
-
await db.query(`CREATE SCHEMA "${schema}"`);
|
|
2340
|
-
(_e = config.logger) == null ? void 0 : _e.log(`Created schema ${schema}`);
|
|
2341
|
-
} catch (err) {
|
|
2342
|
-
if (err.code === "42P06") {
|
|
2343
|
-
(_f = config.logger) == null ? void 0 : _f.log(`Schema ${schema} already exists`);
|
|
2344
|
-
} else {
|
|
2345
|
-
throw err;
|
|
2346
|
-
}
|
|
2347
|
-
}
|
|
2348
|
-
db.schema = schema;
|
|
2349
|
-
}
|
|
2350
2346
|
await createSchemaMigrations(db, config);
|
|
2351
2347
|
await db.close();
|
|
2352
2348
|
};
|