drizzle-kit 0.29.0-3f3eb73 → 0.29.0-994b9b8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. package/api.js +10 -19
  2. package/api.mjs +10 -19
  3. package/bin.cjs +11 -20
  4. package/package.json +1 -1
package/api.js CHANGED
@@ -12331,7 +12331,7 @@ var init_sqlgenerator = __esm({
12331
12331
  const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = st;
12332
12332
  let statement = "";
12333
12333
  const name2 = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
12334
- statement += `CREATE TABLE IF NOT EXISTS ${name2} (
12334
+ statement += `CREATE TABLE ${name2} (
12335
12335
  `;
12336
12336
  for (let i = 0; i < columns.length; i++) {
12337
12337
  const column5 = columns[i];
@@ -13169,7 +13169,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13169
13169
  convert(statement) {
13170
13170
  const { tableName, columnName, schema: schema5 } = statement;
13171
13171
  const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
13172
- return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN IF EXISTS "${columnName}";`;
13172
+ return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN "${columnName}";`;
13173
13173
  }
13174
13174
  };
13175
13175
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
@@ -13590,7 +13590,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13590
13590
  for (const table5 of Object.values(json22.tables)) {
13591
13591
  for (const index5 of Object.values(table5.indexes)) {
13592
13592
  const unsquashed = SQLiteSquasher.unsquashIdx(index5);
13593
- sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
13593
+ sqlStatements.push(`DROP INDEX "${unsquashed.name}";`);
13594
13594
  indexes.push({ ...unsquashed, tableName: table5.name });
13595
13595
  }
13596
13596
  }
@@ -14104,13 +14104,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14104
14104
  const toColumnsString = columnsTo.map((it) => `"${it}"`).join(",");
14105
14105
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
14106
14106
  const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
14107
- const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name2}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
14108
- let sql2 = "DO $$ BEGIN\n";
14109
- sql2 += " " + alterStatement + ";\n";
14110
- sql2 += "EXCEPTION\n";
14111
- sql2 += " WHEN duplicate_object THEN null;\n";
14112
- sql2 += "END $$;\n";
14113
- return sql2;
14107
+ const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name2}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
14108
+ return alterStatement;
14114
14109
  }
14115
14110
  };
14116
14111
  LibSQLCreateForeignKeyConvertor = class extends Convertor {
@@ -14167,12 +14162,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14167
14162
  const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
14168
14163
  const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
14169
14164
  const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
14170
- const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
14171
- sql2 += "DO $$ BEGIN\n";
14172
- sql2 += " " + alterStatement + ";\n";
14173
- sql2 += "EXCEPTION\n";
14174
- sql2 += " WHEN duplicate_object THEN null;\n";
14175
- sql2 += "END $$;\n";
14165
+ const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
14166
+ sql2 += alterStatement;
14176
14167
  return sql2;
14177
14168
  }
14178
14169
  };
@@ -14228,7 +14219,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14228
14219
  reversedString = reversedString.slice(0, -1);
14229
14220
  return reversedString;
14230
14221
  }
14231
- return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} IF NOT EXISTS "${name2}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
14222
+ return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} "${name2}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
14232
14223
  }
14233
14224
  };
14234
14225
  CreateMySqlIndexConvertor = class extends Convertor {
@@ -14283,7 +14274,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14283
14274
  }
14284
14275
  convert(statement) {
14285
14276
  const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
14286
- return `DROP INDEX IF EXISTS "${name2}";`;
14277
+ return `DROP INDEX "${name2}";`;
14287
14278
  }
14288
14279
  };
14289
14280
  PgCreateSchemaConvertor = class extends Convertor {
@@ -14354,7 +14345,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14354
14345
  }
14355
14346
  convert(statement) {
14356
14347
  const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
14357
- return `DROP INDEX IF EXISTS \`${name2}\`;`;
14348
+ return `DROP INDEX \`${name2}\`;`;
14358
14349
  }
14359
14350
  };
14360
14351
  MySqlDropIndexConvertor = class extends Convertor {
package/api.mjs CHANGED
@@ -12336,7 +12336,7 @@ var init_sqlgenerator = __esm({
12336
12336
  const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = st;
12337
12337
  let statement = "";
12338
12338
  const name2 = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
12339
- statement += `CREATE TABLE IF NOT EXISTS ${name2} (
12339
+ statement += `CREATE TABLE ${name2} (
12340
12340
  `;
12341
12341
  for (let i = 0; i < columns.length; i++) {
12342
12342
  const column5 = columns[i];
@@ -13174,7 +13174,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13174
13174
  convert(statement) {
13175
13175
  const { tableName, columnName, schema: schema5 } = statement;
13176
13176
  const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
13177
- return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN IF EXISTS "${columnName}";`;
13177
+ return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN "${columnName}";`;
13178
13178
  }
13179
13179
  };
13180
13180
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
@@ -13595,7 +13595,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13595
13595
  for (const table5 of Object.values(json22.tables)) {
13596
13596
  for (const index5 of Object.values(table5.indexes)) {
13597
13597
  const unsquashed = SQLiteSquasher.unsquashIdx(index5);
13598
- sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
13598
+ sqlStatements.push(`DROP INDEX "${unsquashed.name}";`);
13599
13599
  indexes.push({ ...unsquashed, tableName: table5.name });
13600
13600
  }
13601
13601
  }
@@ -14109,13 +14109,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14109
14109
  const toColumnsString = columnsTo.map((it) => `"${it}"`).join(",");
14110
14110
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
14111
14111
  const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
14112
- const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name2}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
14113
- let sql2 = "DO $$ BEGIN\n";
14114
- sql2 += " " + alterStatement + ";\n";
14115
- sql2 += "EXCEPTION\n";
14116
- sql2 += " WHEN duplicate_object THEN null;\n";
14117
- sql2 += "END $$;\n";
14118
- return sql2;
14112
+ const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name2}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
14113
+ return alterStatement;
14119
14114
  }
14120
14115
  };
14121
14116
  LibSQLCreateForeignKeyConvertor = class extends Convertor {
@@ -14172,12 +14167,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14172
14167
  const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
14173
14168
  const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
14174
14169
  const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
14175
- const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
14176
- sql2 += "DO $$ BEGIN\n";
14177
- sql2 += " " + alterStatement + ";\n";
14178
- sql2 += "EXCEPTION\n";
14179
- sql2 += " WHEN duplicate_object THEN null;\n";
14180
- sql2 += "END $$;\n";
14170
+ const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
14171
+ sql2 += alterStatement;
14181
14172
  return sql2;
14182
14173
  }
14183
14174
  };
@@ -14233,7 +14224,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14233
14224
  reversedString = reversedString.slice(0, -1);
14234
14225
  return reversedString;
14235
14226
  }
14236
- return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} IF NOT EXISTS "${name2}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
14227
+ return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} "${name2}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
14237
14228
  }
14238
14229
  };
14239
14230
  CreateMySqlIndexConvertor = class extends Convertor {
@@ -14288,7 +14279,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14288
14279
  }
14289
14280
  convert(statement) {
14290
14281
  const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
14291
- return `DROP INDEX IF EXISTS "${name2}";`;
14282
+ return `DROP INDEX "${name2}";`;
14292
14283
  }
14293
14284
  };
14294
14285
  PgCreateSchemaConvertor = class extends Convertor {
@@ -14359,7 +14350,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
14359
14350
  }
14360
14351
  convert(statement) {
14361
14352
  const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
14362
- return `DROP INDEX IF EXISTS \`${name2}\`;`;
14353
+ return `DROP INDEX \`${name2}\`;`;
14363
14354
  }
14364
14355
  };
14365
14356
  MySqlDropIndexConvertor = class extends Convertor {
package/bin.cjs CHANGED
@@ -42787,7 +42787,7 @@ var init_sqlgenerator = __esm({
42787
42787
  const { tableName, schema: schema6, columns, compositePKs, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = st;
42788
42788
  let statement = "";
42789
42789
  const name = schema6 ? `"${schema6}"."${tableName}"` : `"${tableName}"`;
42790
- statement += `CREATE TABLE IF NOT EXISTS ${name} (
42790
+ statement += `CREATE TABLE ${name} (
42791
42791
  `;
42792
42792
  for (let i2 = 0; i2 < columns.length; i2++) {
42793
42793
  const column9 = columns[i2];
@@ -43633,7 +43633,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
43633
43633
  convert(statement) {
43634
43634
  const { tableName, columnName, schema: schema6 } = statement;
43635
43635
  const tableNameWithSchema = schema6 ? `"${schema6}"."${tableName}"` : `"${tableName}"`;
43636
- return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN IF EXISTS "${columnName}";`;
43636
+ return `ALTER TABLE ${tableNameWithSchema} DROP COLUMN "${columnName}";`;
43637
43637
  }
43638
43638
  };
43639
43639
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
@@ -44054,7 +44054,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
44054
44054
  for (const table5 of Object.values(json2.tables)) {
44055
44055
  for (const index5 of Object.values(table5.indexes)) {
44056
44056
  const unsquashed = SQLiteSquasher.unsquashIdx(index5);
44057
- sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
44057
+ sqlStatements.push(`DROP INDEX "${unsquashed.name}";`);
44058
44058
  indexes.push({ ...unsquashed, tableName: table5.name });
44059
44059
  }
44060
44060
  }
@@ -44570,13 +44570,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
44570
44570
  const toColumnsString = columnsTo.map((it) => `"${it}"`).join(",");
44571
44571
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
44572
44572
  const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
44573
- const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
44574
- let sql = "DO $$ BEGIN\n";
44575
- sql += " " + alterStatement + ";\n";
44576
- sql += "EXCEPTION\n";
44577
- sql += " WHEN duplicate_object THEN null;\n";
44578
- sql += "END $$;\n";
44579
- return sql;
44573
+ const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
44574
+ return alterStatement;
44580
44575
  }
44581
44576
  };
44582
44577
  LibSQLCreateForeignKeyConvertor = class extends Convertor {
@@ -44633,12 +44628,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
44633
44628
  const toColumnsString = newFk.columnsTo.map((it) => `"${it}"`).join(",");
44634
44629
  const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
44635
44630
  const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
44636
- const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
44637
- sql += "DO $$ BEGIN\n";
44638
- sql += " " + alterStatement + ";\n";
44639
- sql += "EXCEPTION\n";
44640
- sql += " WHEN duplicate_object THEN null;\n";
44641
- sql += "END $$;\n";
44631
+ const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement};`;
44632
+ sql += alterStatement;
44642
44633
  return sql;
44643
44634
  }
44644
44635
  };
@@ -44694,7 +44685,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
44694
44685
  reversedString = reversedString.slice(0, -1);
44695
44686
  return reversedString;
44696
44687
  }
44697
- return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} IF NOT EXISTS "${name}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
44688
+ return `CREATE ${indexPart}${concurrently ? " CONCURRENTLY" : ""} "${name}" ON ${tableNameWithSchema} USING ${method} (${value})${Object.keys(withMap).length !== 0 ? ` WITH (${reverseLogic(withMap)})` : ""}${where ? ` WHERE ${where}` : ""};`;
44698
44689
  }
44699
44690
  };
44700
44691
  CreateMySqlIndexConvertor = class extends Convertor {
@@ -44752,7 +44743,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
44752
44743
  }
44753
44744
  convert(statement) {
44754
44745
  const { name } = PgSquasher.unsquashIdx(statement.data);
44755
- return `DROP INDEX IF EXISTS "${name}";`;
44746
+ return `DROP INDEX "${name}";`;
44756
44747
  }
44757
44748
  };
44758
44749
  PgCreateSchemaConvertor = class extends Convertor {
@@ -44823,7 +44814,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newC
44823
44814
  }
44824
44815
  convert(statement) {
44825
44816
  const { name } = PgSquasher.unsquashIdx(statement.data);
44826
- return `DROP INDEX IF EXISTS \`${name}\`;`;
44817
+ return `DROP INDEX \`${name}\`;`;
44827
44818
  }
44828
44819
  };
44829
44820
  MySqlDropIndexConvertor = class extends Convertor {
@@ -92435,7 +92426,7 @@ init_utils5();
92435
92426
  var version2 = async () => {
92436
92427
  const { npmVersion } = await ormCoreVersions();
92437
92428
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
92438
- const envVersion = "0.29.0-3f3eb73";
92429
+ const envVersion = "0.29.0-994b9b8";
92439
92430
  const kitVersion = envVersion ? `v${envVersion}` : "--";
92440
92431
  const versions = `drizzle-kit: ${kitVersion}
92441
92432
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.29.0-3f3eb73",
3
+ "version": "0.29.0-994b9b8",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",