drizzle-kit 0.22.0-3b0ba5f → 0.22.0-407e2e6

Sign up to get free protection for your applications and to get access to all the features.
package/payload.mjs CHANGED
@@ -8530,7 +8530,7 @@ var init_utils4 = __esm({
8530
8530
 
8531
8531
  // src/cli/views.ts
8532
8532
  import { Prompt, render, SelectState, TaskView } from "hanji";
8533
- var error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect;
8533
+ var error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, ProgressView;
8534
8534
  var init_views = __esm({
8535
8535
  "src/cli/views.ts"() {
8536
8536
  "use strict";
@@ -8682,6 +8682,42 @@ Is ${source_default.bold.blue(
8682
8682
  return this.state.items[this.state.selectedIdx];
8683
8683
  }
8684
8684
  };
8685
+ Spinner = class {
8686
+ constructor(frames) {
8687
+ this.frames = frames;
8688
+ this.offset = 0;
8689
+ this.tick = () => {
8690
+ this.iterator();
8691
+ };
8692
+ this.value = () => {
8693
+ return this.frames[this.offset];
8694
+ };
8695
+ this.iterator = () => {
8696
+ this.offset += 1;
8697
+ this.offset %= frames.length - 1;
8698
+ };
8699
+ }
8700
+ };
8701
+ ProgressView = class extends TaskView {
8702
+ constructor(progressText, successText) {
8703
+ super();
8704
+ this.progressText = progressText;
8705
+ this.successText = successText;
8706
+ this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
8707
+ this.timeout = setInterval(() => {
8708
+ this.spinner.tick();
8709
+ this.requestLayout();
8710
+ }, 128);
8711
+ this.on("detach", () => clearInterval(this.timeout));
8712
+ }
8713
+ render(status) {
8714
+ if (status === "pending") {
8715
+ const spin = this.spinner.value();
8716
+ return `[${spin}] ${this.progressText}`;
8717
+ }
8718
+ return `[${source_default.green("\u2713")}] ${this.successText}`;
8719
+ }
8720
+ };
8685
8721
  }
8686
8722
  });
8687
8723
 
@@ -8802,6 +8838,12 @@ var init_sqlite = __esm({
8802
8838
  url: string6(),
8803
8839
  authToken: string6()
8804
8840
  }),
8841
+ object6({
8842
+ driver: literal5("d1-http"),
8843
+ accountId: string6(),
8844
+ databaseId: string6(),
8845
+ token: string6()
8846
+ }),
8805
8847
  object6({
8806
8848
  url: string6()
8807
8849
  })
@@ -8851,6 +8893,7 @@ var init_common2 = __esm({
8851
8893
  literal6("turso"),
8852
8894
  literal6("libsql"),
8853
8895
  literal6("d1"),
8896
+ literal6("d1-http"),
8854
8897
  literal6("expo")
8855
8898
  ]);
8856
8899
  postgresDriver = literal6("aws-data-api");
@@ -9837,6 +9880,7 @@ ${withStyle.errorWarning(
9837
9880
  "time without time zone": "::time without time zone",
9838
9881
  // "timestamp with time zone": "::timestamp with time zone",
9839
9882
  "timestamp without time zone": "::timestamp without time zone",
9883
+ "timestamp(": "::timestamp without time zone",
9840
9884
  // date: "::date",
9841
9885
  // interval: "::interval",
9842
9886
  // character: "::bpchar",
@@ -9849,15 +9893,15 @@ ${withStyle.errorWarning(
9849
9893
  "character(": "::bpchar"
9850
9894
  };
9851
9895
  defaultForColumn = (column4) => {
9896
+ if (column4.column_default === null) {
9897
+ return void 0;
9898
+ }
9852
9899
  if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
9853
9900
  return void 0;
9854
9901
  }
9855
9902
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
9856
9903
  (it) => column4.data_type.startsWith(it)
9857
9904
  );
9858
- if (column4.column_default === null) {
9859
- return void 0;
9860
- }
9861
9905
  const columnDefaultAsString = column4.column_default.toString();
9862
9906
  if (columnDefaultAsString.endsWith(
9863
9907
  hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
@@ -11339,8 +11383,7 @@ var init_jsonDiffer = __esm({
11339
11383
  };
11340
11384
  findAlternationsInTable = (table4) => {
11341
11385
  const columns = table4.columns ?? {};
11342
- const isSemanticallyEqual = (it) => columns[it]["type"]?.__new.replace(" (", "(") === columns[it]["type"]?.__old.replace(" (", "(");
11343
- const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added") || isSemanticallyEqual(it))).map((it) => {
11386
+ const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added"))).map((it) => {
11344
11387
  return { name: it, ...columns[it] };
11345
11388
  });
11346
11389
  const deletedIndexes = Object.fromEntries(
@@ -11442,6 +11485,9 @@ var init_jsonDiffer = __esm({
11442
11485
  return it;
11443
11486
  }).map((it) => {
11444
11487
  if ("type" in it) {
11488
+ if (it.type.__old.replace(" (", "(") === it.type.__new.replace(" (", "(")) {
11489
+ return void 0;
11490
+ }
11445
11491
  return {
11446
11492
  ...it,
11447
11493
  type: { type: "changed", old: it.type.__old, new: it.type.__new }
@@ -11604,7 +11650,7 @@ var init_jsonDiffer = __esm({
11604
11650
  };
11605
11651
  }
11606
11652
  return it;
11607
- });
11653
+ }).filter(Boolean);
11608
11654
  return result[0];
11609
11655
  };
11610
11656
  }
@@ -12426,20 +12472,21 @@ var init_jsonStatements = __esm({
12426
12472
  });
12427
12473
  };
12428
12474
  prepareAlterReferencesJson = (tableName, schema4, foreignKeys) => {
12429
- const keys = Object.keys(foreignKeys);
12430
12475
  const stmts = [];
12431
- if (keys.length > 0) {
12432
- stmts.push(
12433
- ...prepareDropReferencesJson(tableName, schema4, {
12434
- [keys[0]]: foreignKeys[keys[0]].__old
12435
- })
12436
- );
12437
- stmts.push(
12438
- ...prepareCreateReferencesJson(tableName, schema4, {
12439
- [keys[0]]: foreignKeys[keys[0]].__new
12440
- })
12441
- );
12442
- }
12476
+ Object.values(foreignKeys).map((val) => {
12477
+ stmts.push({
12478
+ type: "delete_reference",
12479
+ tableName,
12480
+ schema: schema4,
12481
+ data: val.__old
12482
+ });
12483
+ stmts.push({
12484
+ type: "create_reference",
12485
+ tableName,
12486
+ schema: schema4,
12487
+ data: val.__new
12488
+ });
12489
+ });
12443
12490
  return stmts;
12444
12491
  };
12445
12492
  prepareDropIndexesJson = (tableName, schema4, indexes) => {
@@ -12488,7 +12535,7 @@ var init_jsonStatements = __esm({
12488
12535
  tableName,
12489
12536
  data: it,
12490
12537
  schema: schema4,
12491
- constraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
12538
+ constraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
12492
12539
  };
12493
12540
  });
12494
12541
  };
@@ -12511,8 +12558,8 @@ var init_jsonStatements = __esm({
12511
12558
  old: it.__old,
12512
12559
  new: it.__new,
12513
12560
  schema: schema4,
12514
- oldConstraintName: json1.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
12515
- newConstraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
12561
+ oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
12562
+ newConstraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
12516
12563
  };
12517
12564
  });
12518
12565
  };
@@ -12793,7 +12840,7 @@ var init_snapshotsDiffer = __esm({
12793
12840
  for (let ren of renamedTables) {
12794
12841
  if (table4.name === ren.from.name && table4.schema === ren.from.schema) {
12795
12842
  return {
12796
- key: `${ren.to.schema}.${ren.to.name}`,
12843
+ key: `${ren.to.schema || "public"}.${ren.to.name}`,
12797
12844
  name: ren.to.name,
12798
12845
  schema: ren.to.schema
12799
12846
  };
@@ -14165,8 +14212,7 @@ var init_sqlgenerator = __esm({
14165
14212
  convert(st) {
14166
14213
  const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
14167
14214
  let statement = "";
14168
- const tName = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
14169
- statement += `CREATE TABLE ${tName} (
14215
+ statement += `CREATE TABLE \`${tableName}\` (
14170
14216
  `;
14171
14217
  for (let i = 0; i < columns.length; i++) {
14172
14218
  const column4 = columns[i];
@@ -14286,8 +14332,7 @@ var init_sqlgenerator = __esm({
14286
14332
  }
14287
14333
  convert(statement) {
14288
14334
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
14289
- const tableNameWithSchema = statement.schema ? `\`${statement.schema}\`.\`${statement.tableName}\`` : `\`${statement.tableName}\``;
14290
- return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
14335
+ return `ALTER TABLE \`${statement.tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
14291
14336
  }
14292
14337
  };
14293
14338
  MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
@@ -14296,8 +14341,7 @@ var init_sqlgenerator = __esm({
14296
14341
  }
14297
14342
  convert(statement) {
14298
14343
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
14299
- const tableNameWithSchema = statement.schema ? `\`${statement.schema}\`.\`${statement.tableName}\`` : `\`${statement.tableName}\``;
14300
- return `ALTER TABLE ${tableNameWithSchema} DROP INDEX \`${unsquashed.name}\`;`;
14344
+ return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
14301
14345
  }
14302
14346
  };
14303
14347
  SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
@@ -14412,10 +14456,8 @@ var init_sqlgenerator = __esm({
14412
14456
  return statement.type === "rename_table" && dialect7 === "mysql";
14413
14457
  }
14414
14458
  convert(statement) {
14415
- const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
14416
- const from = fromSchema ? `\`${fromSchema}\`.\`${tableNameFrom}\`` : `\`${tableNameFrom}\``;
14417
- const to = fromSchema ? `\`${fromSchema}\`.\`${tableNameTo}\`` : `\`${tableNameTo}\``;
14418
- return `RENAME TABLE ${from} TO ${to};`;
14459
+ const { tableNameFrom, tableNameTo } = statement;
14460
+ return `RENAME TABLE \`${tableNameFrom}\` TO \`${tableNameTo}\`;`;
14419
14461
  }
14420
14462
  };
14421
14463
  PgAlterTableRenameColumnConvertor = class extends Convertor {
@@ -15223,9 +15265,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
15223
15265
  return statement.type === "drop_index" && dialect7 === "mysql";
15224
15266
  }
15225
15267
  convert(statement) {
15226
- const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
15227
15268
  const { name: name2 } = MySqlSquasher.unsquashIdx(statement.data);
15228
- return `DROP INDEX \`${name2}\` ON ${tableName};`;
15269
+ return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
15229
15270
  }
15230
15271
  };
15231
15272
  convertors = [];
@@ -18880,12 +18921,24 @@ The unique constraint ${source_default.underline.blue(
18880
18921
  `SELECT
18881
18922
  m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
18882
18923
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
18883
- WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
18924
+ WHERE m.type = 'table'
18925
+ and m.tbl_name != 'sqlite_sequence'
18926
+ and m.tbl_name != 'sqlite_stat1'
18927
+ and m.tbl_name != '_litestream_seq'
18928
+ and m.tbl_name != '_litestream_lock'
18929
+ and m.tbl_name != 'libsql_wasm_func_table'
18930
+ and m.tbl_name != '__drizzle_migrations'
18931
+ and m.tbl_name != '_cf_KV';
18884
18932
  `
18885
18933
  );
18886
18934
  const tablesWithSeq = [];
18887
18935
  const seq = await db.query(
18888
- `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock' and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
18936
+ `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
18937
+ and name != 'sqlite_stat1'
18938
+ and name != '_litestream_seq'
18939
+ and name != '_litestream_lock'
18940
+ and tbl_name != '_cf_KV'
18941
+ and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
18889
18942
  );
18890
18943
  for (const s of seq) {
18891
18944
  tablesWithSeq.push(s.name);
@@ -18970,7 +19023,8 @@ The unique constraint ${source_default.underline.blue(
18970
19023
  try {
18971
19024
  const fks = await db.query(
18972
19025
  `SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
18973
- FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
19026
+ FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
19027
+ where m.tbl_name != '_cf_KV';`
18974
19028
  );
18975
19029
  const fkByTableName = {};
18976
19030
  for (const fkRow of fks) {
@@ -19029,7 +19083,9 @@ FROM sqlite_master AS m,
19029
19083
  pragma_index_list(m.name) AS il,
19030
19084
  pragma_index_info(il.name) AS ii
19031
19085
  WHERE
19032
- m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
19086
+ m.type = 'table'
19087
+ and il.name NOT LIKE 'sqlite_autoindex_%'
19088
+ and m.tbl_name != '_cf_KV';`
19033
19089
  );
19034
19090
  for (const idxRow of idxs) {
19035
19091
  const tableName = idxRow.tableName;
@@ -23938,6 +23994,7 @@ var mysqlIntrospect_exports = {};
23938
23994
  __export(mysqlIntrospect_exports, {
23939
23995
  mysqlPushIntrospect: () => mysqlPushIntrospect
23940
23996
  });
23997
+ import { renderWithTask as renderWithTask3 } from "hanji";
23941
23998
  var mysqlPushIntrospect;
23942
23999
  var init_mysqlIntrospect = __esm({
23943
24000
  "src/cli/commands/mysqlIntrospect.ts"() {
@@ -23945,6 +24002,7 @@ var init_mysqlIntrospect = __esm({
23945
24002
  init_mysqlSerializer();
23946
24003
  init_global();
23947
24004
  init_mjs();
24005
+ init_views();
23948
24006
  mysqlPushIntrospect = async (db, databaseName, filters) => {
23949
24007
  const matchers = filters.map((it) => {
23950
24008
  return new Minimatch(it);
@@ -23959,7 +24017,14 @@ var init_mysqlIntrospect = __esm({
23959
24017
  }
23960
24018
  return false;
23961
24019
  };
23962
- const res = await fromDatabase3(db, databaseName, filter2);
24020
+ const progress = new ProgressView(
24021
+ "Pulling schema from database...",
24022
+ "Pulling schema from database..."
24023
+ );
24024
+ const res = await renderWithTask3(
24025
+ progress,
24026
+ fromDatabase3(db, databaseName, filter2)
24027
+ );
23963
24028
  const schema4 = { id: originUUID, prevId: "", ...res };
23964
24029
  const { internal, ...schemaWithoutInternals } = schema4;
23965
24030
  return { schema: schemaWithoutInternals };
@@ -23980,6 +24045,8 @@ import { randomUUID } from "crypto";
23980
24045
  init_pgSerializer();
23981
24046
  init_global();
23982
24047
  init_mjs();
24048
+ init_views();
24049
+ import { renderWithTask } from "hanji";
23983
24050
  var pgPushIntrospect = async (db, filters, schemaFilters) => {
23984
24051
  const matchers = filters.map((it) => {
23985
24052
  return new Minimatch(it);
@@ -23994,7 +24061,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
23994
24061
  }
23995
24062
  return false;
23996
24063
  };
23997
- const res = await fromDatabase(db, filter2, schemaFilters);
24064
+ const progress = new ProgressView(
24065
+ "Pulling schema from database...",
24066
+ "Pulling schema from database..."
24067
+ );
24068
+ const res = await renderWithTask(
24069
+ progress,
24070
+ fromDatabase(db, filter2, schemaFilters)
24071
+ );
23998
24072
  const schema4 = { id: originUUID, prevId: "", ...res };
23999
24073
  const { internal, ...schemaWithoutInternals } = schema4;
24000
24074
  return { schema: schemaWithoutInternals };
@@ -24412,7 +24486,7 @@ Array.prototype.random = function() {
24412
24486
 
24413
24487
  // src/cli/commands/sqliteIntrospect.ts
24414
24488
  init_mjs();
24415
- import { renderWithTask } from "hanji";
24489
+ import { renderWithTask as renderWithTask2 } from "hanji";
24416
24490
  var sqlitePushIntrospect = async (db, filters) => {
24417
24491
  const matchers = filters.map((it) => {
24418
24492
  return new Minimatch(it);
@@ -24427,7 +24501,14 @@ var sqlitePushIntrospect = async (db, filters) => {
24427
24501
  }
24428
24502
  return false;
24429
24503
  };
24430
- const res = await fromDatabase2(db, filter2);
24504
+ const progress = new ProgressView(
24505
+ "Pulling schema from database...",
24506
+ "Pulling schema from database..."
24507
+ );
24508
+ const res = await renderWithTask2(
24509
+ progress,
24510
+ fromDatabase2(db, filter2)
24511
+ );
24431
24512
  const schema4 = { id: originUUID, prevId: "", ...res };
24432
24513
  return { schema: schema4 };
24433
24514
  };
@@ -24544,7 +24625,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
24544
24625
  ).find(
24545
24626
  (c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName)
24546
24627
  );
24547
- const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
24628
+ const columnIsPk = json2.tables[newTableName].columns[statement.columnName].primaryKey;
24548
24629
  const columnIsPartOfFk = Object.values(
24549
24630
  json1.tables[newTableName].foreignKeys
24550
24631
  ).find(
@@ -24628,48 +24709,52 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
24628
24709
  }
24629
24710
  }
24630
24711
  } else if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk") {
24631
- const newTableName = getOldTableName(statement.tableName, meta);
24632
- if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
24633
- const res = await connection.query(
24634
- `select count(*) as count from \`${newTableName}\``
24635
- );
24636
- const count2 = Number(res[0].count);
24637
- if (count2 > 0) {
24638
- infoToPrint.push(
24639
- `\xB7 You're about to add not-null constraint to ${source_default.underline(
24640
- statement.columnName
24641
- )} column without default value, which contains ${count2} items`
24712
+ if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
24713
+ const newTableName = getOldTableName(statement.tableName, meta);
24714
+ if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
24715
+ const res = await connection.query(
24716
+ `select count(*) as count from \`${newTableName}\``
24642
24717
  );
24643
- tablesToTruncate.push(newTableName);
24644
- shouldAskForApprove = true;
24645
- }
24646
- tablesContext[newTableName] = _moveDataStatements(
24647
- statement.tableName,
24648
- json2,
24649
- true
24650
- );
24651
- } else {
24652
- if (typeof tablesContext[newTableName] === "undefined") {
24718
+ const count2 = Number(res[0].count);
24719
+ if (count2 > 0) {
24720
+ infoToPrint.push(
24721
+ `\xB7 You're about to add not-null constraint to ${source_default.underline(
24722
+ statement.columnName
24723
+ )} column without default value, which contains ${count2} items`
24724
+ );
24725
+ tablesToTruncate.push(newTableName);
24726
+ shouldAskForApprove = true;
24727
+ }
24653
24728
  tablesContext[newTableName] = _moveDataStatements(
24654
24729
  statement.tableName,
24655
- json2
24730
+ json2,
24731
+ true
24656
24732
  );
24733
+ } else {
24734
+ if (typeof tablesContext[newTableName] === "undefined") {
24735
+ tablesContext[newTableName] = _moveDataStatements(
24736
+ statement.tableName,
24737
+ json2
24738
+ );
24739
+ }
24657
24740
  }
24658
- }
24659
- const tablesReferncingCurrent = [];
24660
- for (const table4 of Object.values(json1.tables)) {
24661
- const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter((t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName).map((t) => {
24662
- return getNewTableName(
24663
- SQLiteSquasher.unsquashFK(t).tableFrom,
24664
- meta
24665
- );
24666
- });
24667
- tablesReferncingCurrent.push(...tablesRefs);
24668
- }
24669
- const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
24670
- for (const table4 of uniqueTableRefs) {
24671
- if (typeof tablesContext[table4] === "undefined") {
24672
- tablesContext[table4] = [..._moveDataStatements(table4, json2)];
24741
+ const tablesReferncingCurrent = [];
24742
+ for (const table4 of Object.values(json1.tables)) {
24743
+ const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
24744
+ (t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
24745
+ ).map((t) => {
24746
+ return getNewTableName(
24747
+ SQLiteSquasher.unsquashFK(t).tableFrom,
24748
+ meta
24749
+ );
24750
+ });
24751
+ tablesReferncingCurrent.push(...tablesRefs);
24752
+ }
24753
+ const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
24754
+ for (const table4 of uniqueTableRefs) {
24755
+ if (typeof tablesContext[table4] === "undefined") {
24756
+ tablesContext[table4] = [..._moveDataStatements(table4, json2)];
24757
+ }
24673
24758
  }
24674
24759
  }
24675
24760
  } else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {