drizzle-kit 0.22.0-3b0ba5f → 0.22.0-ed86dfa

Sign up to get free protection for your applications and to get access to all the features.
package/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import { SslOptions } from 'mysql2';
2
2
  import * as zod from 'zod';
3
3
  import { TypeOf } from 'zod';
4
4
 
5
- declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
5
+ declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"d1-http">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
6
6
  type Driver = TypeOf<typeof driver>;
7
7
 
8
8
  declare const dialect: zod.ZodEnum<["postgresql", "mysql", "sqlite"]>;
@@ -169,6 +169,14 @@ type Config = {
169
169
  wranglerConfigPath: string;
170
170
  dbName: string;
171
171
  };
172
+ } | {
173
+ dialect: Verify<Dialect, "sqlite">;
174
+ driver: Verify<Driver, "d1-http">;
175
+ dbCredentials: {
176
+ accountId: string;
177
+ databaseId: string;
178
+ token: string;
179
+ };
172
180
  } | {
173
181
  dialect: Verify<Dialect, "sqlite">;
174
182
  driver: Verify<Driver, "expo">;
package/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { SslOptions } from 'mysql2';
2
2
  import * as zod from 'zod';
3
3
  import { TypeOf } from 'zod';
4
4
 
5
- declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
5
+ declare const driver: zod.ZodUnion<[zod.ZodUnion<[zod.ZodLiteral<"better-sqlite">, zod.ZodLiteral<"turso">, zod.ZodLiteral<"libsql">, zod.ZodLiteral<"d1">, zod.ZodLiteral<"d1-http">, zod.ZodLiteral<"expo">]>, zod.ZodLiteral<"aws-data-api">, zod.ZodLiteral<"mysql2">]>;
6
6
  type Driver = TypeOf<typeof driver>;
7
7
 
8
8
  declare const dialect: zod.ZodEnum<["postgresql", "mysql", "sqlite"]>;
@@ -169,6 +169,14 @@ type Config = {
169
169
  wranglerConfigPath: string;
170
170
  dbName: string;
171
171
  };
172
+ } | {
173
+ dialect: Verify<Dialect, "sqlite">;
174
+ driver: Verify<Driver, "d1-http">;
175
+ dbCredentials: {
176
+ accountId: string;
177
+ databaseId: string;
178
+ token: string;
179
+ };
172
180
  } | {
173
181
  dialect: Verify<Dialect, "sqlite">;
174
182
  driver: Verify<Driver, "expo">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.22.0-3b0ba5f",
3
+ "version": "0.22.0-ed86dfa",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
@@ -70,6 +70,7 @@
70
70
  "hono": "^4.1.5",
71
71
  "minimatch": "^7.4.3",
72
72
  "mysql2": "2.3.3",
73
+ "node-fetch": "^3.3.2",
73
74
  "pg": "^8.11.3",
74
75
  "pluralize": "^8.0.0",
75
76
  "postgres": "^3.4.4",
package/payload.js CHANGED
@@ -8495,7 +8495,7 @@ var init_utils4 = __esm({
8495
8495
  });
8496
8496
 
8497
8497
  // src/cli/views.ts
8498
- var import_hanji, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect;
8498
+ var import_hanji, error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, ProgressView;
8499
8499
  var init_views = __esm({
8500
8500
  "src/cli/views.ts"() {
8501
8501
  "use strict";
@@ -8648,6 +8648,42 @@ Is ${source_default.bold.blue(
8648
8648
  return this.state.items[this.state.selectedIdx];
8649
8649
  }
8650
8650
  };
8651
+ Spinner = class {
8652
+ constructor(frames) {
8653
+ this.frames = frames;
8654
+ this.offset = 0;
8655
+ this.tick = () => {
8656
+ this.iterator();
8657
+ };
8658
+ this.value = () => {
8659
+ return this.frames[this.offset];
8660
+ };
8661
+ this.iterator = () => {
8662
+ this.offset += 1;
8663
+ this.offset %= frames.length - 1;
8664
+ };
8665
+ }
8666
+ };
8667
+ ProgressView = class extends import_hanji.TaskView {
8668
+ constructor(progressText, successText) {
8669
+ super();
8670
+ this.progressText = progressText;
8671
+ this.successText = successText;
8672
+ this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
8673
+ this.timeout = setInterval(() => {
8674
+ this.spinner.tick();
8675
+ this.requestLayout();
8676
+ }, 128);
8677
+ this.on("detach", () => clearInterval(this.timeout));
8678
+ }
8679
+ render(status) {
8680
+ if (status === "pending") {
8681
+ const spin = this.spinner.value();
8682
+ return `[${spin}] ${this.progressText}`;
8683
+ }
8684
+ return `[${source_default.green("\u2713")}] ${this.successText}`;
8685
+ }
8686
+ };
8651
8687
  }
8652
8688
  });
8653
8689
 
@@ -8768,6 +8804,12 @@ var init_sqlite = __esm({
8768
8804
  url: (0, import_zod6.string)(),
8769
8805
  authToken: (0, import_zod6.string)()
8770
8806
  }),
8807
+ (0, import_zod6.object)({
8808
+ driver: (0, import_zod6.literal)("d1-http"),
8809
+ accountId: (0, import_zod6.string)(),
8810
+ databaseId: (0, import_zod6.string)(),
8811
+ token: (0, import_zod6.string)()
8812
+ }),
8771
8813
  (0, import_zod6.object)({
8772
8814
  url: (0, import_zod6.string)()
8773
8815
  })
@@ -8811,6 +8853,7 @@ var init_common2 = __esm({
8811
8853
  (0, import_zod8.literal)("turso"),
8812
8854
  (0, import_zod8.literal)("libsql"),
8813
8855
  (0, import_zod8.literal)("d1"),
8856
+ (0, import_zod8.literal)("d1-http"),
8814
8857
  (0, import_zod8.literal)("expo")
8815
8858
  ]);
8816
8859
  postgresDriver = (0, import_zod8.literal)("aws-data-api");
@@ -9797,6 +9840,7 @@ ${withStyle.errorWarning(
9797
9840
  "time without time zone": "::time without time zone",
9798
9841
  // "timestamp with time zone": "::timestamp with time zone",
9799
9842
  "timestamp without time zone": "::timestamp without time zone",
9843
+ "timestamp(": "::timestamp without time zone",
9800
9844
  // date: "::date",
9801
9845
  // interval: "::interval",
9802
9846
  // character: "::bpchar",
@@ -9809,15 +9853,15 @@ ${withStyle.errorWarning(
9809
9853
  "character(": "::bpchar"
9810
9854
  };
9811
9855
  defaultForColumn = (column4) => {
9856
+ if (column4.column_default === null) {
9857
+ return void 0;
9858
+ }
9812
9859
  if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
9813
9860
  return void 0;
9814
9861
  }
9815
9862
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
9816
9863
  (it) => column4.data_type.startsWith(it)
9817
9864
  );
9818
- if (column4.column_default === null) {
9819
- return void 0;
9820
- }
9821
9865
  const columnDefaultAsString = column4.column_default.toString();
9822
9866
  if (columnDefaultAsString.endsWith(
9823
9867
  hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
@@ -11299,8 +11343,7 @@ var init_jsonDiffer = __esm({
11299
11343
  };
11300
11344
  findAlternationsInTable = (table4) => {
11301
11345
  const columns = table4.columns ?? {};
11302
- const isSemanticallyEqual = (it) => columns[it]["type"]?.__new.replace(" (", "(") === columns[it]["type"]?.__old.replace(" (", "(");
11303
- const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added") || isSemanticallyEqual(it))).map((it) => {
11346
+ const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added"))).map((it) => {
11304
11347
  return { name: it, ...columns[it] };
11305
11348
  });
11306
11349
  const deletedIndexes = Object.fromEntries(
@@ -11402,6 +11445,9 @@ var init_jsonDiffer = __esm({
11402
11445
  return it;
11403
11446
  }).map((it) => {
11404
11447
  if ("type" in it) {
11448
+ if (it.type.__old.replace(" (", "(") === it.type.__new.replace(" (", "(")) {
11449
+ return void 0;
11450
+ }
11405
11451
  return {
11406
11452
  ...it,
11407
11453
  type: { type: "changed", old: it.type.__old, new: it.type.__new }
@@ -11564,7 +11610,7 @@ var init_jsonDiffer = __esm({
11564
11610
  };
11565
11611
  }
11566
11612
  return it;
11567
- });
11613
+ }).filter(Boolean);
11568
11614
  return result[0];
11569
11615
  };
11570
11616
  }
@@ -12448,7 +12494,7 @@ var init_jsonStatements = __esm({
12448
12494
  tableName,
12449
12495
  data: it,
12450
12496
  schema: schema4,
12451
- constraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
12497
+ constraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
12452
12498
  };
12453
12499
  });
12454
12500
  };
@@ -12471,8 +12517,8 @@ var init_jsonStatements = __esm({
12471
12517
  old: it.__old,
12472
12518
  new: it.__new,
12473
12519
  schema: schema4,
12474
- oldConstraintName: json1.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
12475
- newConstraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
12520
+ oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
12521
+ newConstraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
12476
12522
  };
12477
12523
  });
12478
12524
  };
