drizzle-kit 0.22.7-7d5e8a9 → 0.22.7-7d90fee

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -23283,8 +23283,6 @@ var init_sqlgenerator = __esm({
23283
23283
  const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
23284
23284
  const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
23285
23285
  const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
23286
- const identityWithSchema = schema5 ? `"${schema5}"."${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"` : `"${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"`;
23287
- const oldIdentityWithSchema = schema5 ? `"${schema5}"."${unsquashedOldIdentity == null ? void 0 : unsquashedOldIdentity.name}"` : `"${unsquashedOldIdentity == null ? void 0 : unsquashedOldIdentity.name}"`;
23288
23286
  const statementsToReturn = [];
23289
23287
  if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
23290
23288
  statementsToReturn.push(
@@ -23593,14 +23591,18 @@ var init_sqlgenerator = __esm({
23593
23591
  }
23594
23592
  convert(statement) {
23595
23593
  const { tableName, column: column7, schema: schema5 } = statement;
23596
- const { name, type, notNull, generated } = column7;
23594
+ const { name, type, notNull, generated, primaryKey, identity } = column7;
23595
+ const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
23597
23596
  const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
23598
23597
  const defaultStatement = `${column7.default !== void 0 ? ` DEFAULT ${column7.default}` : ""}`;
23599
23598
  const schemaPrefix = column7.typeSchema && column7.typeSchema !== "public" ? `"${column7.typeSchema}".` : "";
23600
23599
  const fixedType = isPgNativeType(column7.type) ? column7.type : `${schemaPrefix}"${column7.type}"`;
23601
23600
  const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
23601
+ const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
23602
+ const identityWithSchema = schema5 ? `"${schema5}"."${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"` : `"${unsquashedIdentity == null ? void 0 : unsquashedIdentity.name}"`;
23603
+ const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
23602
23604
  const generatedStatement = ` GENERATED ALWAYS AS (${generated == null ? void 0 : generated.as}) STORED`;
23603
- return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
23605
+ return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
23604
23606
  }
23605
23607
  };
23606
23608
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
@@ -23928,8 +23930,8 @@ var init_sqlgenerator = __esm({
23928
23930
  columnPk,
23929
23931
  columnGenerated
23930
23932
  } = statement;
23931
- const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
23932
- const addColumnStatement = new PgAlterTableAddColumnConvertor().convert({
23933
+ const tableNameWithSchema = schema5 ? `\`${schema5}\`.\`${tableName}\`` : `\`${tableName}\``;
23934
+ const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
23933
23935
  schema: schema5,
23934
23936
  tableName,
23935
23937
  column: {
@@ -23945,7 +23947,7 @@ var init_sqlgenerator = __esm({
23945
23947
  type: "alter_table_add_column"
23946
23948
  });
23947
23949
  return [
23948
- `ALTER TABLE ${tableNameWithSchema} drop column "${columnName}";`,
23950
+ `ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
23949
23951
  addColumnStatement
23950
23952
  ];
23951
23953
  }
@@ -29555,6 +29557,13 @@ var init_snapshotsDiffer = __esm({
29555
29557
  return false;
29556
29558
  }
29557
29559
  }
29560
+ if (st.type === "alter_table_alter_column_set_notnull") {
29561
+ if (jsonStatements.find(
29562
+ (it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
29563
+ )) {
29564
+ return false;
29565
+ }
29566
+ }
29558
29567
  return true;
29559
29568
  });
29560
29569
  const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
@@ -122121,7 +122130,7 @@ var init_pgPushUtils = __esm({
122121
122130
  }
122122
122131
  }
122123
122132
  }
122124
- const stmnt = fromJson([statement], "postgresql")[0];
122133
+ const stmnt = fromJson([statement], "postgresql");
122125
122134
  if (typeof stmnt !== "undefined") {
122126
122135
  if (statement.type === "drop_table") {
122127
122136
  statementsToExecute.push(
@@ -122131,7 +122140,7 @@ var init_pgPushUtils = __esm({
122131
122140
  )} CASCADE;`
122132
122141
  );
122133
122142
  } else {
122134
- statementsToExecute.push(stmnt);
122143
+ statementsToExecute.push(...stmnt);
122135
122144
  }
122136
122145
  }
122137
122146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.22.7-7d5e8a9",
3
+ "version": "0.22.7-7d90fee",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
package/payload.js CHANGED
@@ -23102,6 +23102,13 @@ var init_snapshotsDiffer = __esm({
23102
23102
  return false;
23103
23103
  }
23104
23104
  }
23105
+ if (st.type === "alter_table_alter_column_set_notnull") {
23106
+ if (jsonStatements.find(
23107
+ (it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
23108
+ )) {
23109
+ return false;
23110
+ }
23111
+ }
23105
23112
  return true;
23106
23113
  });
23107
23114
  const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
@@ -24231,8 +24238,6 @@ var init_sqlgenerator = __esm({
24231
24238
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24232
24239
  const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
24233
24240
  const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
24234
- const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
24235
- const oldIdentityWithSchema = schema4 ? `"${schema4}"."${unsquashedOldIdentity?.name}"` : `"${unsquashedOldIdentity?.name}"`;
24236
24241
  const statementsToReturn = [];
24237
24242
  if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
24238
24243
  statementsToReturn.push(
@@ -24541,14 +24546,18 @@ var init_sqlgenerator = __esm({
24541
24546
  }
24542
24547
  convert(statement) {
24543
24548
  const { tableName, column: column4, schema: schema4 } = statement;
24544
- const { name: name2, type, notNull, generated } = column4;
24549
+ const { name: name2, type, notNull, generated, primaryKey, identity } = column4;
24550
+ const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
24545
24551
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24546
24552
  const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
24547
24553
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
24548
24554
  const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
24549
24555
  const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
24556
+ const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
24557
+ const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
24558
+ const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
24550
24559
  const generatedStatement = ` GENERATED ALWAYS AS (${generated?.as}) STORED`;
24551
- return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
24560
+ return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
24552
24561
  }
24553
24562
  };
24554
24563
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
@@ -24876,8 +24885,8 @@ var init_sqlgenerator = __esm({
24876
24885
  columnPk,
24877
24886
  columnGenerated
24878
24887
  } = statement;
24879
- const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24880
- const addColumnStatement = new PgAlterTableAddColumnConvertor().convert({
24888
+ const tableNameWithSchema = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
24889
+ const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
24881
24890
  schema: schema4,
24882
24891
  tableName,
24883
24892
  column: {
@@ -24893,7 +24902,7 @@ var init_sqlgenerator = __esm({
24893
24902
  type: "alter_table_add_column"
24894
24903
  });
24895
24904
  return [
24896
- `ALTER TABLE ${tableNameWithSchema} drop column "${columnName}";`,
24905
+ `ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
24897
24906
  addColumnStatement
24898
24907
  ];
24899
24908
  }
@@ -34670,7 +34679,7 @@ var pgSuggestions = async (db, statements) => {
34670
34679
  }
34671
34680
  }
34672
34681
  }
34673
- const stmnt = fromJson([statement], "postgresql")[0];
34682
+ const stmnt = fromJson([statement], "postgresql");
34674
34683
  if (typeof stmnt !== "undefined") {
34675
34684
  if (statement.type === "drop_table") {
34676
34685
  statementsToExecute.push(
@@ -34680,7 +34689,7 @@ var pgSuggestions = async (db, statements) => {
34680
34689
  )} CASCADE;`
34681
34690
  );
34682
34691
  } else {
34683
- statementsToExecute.push(stmnt);
34692
+ statementsToExecute.push(...stmnt);
34684
34693
  }
34685
34694
  }
34686
34695
  }
package/payload.mjs CHANGED
@@ -23107,6 +23107,13 @@ var init_snapshotsDiffer = __esm({
23107
23107
  return false;
23108
23108
  }
23109
23109
  }
23110
+ if (st.type === "alter_table_alter_column_set_notnull") {
23111
+ if (jsonStatements.find(
23112
+ (it) => it.type === "alter_table_alter_column_set_identity" && it.tableName === st.tableName && it.schema === st.schema
23113
+ )) {
23114
+ return false;
23115
+ }
23116
+ }
23110
23117
  return true;
23111
23118
  });
23112
23119
  const sqlStatements = fromJson(filteredJsonStatements, "postgresql");
@@ -24236,8 +24243,6 @@ var init_sqlgenerator = __esm({
24236
24243
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24237
24244
  const unsquashedIdentity = PgSquasher.unsquashIdentity(identity);
24238
24245
  const unsquashedOldIdentity = PgSquasher.unsquashIdentity(oldIdentity);
24239
- const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
24240
- const oldIdentityWithSchema = schema4 ? `"${schema4}"."${unsquashedOldIdentity?.name}"` : `"${unsquashedOldIdentity?.name}"`;
24241
24246
  const statementsToReturn = [];
24242
24247
  if (unsquashedOldIdentity.type !== unsquashedIdentity.type) {
24243
24248
  statementsToReturn.push(
@@ -24546,14 +24551,18 @@ var init_sqlgenerator = __esm({
24546
24551
  }
24547
24552
  convert(statement) {
24548
24553
  const { tableName, column: column4, schema: schema4 } = statement;
24549
- const { name: name2, type, notNull, generated } = column4;
24554
+ const { name: name2, type, notNull, generated, primaryKey, identity } = column4;
24555
+ const primaryKeyStatement = primaryKey ? " PRIMARY KEY" : "";
24550
24556
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24551
24557
  const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
24552
24558
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
24553
24559
  const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
24554
24560
  const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
24561
+ const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
24562
+ const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
24563
+ const identityStatement = unsquashedIdentity ? ` GENERATED ${unsquashedIdentity.type === "always" ? "ALWAYS" : "BY DEFAULT"} AS IDENTITY (sequence name ${identityWithSchema}${unsquashedIdentity.increment ? ` INCREMENT BY ${unsquashedIdentity.increment}` : ""}${unsquashedIdentity.minValue ? ` MINVALUE ${unsquashedIdentity.minValue}` : ""}${unsquashedIdentity.maxValue ? ` MAXVALUE ${unsquashedIdentity.maxValue}` : ""}${unsquashedIdentity.startWith ? ` START WITH ${unsquashedIdentity.startWith}` : ""}${unsquashedIdentity.cache ? ` CACHE ${unsquashedIdentity.cache}` : ""}${unsquashedIdentity.cycle ? ` CYCLE` : ""})` : "";
24555
24564
  const generatedStatement = ` GENERATED ALWAYS AS (${generated?.as}) STORED`;
24556
- return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""};`;
24565
+ return `ALTER TABLE ${tableNameWithSchema} ADD COLUMN "${name2}" ${fixedType}${primaryKeyStatement}${defaultStatement}${notNullStatement}${generated ? generatedStatement : ""}${identityStatement};`;
24557
24566
  }
24558
24567
  };
24559
24568
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
@@ -24881,8 +24890,8 @@ var init_sqlgenerator = __esm({
24881
24890
  columnPk,
24882
24891
  columnGenerated
24883
24892
  } = statement;
24884
- const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
24885
- const addColumnStatement = new PgAlterTableAddColumnConvertor().convert({
24893
+ const tableNameWithSchema = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
24894
+ const addColumnStatement = new MySqlAlterTableAddColumnConvertor().convert({
24886
24895
  schema: schema4,
24887
24896
  tableName,
24888
24897
  column: {
@@ -24898,7 +24907,7 @@ var init_sqlgenerator = __esm({
24898
24907
  type: "alter_table_add_column"
24899
24908
  });
24900
24909
  return [
24901
- `ALTER TABLE ${tableNameWithSchema} drop column "${columnName}";`,
24910
+ `ALTER TABLE ${tableNameWithSchema} drop column \`${columnName}\`;`,
24902
24911
  addColumnStatement
24903
24912
  ];
24904
24913
  }
@@ -34661,7 +34670,7 @@ var pgSuggestions = async (db, statements) => {
34661
34670
  }
34662
34671
  }
34663
34672
  }
34664
- const stmnt = fromJson([statement], "postgresql")[0];
34673
+ const stmnt = fromJson([statement], "postgresql");
34665
34674
  if (typeof stmnt !== "undefined") {
34666
34675
  if (statement.type === "drop_table") {
34667
34676
  statementsToExecute.push(
@@ -34671,7 +34680,7 @@ var pgSuggestions = async (db, statements) => {
34671
34680
  )} CASCADE;`
34672
34681
  );
34673
34682
  } else {
34674
- statementsToExecute.push(stmnt);
34683
+ statementsToExecute.push(...stmnt);
34675
34684
  }
34676
34685
  }
34677
34686
  }