rake-db 2.10.13 → 2.10.14
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.d.ts +18 -6
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -588,12 +588,7 @@ const createTable$1 = async (migration, up, tableName, options, fn) => {
|
|
|
588
588
|
tableMethods
|
|
589
589
|
);
|
|
590
590
|
types[snakeCaseKey] = snakeCase;
|
|
591
|
-
const shape = getColumnTypes(
|
|
592
|
-
types,
|
|
593
|
-
fn,
|
|
594
|
-
(_a = migration.options.baseTable) == null ? void 0 : _a.nowSQL,
|
|
595
|
-
language
|
|
596
|
-
);
|
|
591
|
+
const shape = !fn ? emptyObject : getColumnTypes(types, fn, (_a = migration.options.baseTable) == null ? void 0 : _a.nowSQL, language);
|
|
597
592
|
const tableData = getTableData();
|
|
598
593
|
const ast = makeAst$2(
|
|
599
594
|
up,
|
|
@@ -603,7 +598,7 @@ const createTable$1 = async (migration, up, tableName, options, fn) => {
|
|
|
603
598
|
options,
|
|
604
599
|
migration.options.noPrimaryKey
|
|
605
600
|
);
|
|
606
|
-
validatePrimaryKey(ast);
|
|
601
|
+
fn && validatePrimaryKey(ast);
|
|
607
602
|
const queries = astToQueries$1(ast, snakeCase, language);
|
|
608
603
|
for (const _b of queries) {
|
|
609
604
|
const _c = _b, { then } = _c, query = __objRest$1(_c, ["then"]);
|
|
@@ -684,7 +679,7 @@ const astToQueries$1 = (ast, snakeCase, language) => {
|
|
|
684
679
|
}
|
|
685
680
|
if (ast.action === "drop") {
|
|
686
681
|
queries.push({
|
|
687
|
-
text: `DROP TABLE ${quoteWithSchema(ast)}${ast.dropMode ? ` ${ast.dropMode}` : ""}`
|
|
682
|
+
text: `DROP TABLE${ast.dropIfExists ? " IF EXISTS" : ""} ${quoteWithSchema(ast)}${ast.dropMode ? ` ${ast.dropMode}` : ""}`
|
|
688
683
|
});
|
|
689
684
|
return queries;
|
|
690
685
|
}
|
|
@@ -740,7 +735,7 @@ const astToQueries$1 = (ast, snakeCase, language) => {
|
|
|
740
735
|
);
|
|
741
736
|
queries.push(
|
|
742
737
|
{
|
|
743
|
-
text: `CREATE TABLE ${quoteWithSchema(ast)} (${lines.join(",")}
|
|
738
|
+
text: `CREATE TABLE${ast.createIfNotExists ? " IF NOT EXISTS" : ""} ${quoteWithSchema(ast)} (${lines.join(",")}
|
|
744
739
|
)`,
|
|
745
740
|
values
|
|
746
741
|
},
|
|
@@ -1351,12 +1346,12 @@ const createMigrationInterface = (tx, up, config) => {
|
|
|
1351
1346
|
};
|
|
1352
1347
|
class Migration {
|
|
1353
1348
|
createTable(tableName, cbOrOptions, cb) {
|
|
1354
|
-
const options = typeof cbOrOptions === "function" ? {} : cbOrOptions;
|
|
1349
|
+
const options = !cbOrOptions || typeof cbOrOptions === "function" ? {} : cbOrOptions;
|
|
1355
1350
|
const fn = cb || cbOrOptions;
|
|
1356
1351
|
return createTable$1(this, this.up, tableName, options, fn);
|
|
1357
1352
|
}
|
|
1358
1353
|
dropTable(tableName, cbOrOptions, cb) {
|
|
1359
|
-
const options = typeof cbOrOptions === "function" ? {} : cbOrOptions;
|
|
1354
|
+
const options = !cbOrOptions || typeof cbOrOptions === "function" ? {} : cbOrOptions;
|
|
1360
1355
|
const fn = cb || cbOrOptions;
|
|
1361
1356
|
return createTable$1(this, !this.up, tableName, options, fn);
|
|
1362
1357
|
}
|