@@ -12742,7 +12788,7 @@ var init_snapshotsDiffer = __esm({
12742
12788
  for (let ren of renamedTables) {
12743
12789
  if (table4.name === ren.from.name && table4.schema === ren.from.schema) {
12744
12790
  return {
12745
- key: `${ren.to.schema}.${ren.to.name}`,
12791
+ key: `${ren.to.schema || "public"}.${ren.to.name}`,
12746
12792
  name: ren.to.name,
12747
12793
  schema: ren.to.schema
12748
12794
  };
@@ -13779,13 +13825,13 @@ var init_words = __esm({
13779
13825
  });
13780
13826
 
13781
13827
  // src/cli/commands/migrate.ts
13782
- var import_hanji3, schemasResolver, tablesResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT;
13828
+ var import_hanji4, schemasResolver, tablesResolver, enumsResolver, columnsResolver, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT;
13783
13829
  var init_migrate = __esm({
13784
13830
  "src/cli/commands/migrate.ts"() {
13785
13831
  "use strict";
13786
13832
  init_migrationPreparator();
13787
13833
  init_snapshotsDiffer();
13788
- import_hanji3 = require("hanji");
13834
+ import_hanji4 = require("hanji");
13789
13835
  init_views();
13790
13836
  init_source();
13791
13837
  init_pgSchema();
@@ -13869,7 +13915,7 @@ var init_migrate = __esm({
13869
13915
  return { from: it, to: created };
13870
13916
  });
13871
13917
  const promptData = [created, ...renames];
13872
- const { status, data } = await (0, import_hanji3.render)(
13918
+ const { status, data } = await (0, import_hanji4.render)(
13873
13919
  new ResolveColumnSelect(tableName, created, promptData)
13874
13920
  );
13875
13921
  if (status === "aborted") {
@@ -13920,7 +13966,7 @@ var init_migrate = __esm({
13920
13966
  return { from: it, to: created };
13921
13967
  });
13922
13968
  const promptData = [created, ...renames];
13923
- const { status, data } = await (0, import_hanji3.render)(
13969
+ const { status, data } = await (0, import_hanji4.render)(
13924
13970
  new ResolveSelect(created, promptData, entity)
13925
13971
  );
13926
13972
  if (status === "aborted") {
@@ -13975,7 +14021,7 @@ var init_migrate = __esm({
13975
14021
  return { from: it, to: created };
13976
14022
  });
13977
14023
  const promptData = [created, ...renames];
13978
- const { status, data } = await (0, import_hanji3.render)(
14024
+ const { status, data } = await (0, import_hanji4.render)(
13979
14025
  new ResolveSchemasSelect(created, promptData)
13980
14026
  );
13981
14027
  if (status === "aborted") {
@@ -14114,8 +14160,7 @@ var init_sqlgenerator = __esm({
14114
14160
  convert(st) {
14115
14161
  const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
14116
14162
  let statement = "";
14117
- const tName = schema4 ? `\`${schema4}\`.\`${tableName}\`` : `\`${tableName}\``;
14118
- statement += `CREATE TABLE ${tName} (
14163
+ statement += `CREATE TABLE \`${tableName}\` (
14119
14164
  `;
14120
14165
  for (let i = 0; i < columns.length; i++) {
14121
14166
  const column4 = columns[i];
@@ -14235,8 +14280,7 @@ var init_sqlgenerator = __esm({
14235
14280
  }
14236
14281
  convert(statement) {
14237
14282
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
14238
- const tableNameWithSchema = statement.schema ? `\`${statement.schema}\`.\`${statement.tableName}\`` : `\`${statement.tableName}\``;
14239
- return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
14283
+ return `ALTER TABLE \`${statement.tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
14240
14284
  }
14241
14285
  };
14242
14286
  MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
@@ -14245,8 +14289,7 @@ var init_sqlgenerator = __esm({
14245
14289
  }
14246
14290
  convert(statement) {
14247
14291
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
14248
- const tableNameWithSchema = statement.schema ? `\`${statement.schema}\`.\`${statement.tableName}\`` : `\`${statement.tableName}\``;
14249
- return `ALTER TABLE ${tableNameWithSchema} DROP INDEX \`${unsquashed.name}\`;`;
14292
+ return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
14250
14293
  }
14251
14294
  };
14252
14295
  SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
@@ -14361,10 +14404,8 @@ var init_sqlgenerator = __esm({
14361
14404
  return statement.type === "rename_table" && dialect7 === "mysql";
14362
14405
  }
14363
14406
  convert(statement) {
14364
- const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
14365
- const from = fromSchema ? `\`${fromSchema}\`.\`${tableNameFrom}\`` : `\`${tableNameFrom}\``;
14366
- const to = fromSchema ? `\`${fromSchema}\`.\`${tableNameTo}\`` : `\`${tableNameTo}\``;
14367
- return `RENAME TABLE ${from} TO ${to};`;
14407
+ const { tableNameFrom, tableNameTo } = statement;
14408
+ return `RENAME TABLE \`${tableNameFrom}\` TO \`${tableNameTo}\`;`;
14368
14409
  }
14369
14410
  };
14370
14411
  PgAlterTableRenameColumnConvertor = class extends Convertor {
@@ -15172,9 +15213,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
15172
15213
  return statement.type === "drop_index" && dialect7 === "mysql";
15173
15214
  }
15174
15215
  convert(statement) {
15175
- const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
15176
15216
  const { name: name2 } = MySqlSquasher.unsquashIdx(statement.data);
15177
- return `DROP INDEX \`${name2}\` ON ${tableName};`;
15217
+ return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
15178
15218
  }
15179
15219
  };
15180
15220
  convertors = [];
@@ -15291,18 +15331,18 @@ drop type __venum;
15291
15331
  });
15292
15332
 
15293
15333
  // src/cli/selector-ui.ts
15294
- var import_hanji4, Select;
15334
+ var import_hanji5, Select;
15295
15335
  var init_selector_ui = __esm({
15296
15336
  "src/cli/selector-ui.ts"() {
15297
15337
  "use strict";
15298
15338
  init_source();
15299
- import_hanji4 = require("hanji");
15300
- Select = class extends import_hanji4.Prompt {
15339
+ import_hanji5 = require("hanji");
15340
+ Select = class extends import_hanji5.Prompt {
15301
15341
  constructor(items) {
15302
15342
  super();
15303
15343
  this.on("attach", (terminal) => terminal.toggleCursor("hide"));
15304
15344
  this.on("detach", (terminal) => terminal.toggleCursor("show"));
15305
- this.data = new import_hanji4.SelectState(
15345
+ this.data = new import_hanji5.SelectState(
15306
15346
  items.map((it) => ({ label: it, value: `${it}-value` }))
15307
15347
  );
15308
15348
  this.data.bind(this);
@@ -18829,12 +18869,24 @@ The unique constraint ${source_default.underline.blue(
18829
18869
  `SELECT
18830
18870
  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
18831
18871
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
18832
- 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';
18872
+ WHERE m.type = 'table'
18873
+ and m.tbl_name != 'sqlite_sequence'
18874
+ and m.tbl_name != 'sqlite_stat1'
18875
+ and m.tbl_name != '_litestream_seq'
18876
+ and m.tbl_name != '_litestream_lock'
18877
+ and m.tbl_name != 'libsql_wasm_func_table'
18878
+ and m.tbl_name != '__drizzle_migrations'
18879
+ and m.tbl_name != '_cf_KV';
18833
18880
  `
18834
18881
  );
18835
18882
  const tablesWithSeq = [];
18836
18883
  const seq = await db.query(
18837
- `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[^'']*';`
18884
+ `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
18885
+ and name != 'sqlite_stat1'
18886
+ and name != '_litestream_seq'
18887
+ and name != '_litestream_lock'
18888
+ and tbl_name != '_cf_KV'
18889
+ and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
18838
18890
  );
18839
18891
  for (const s of seq) {
18840
18892
  tablesWithSeq.push(s.name);
@@ -18919,7 +18971,8 @@ The unique constraint ${source_default.underline.blue(
18919
18971
  try {
18920
18972
  const fks = await db.query(
18921
18973
  `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"
18922
- FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
18974
+ FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
18975
+ where m.tbl_name != '_cf_KV';`
18923
18976
  );
18924
18977
  const fkByTableName = {};
18925
18978
  for (const fkRow of fks) {
@@ -18978,7 +19031,9 @@ FROM sqlite_master AS m,
18978
19031
  pragma_index_list(m.name) AS il,
18979
19032
  pragma_index_info(il.name) AS ii
18980
19033
  WHERE
18981
- m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
19034
+ m.type = 'table'
19035
+ and il.name NOT LIKE 'sqlite_autoindex_%'
19036
+ and m.tbl_name != '_cf_KV';`
18982
19037
  );
18983
19038
  for (const idxRow of idxs) {
18984
19039
  const tableName = idxRow.tableName;
@@ -23636,12 +23691,12 @@ __export(mysqlPushUtils_exports, {
23636
23691
  filterStatements: () => filterStatements,
23637
23692
  logSuggestionsAndReturn: () => logSuggestionsAndReturn2
23638
23693
  });
23639
- var import_hanji7, filterStatements, logSuggestionsAndReturn2;
23694
+ var import_hanji8, filterStatements, logSuggestionsAndReturn2;
23640
23695
  var init_mysqlPushUtils = __esm({
23641
23696
  "src/cli/commands/mysqlPushUtils.ts"() {
23642
23697
  "use strict";
23643
23698
  init_source();
23644
- import_hanji7 = require("hanji");
23699
+ import_hanji8 = require("hanji");
23645
23700
  init_mysqlSchema();
23646
23701
  init_selector_ui();
23647
23702
  init_outputs();
@@ -23855,7 +23910,7 @@ var init_mysqlPushUtils = __esm({
23855
23910
  )} table?
23856
23911
  `
23857
23912
  );
23858
- const { status, data } = await (0, import_hanji7.render)(
23913
+ const { status, data } = await (0, import_hanji8.render)(
23859
23914
  new Select([
23860
23915
  "No, add the constraint without truncating the table",
23861
23916
  `Yes, truncate the table`
@@ -23887,13 +23942,15 @@ var mysqlIntrospect_exports = {};
23887
23942
  __export(mysqlIntrospect_exports, {
23888
23943
  mysqlPushIntrospect: () => mysqlPushIntrospect
23889
23944
  });
23890
- var mysqlPushIntrospect;
23945
+ var import_hanji9, mysqlPushIntrospect;
23891
23946
  var init_mysqlIntrospect = __esm({
23892
23947
  "src/cli/commands/mysqlIntrospect.ts"() {
23893
23948
  "use strict";
23894
23949
  init_mysqlSerializer();
23895
23950
  init_global();
23896
23951
  init_mjs();
23952
+ init_views();
23953
+ import_hanji9 = require("hanji");
23897
23954
  mysqlPushIntrospect = async (db, databaseName, filters) => {
23898
23955
  const matchers = filters.map((it) => {
23899
23956
  return new Minimatch(it);
@@ -23908,7 +23965,14 @@ var init_mysqlIntrospect = __esm({
23908
23965
  }
23909
23966
  return false;
23910
23967
  };
23911
- const res = await fromDatabase3(db, databaseName, filter2);
23968
+ const progress = new ProgressView(
23969
+ "Pulling schema from database...",
23970
+ "Pulling schema from database..."
23971
+ );
23972
+ const res = await (0, import_hanji9.renderWithTask)(
23973
+ progress,
23974
+ fromDatabase3(db, databaseName, filter2)
23975
+ );
23912
23976
  const schema4 = { id: originUUID, prevId: "", ...res };
23913
23977
  const { internal, ...schemaWithoutInternals } = schema4;
23914
23978
  return { schema: schemaWithoutInternals };
@@ -23943,6 +24007,8 @@ init_mysqlSchema();
23943
24007
  init_pgSerializer();
23944
24008
  init_global();
23945
24009
  init_mjs();
24010
+ init_views();
24011
+ var import_hanji3 = require("hanji");
23946
24012
  var pgPushIntrospect = async (db, filters, schemaFilters) => {
23947
24013
  const matchers = filters.map((it) => {
23948
24014
  return new Minimatch(it);
@@ -23957,7 +24023,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
23957
24023
  }
23958
24024
  return false;
23959
24025
  };
23960
- const res = await fromDatabase(db, filter2, schemaFilters);
24026
+ const progress = new ProgressView(
24027
+ "Pulling schema from database...",
24028
+ "Pulling schema from database..."
24029
+ );
24030
+ const res = await (0, import_hanji3.renderWithTask)(
24031
+ progress,
24032
+ fromDatabase(db, filter2, schemaFilters)
24033
+ );
23961
24034
  const schema4 = { id: originUUID, prevId: "", ...res };
23962
24035
  const { internal, ...schemaWithoutInternals } = schema4;
23963
24036
  return { schema: schemaWithoutInternals };
@@ -23965,7 +24038,7 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
23965
24038
 
23966
24039
  // src/cli/commands/pgPushUtils.ts
23967
24040
  init_source();
23968
- var import_hanji5 = require("hanji");
24041
+ var import_hanji6 = require("hanji");
23969
24042
  init_pgSchema();
23970
24043
  init_sqlgenerator();
23971
24044
  init_selector_ui();
@@ -24215,7 +24288,7 @@ var pgSuggestions = async (db, statements) => {
24215
24288
  )} table?
24216
24289
  `
24217
24290
  );
24218
- const { status, data } = await (0, import_hanji5.render)(
24291
+ const { status, data } = await (0, import_hanji6.render)(
24219
24292
  new Select([
24220
24293
  "No, add the constraint without truncating the table",
24221
24294
  `Yes, truncate the table`
@@ -24375,7 +24448,7 @@ Array.prototype.random = function() {
24375
24448
 
24376
24449
  // src/cli/commands/sqliteIntrospect.ts
24377
24450
  init_mjs();
24378
- var import_hanji6 = require("hanji");
24451
+ var import_hanji7 = require("hanji");
24379
24452
  var sqlitePushIntrospect = async (db, filters) => {
24380
24453
  const matchers = filters.map((it) => {
24381
24454
  return new Minimatch(it);
@@ -24390,7 +24463,14 @@ var sqlitePushIntrospect = async (db, filters) => {
24390
24463
  }
24391
24464
  return false;
24392
24465
  };
24393
- const res = await fromDatabase2(db, filter2);
24466
+ const progress = new ProgressView(
24467
+ "Pulling schema from database...",
24468
+ "Pulling schema from database..."
24469
+ );
24470
+ const res = await (0, import_hanji7.renderWithTask)(
24471
+ progress,
24472
+ fromDatabase2(db, filter2)
24473
+ );
24394
24474
  const schema4 = { id: originUUID, prevId: "", ...res };
24395
24475
  return { schema: schema4 };
24396
24476
  };
@@ -24507,7 +24587,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
24507
24587
  ).find(
24508
24588
  (c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName)
24509
24589
  );
24510
- const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
24590
+ const columnIsPk = json2.tables[newTableName].columns[statement.columnName].primaryKey;
24511
24591
  const columnIsPartOfFk = Object.values(
24512
24592
  json1.tables[newTableName].foreignKeys
24513
24593
  ).find(
@@ -24591,48 +24671,52 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
24591
24671
  }
24592
24672
  }
24593
24673
  } 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") {
24594
- const newTableName = getOldTableName(statement.tableName, meta);
24595
- if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
24596
- const res = await connection.query(
24597
- `select count(*) as count from \`${newTableName}\``
24598
- );
24599
- const count2 = Number(res[0].count);
24600
- if (count2 > 0) {
24601
- infoToPrint.push(
24602
- `\xB7 You're about to add not-null constraint to ${source_default.underline(
24603
- statement.columnName
24604
- )} column without default value, which contains ${count2} items`
24674
+ if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
24675
+ const newTableName = getOldTableName(statement.tableName, meta);
24676
+ if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
24677
+ const res = await connection.query(
24678
+ `select count(*) as count from \`${newTableName}\``
24605
24679
  );
24606
- tablesToTruncate.push(newTableName);
24607
- shouldAskForApprove = true;
24608
- }
24609
- tablesContext[newTableName] = _moveDataStatements(
24610
- statement.tableName,
24611
- json2,
24612
- true
24613
- );
24614
- } else {
24615
- if (typeof tablesContext[newTableName] === "undefined") {
24680
+ const count2 = Number(res[0].count);
24681
+ if (count2 > 0) {
24682
+ infoToPrint.push(
24683
+ `\xB7 You're about to add not-null constraint to ${source_default.underline(
24684
+ statement.columnName
24685
+ )} column without default value, which contains ${count2} items`
24686
+ );
24687
+ tablesToTruncate.push(newTableName);
24688
+ shouldAskForApprove = true;
24689
+ }
24616
24690
  tablesContext[newTableName] = _moveDataStatements(
24617
24691
  statement.tableName,
24618
- json2
24692
+ json2,
24693
+ true
24619
24694
  );
24695
+ } else {
24696
+ if (typeof tablesContext[newTableName] === "undefined") {
24697
+ tablesContext[newTableName] = _moveDataStatements(
24698
+ statement.tableName,
24699
+ json2
24700
+ );
24701
+ }
24620
24702
  }
24621
- }
24622
- const tablesReferncingCurrent = [];
24623
- for (const table4 of Object.values(json1.tables)) {
24624
- const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter((t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName).map((t) => {
24625
- return getNewTableName(
24626
- SQLiteSquasher.unsquashFK(t).tableFrom,
24627
- meta
24628
- );
24629
- });
24630
- tablesReferncingCurrent.push(...tablesRefs);
24631
- }
24632
- const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
24633
- for (const table4 of uniqueTableRefs) {
24634
- if (typeof tablesContext[table4] === "undefined") {
24635
- tablesContext[table4] = [..._moveDataStatements(table4, json2)];
24703
+ const tablesReferncingCurrent = [];
24704
+ for (const table4 of Object.values(json1.tables)) {
24705
+ const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
24706
+ (t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
24707
+ ).map((t) => {
24708
+ return getNewTableName(
24709
+ SQLiteSquasher.unsquashFK(t).tableFrom,
24710
+ meta
24711
+ );
24712
+ });
24713
+ tablesReferncingCurrent.push(...tablesRefs);
24714
+ }
24715
+ const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
24716
+ for (const table4 of uniqueTableRefs) {
24717
+ if (typeof tablesContext[table4] === "undefined") {
24718
+ tablesContext[table4] = [..._moveDataStatements(table4, json2)];
24719
+ }
24636
24720
  }
24637
24721
  }
24638
24722
  } else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {