drizzle-kit 0.20.17-b4f119e → 0.20.17-c347d7b

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/payload.js CHANGED
@@ -5900,8 +5900,8 @@ var init_serializer = __esm({
5900
5900
  "use strict";
5901
5901
  glob = __toESM(require("glob"));
5902
5902
  init_views();
5903
- sqlToStr = (sql2) => {
5904
- return sql2.toQuery({
5903
+ sqlToStr = (sql) => {
5904
+ return sql.toQuery({
5905
5905
  escapeName: () => {
5906
5906
  throw new Error("we don't support params for `sql` default values");
5907
5907
  },
@@ -5927,7 +5927,8 @@ var init_outputs = __esm({
5927
5927
  warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
5928
5928
  errorWarning: (str) => `${source_default.red(`${source_default.white.bgRed(" Warning ")} ${str}`)}`,
5929
5929
  fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`,
5930
- suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`
5930
+ suggestion: (str) => `${source_default.white.bgGray(" Suggestion ")} ${str}`,
5931
+ info: (str) => `${source_default.grey(str)}`
5931
5932
  };
5932
5933
  }
5933
5934
  });
@@ -6132,7 +6133,7 @@ var init_cli = __esm({
6132
6133
  dialect: dialect3,
6133
6134
  schema: unionType([stringType(), stringType().array()]).optional(),
6134
6135
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
6135
- schemaFilters: unionType([stringType(), stringType().array()]).optional().default(["public"]),
6136
+ schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
6136
6137
  driver: stringType().optional(),
6137
6138
  // pg
6138
6139
  connectionString: stringType().optional(),
@@ -6171,7 +6172,7 @@ var init_cli = __esm({
6171
6172
  authToken: stringType().optional(),
6172
6173
  introspectCasing: casing,
6173
6174
  breakpoints: booleanType().optional().default(true)
6174
- });
6175
+ }).passthrough();
6175
6176
  configCheck = objectType({
6176
6177
  dialect: dialect3.optional(),
6177
6178
  out: stringType().optional()
@@ -6185,6 +6186,33 @@ var init_cli = __esm({
6185
6186
  }
6186
6187
  });
6187
6188
 
6189
+ // src/cli/validations/studio.ts
6190
+ var credentials, studioCliParams, studioConfig;
6191
+ var init_studio = __esm({
6192
+ "src/cli/validations/studio.ts"() {
6193
+ "use strict";
6194
+ init_lib();
6195
+ init_mysql();
6196
+ init_sqlite();
6197
+ init_schemaValidator();
6198
+ init_pg();
6199
+ credentials = intersectionType(
6200
+ postgresCredentials,
6201
+ mysqlCredentials,
6202
+ sqliteCredentials
6203
+ );
6204
+ studioCliParams = objectType({
6205
+ port: coerce.number().optional().default(4983),
6206
+ host: stringType().optional().default("127.0.0.1"),
6207
+ config: stringType().optional()
6208
+ });
6209
+ studioConfig = objectType({
6210
+ dialect: dialect3,
6211
+ schema: unionType([stringType(), stringType().array()])
6212
+ });
6213
+ }
6214
+ });
6215
+
6188
6216
  // src/cli/commands/_es5.ts
6189
6217
  var es5_exports = {};
6190
6218
  __export(es5_exports, {
@@ -9214,13 +9242,13 @@ var require_node2 = __commonJS({
9214
9242
  }
9215
9243
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
9216
9244
  try {
9217
- var info3 = gen[key](arg);
9218
- var value = info3.value;
9245
+ var info2 = gen[key](arg);
9246
+ var value = info2.value;
9219
9247
  } catch (error2) {
9220
9248
  reject(error2);
9221
9249
  return;
9222
9250
  }
9223
- if (info3.done) {
9251
+ if (info2.done) {
9224
9252
  resolve(value);
9225
9253
  } else {
9226
9254
  Promise.resolve(value).then(_next, _throw);
@@ -11805,7 +11833,7 @@ var require_node2 = __commonJS({
11805
11833
  });
11806
11834
 
11807
11835
  // src/cli/commands/utils.ts
11808
- var import_hanji2, assertES5, safeRegister;
11836
+ var import_hanji2, assertES5, safeRegister, migrateCliParams, migrateConfig;
11809
11837
  var init_utils2 = __esm({
11810
11838
  "src/cli/commands/utils.ts"() {
11811
11839
  "use strict";
@@ -11817,8 +11845,11 @@ var init_utils2 = __esm({
11817
11845
  init_pg();
11818
11846
  init_sqlite();
11819
11847
  init_common();
11848
+ init_schemaValidator();
11820
11849
  init_cli();
11821
11850
  init_outputs();
11851
+ init_studio();
11852
+ init_lib();
11822
11853
  assertES5 = async (unregister) => {
11823
11854
  try {
11824
11855
  init_es5();
@@ -11860,6 +11891,17 @@ var init_utils2 = __esm({
11860
11891
  await assertES5(res.unregister);
11861
11892
  return res;
11862
11893
  };
11894
+ migrateCliParams = objectType({
11895
+ config: stringType().optional()
11896
+ });
11897
+ migrateConfig = objectType({
11898
+ dialect: dialect3,
11899
+ out: stringType().optional().default("drizzle"),
11900
+ migrations: objectType({
11901
+ table: stringType().optional(),
11902
+ schema: stringType().optional()
11903
+ }).optional()
11904
+ });
11863
11905
  }
11864
11906
  });
11865
11907
 
@@ -15708,7 +15750,7 @@ var init_snapshotsDiffer = __esm({
15708
15750
  const jsonTableAlternations = alteredTables.map((it) => {
15709
15751
  return preparePgAlterColumns(it.name, it.schema, it.altered, json2);
15710
15752
  }).flat();
15711
- const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
15753
+ const jsonCreateIndexesFoAlteredTables = alteredTables.map((it) => {
15712
15754
  return prepareCreateIndexesJson(
15713
15755
  it.name,
15714
15756
  it.schema,
@@ -15737,14 +15779,21 @@ var init_snapshotsDiffer = __esm({
15737
15779
  },
15738
15780
  {}
15739
15781
  );
15740
- jsonCreateIndexesForAllAlteredTables.push(
15782
+ jsonCreateIndexesFoAlteredTables.push(
15741
15783
  ...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
15742
15784
  );
15743
15785
  jsonDropIndexesForAllAlteredTables.push(
15744
15786
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
15745
15787
  );
15746
15788
  });
15747
- const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
15789
+ const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
15790
+ return prepareCreateReferencesJson(
15791
+ it.name,
15792
+ it.schema,
15793
+ it.foreignKeys
15794
+ );
15795
+ }).flat();
15796
+ const jsonReferencesForAlteredTables = alteredTables.map((it) => {
15748
15797
  const forAdded = prepareCreateReferencesJson(
15749
15798
  it.name,
15750
15799
  it.schema,
@@ -15762,10 +15811,10 @@ var init_snapshotsDiffer = __esm({
15762
15811
  );
15763
15812
  return [...forAdded, ...forAltered, ...alteredFKs];
15764
15813
  }).flat();
15765
- const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15814
+ const jsonCreatedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15766
15815
  (t) => t.type === "create_reference"
15767
15816
  );
15768
- const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
15817
+ const jsonDroppedReferencesForAlteredTables = jsonReferencesForAlteredTables.filter(
15769
15818
  (t) => t.type === "delete_reference"
15770
15819
  );
15771
15820
  const createEnums = createdEnums.map((it) => {
@@ -15792,7 +15841,7 @@ var init_snapshotsDiffer = __esm({
15792
15841
  const dropSchemas = prepareDeleteSchemasJson(
15793
15842
  deletedSchemas.map((it) => it.name)
15794
15843
  );
15795
- const jsonPgCreateTables = createdTables.map((it) => {
15844
+ const createTables = createdTables.map((it) => {
15796
15845
  return preparePgCreateTableJson(it, curFull);
15797
15846
  });
15798
15847
  jsonStatements.push(...createSchemas);
@@ -15801,7 +15850,7 @@ var init_snapshotsDiffer = __esm({
15801
15850
  jsonStatements.push(...moveEnums);
15802
15851
  jsonStatements.push(...renameEnums);
15803
15852
  jsonStatements.push(...jsonAlterEnumsWithAddedValues);
15804
- jsonStatements.push(...jsonPgCreateTables);
15853
+ jsonStatements.push(...createTables);
15805
15854
  jsonStatements.push(...jsonDropTables);
15806
15855
  jsonStatements.push(...jsonSetTableSchemas);
15807
15856
  jsonStatements.push(...jsonRenameTables);
@@ -15812,9 +15861,10 @@ var init_snapshotsDiffer = __esm({
15812
15861
  jsonStatements.push(...jsonTableAlternations);
15813
15862
  jsonStatements.push(...jsonAddedCompositePKs);
15814
15863
  jsonStatements.push(...jsonAddColumnsStatemets);
15864
+ jsonStatements.push(...jsonCreateReferencesForCreatedTables);
15815
15865
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
15816
- jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
15817
15866
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
15867
+ jsonStatements.push(...jsonCreateIndexesFoAlteredTables);
15818
15868
  jsonStatements.push(...jsonDropColumnsStatemets);
15819
15869
  jsonStatements.push(...jsonAlteredCompositePKs);
15820
15870
  jsonStatements.push(...jsonAlteredUniqueConstraints);
@@ -16073,6 +16123,13 @@ var init_snapshotsDiffer = __esm({
16073
16123
  ...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
16074
16124
  );
16075
16125
  });
16126
+ const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
16127
+ return prepareCreateReferencesJson(
16128
+ it.name,
16129
+ it.schema,
16130
+ it.foreignKeys
16131
+ );
16132
+ }).flat();
16076
16133
  const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
16077
16134
  const forAdded = prepareCreateReferencesJson(
16078
16135
  it.name,
@@ -16113,9 +16170,10 @@ var init_snapshotsDiffer = __esm({
16113
16170
  jsonStatements.push(...jsonAddedUniqueConstraints);
16114
16171
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16115
16172
  jsonStatements.push(...jsonAddColumnsStatemets);
16173
+ jsonStatements.push(...jsonCreateReferencesForCreatedTables);
16116
16174
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
16117
- jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16118
16175
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16176
+ jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16119
16177
  jsonStatements.push(...jsonDropColumnsStatemets);
16120
16178
  jsonStatements.push(...jsonAlteredCompositePKs);
16121
16179
  jsonStatements.push(...jsonAddedUniqueConstraints);
@@ -17540,12 +17598,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17540
17598
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${tableFrom}"` : `"${tableFrom}"`;
17541
17599
  const tableToNameWithSchema = schemaTo ? `"${schemaTo}"."${tableTo}"` : `"${tableTo}"`;
17542
17600
  const alterStatement = `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
17543
- let sql2 = "DO $$ BEGIN\n";
17544
- sql2 += " " + alterStatement + ";\n";
17545
- sql2 += "EXCEPTION\n";
17546
- sql2 += " WHEN duplicate_object THEN null;\n";
17547
- sql2 += "END $$;\n";
17548
- return sql2;
17601
+ let sql = "DO $$ BEGIN\n";
17602
+ sql += " " + alterStatement + ";\n";
17603
+ sql += "EXCEPTION\n";
17604
+ sql += " WHEN duplicate_object THEN null;\n";
17605
+ sql += "END $$;\n";
17606
+ return sql;
17549
17607
  }
17550
17608
  };
17551
17609
  SqliteCreateForeignKeyConvertor = class extends Convertor {
@@ -17591,7 +17649,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17591
17649
  const newFk = PgSquasher.unsquashFK(statement.data);
17592
17650
  const oldFk = PgSquasher.unsquashFK(statement.oldFkey);
17593
17651
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
17594
- let sql2 = `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${oldFk.name}";
17652
+ let sql = `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${oldFk.name}";
17595
17653
  `;
17596
17654
  const onDeleteStatement = newFk.onDelete ? ` ON DELETE ${newFk.onDelete}` : "";
17597
17655
  const onUpdateStatement = newFk.onUpdate ? ` ON UPDATE ${newFk.onUpdate}` : "";
@@ -17600,12 +17658,12 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17600
17658
  const tableFromNameWithSchema = oldFk.schemaTo ? `"${oldFk.schemaTo}"."${oldFk.tableFrom}"` : `"${oldFk.tableFrom}"`;
17601
17659
  const tableToNameWithSchema = newFk.schemaTo ? `"${newFk.schemaTo}"."${newFk.tableFrom}"` : `"${newFk.tableFrom}"`;
17602
17660
  const alterStatement = `ALTER TABLE ${tableFromNameWithSchema} ADD CONSTRAINT "${newFk.name}" FOREIGN KEY (${fromColumnsString}) REFERENCES ${tableToNameWithSchema}(${toColumnsString})${onDeleteStatement}${onUpdateStatement}`;
17603
- sql2 += "DO $$ BEGIN\n";
17604
- sql2 += " " + alterStatement + ";\n";
17605
- sql2 += "EXCEPTION\n";
17606
- sql2 += " WHEN duplicate_object THEN null;\n";
17607
- sql2 += "END $$;\n";
17608
- return sql2;
17661
+ sql += "DO $$ BEGIN\n";
17662
+ sql += " " + alterStatement + ";\n";
17663
+ sql += "EXCEPTION\n";
17664
+ sql += " WHEN duplicate_object THEN null;\n";
17665
+ sql += "END $$;\n";
17666
+ return sql;
17609
17667
  }
17610
17668
  };
17611
17669
  SqliteAlterForeignKeyConvertor = class extends Convertor {
@@ -17972,7 +18030,9 @@ function mapSqlToSqliteType(sqlType) {
17972
18030
  return "text";
17973
18031
  } else if (lowered.startsWith("blob")) {
17974
18032
  return "blob";
17975
- } else if (["real", "double", "double precision", "float"].some((it) => lowered.startsWith(it))) {
18033
+ } else if (["real", "double", "double precision", "float"].some(
18034
+ (it) => lowered.startsWith(it)
18035
+ )) {
17976
18036
  return "real";
17977
18037
  } else {
17978
18038
  return "numeric";
@@ -18159,7 +18219,7 @@ The unique constraint ${source_default.underline.blue(
18159
18219
  `SELECT
18160
18220
  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
18161
18221
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
18162
- 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';
18222
+ 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';
18163
18223
  `
18164
18224
  );
18165
18225
  const tablesWithSeq = [];
@@ -19668,6 +19728,9 @@ String.prototype.squashSpaces = function() {
19668
19728
  String.prototype.camelCase = function() {
19669
19729
  return camelCase(String(this));
19670
19730
  };
19731
+ String.prototype.capitalise = function() {
19732
+ return this && this.length > 0 ? `${this[0].toUpperCase()}${this.slice(1)}` : String(this);
19733
+ };
19671
19734
  String.prototype.concatIf = function(it, condition) {
19672
19735
  return condition ? `${this}${it}` : String(this);
19673
19736
  };
@@ -19978,7 +20041,6 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
19978
20041
  init_mysqlSerializer();
19979
20042
  init_global();
19980
20043
  init_migrate();
19981
- var import_drizzle_orm8 = require("drizzle-orm");
19982
20044
  var generateDrizzleJson = (imports, prevId) => {
19983
20045
  const prepared = prepareFromExports(imports);
19984
20046
  const id = (0, import_crypto.randomUUID)();
@@ -20013,9 +20075,10 @@ var generateMigration = async (prev, cur) => {
20013
20075
  };
20014
20076
  var pushSchema = async (imports, drizzleInstance) => {
20015
20077
  const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
20078
+ const { sql } = await import("drizzle-orm");
20016
20079
  const db = {
20017
20080
  query: async (query, params) => {
20018
- const res = await drizzleInstance.execute(import_drizzle_orm8.sql.raw(query));
20081
+ const res = await drizzleInstance.execute(sql.raw(query));
20019
20082
  return res.rows;
20020
20083
  }
20021
20084
  };
@@ -20074,13 +20137,14 @@ var generateSQLiteMigration = async (prev, cur) => {
20074
20137
  };
20075
20138
  var pushSQLiteSchema = async (imports, drizzleInstance) => {
20076
20139
  const { applySqliteSnapshotsDiff: applySqliteSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
20140
+ const { sql } = await import("drizzle-orm");
20077
20141
  const db = {
20078
20142
  query: async (query, params) => {
20079
- const res = drizzleInstance.all(import_drizzle_orm8.sql.raw(query));
20143
+ const res = drizzleInstance.all(sql.raw(query));
20080
20144
  return res;
20081
20145
  },
20082
20146
  run: async (query) => {
20083
- return Promise.resolve(drizzleInstance.run(import_drizzle_orm8.sql.raw(query))).then(
20147
+ return Promise.resolve(drizzleInstance.run(sql.raw(query))).then(
20084
20148
  () => {
20085
20149
  }
20086
20150
  );
@@ -20147,9 +20211,10 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
20147
20211
  const { applyMysqlSnapshotsDiff: applyMysqlSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
20148
20212
  const { logSuggestionsAndReturn: logSuggestionsAndReturn3 } = await Promise.resolve().then(() => (init_mysqlPushUtils(), mysqlPushUtils_exports));
20149
20213
  const { mysqlPushIntrospect: mysqlPushIntrospect2 } = await Promise.resolve().then(() => (init_mysqlIntrospect(), mysqlIntrospect_exports));
20214
+ const { sql } = await import("drizzle-orm");
20150
20215
  const db = {
20151
20216
  query: async (query, params) => {
20152
- const res = await drizzleInstance.execute(import_drizzle_orm8.sql.raw(query));
20217
+ const res = await drizzleInstance.execute(sql.raw(query));
20153
20218
  return res[0];
20154
20219
  }
20155
20220
  };