drizzle-kit 0.20.14-6ce9d1f → 0.20.14-a183d8b

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -5724,12 +5724,36 @@ var init_outputs = __esm({
5724
5724
  }
5725
5725
  });
5726
5726
 
5727
+ // src/schemaValidator.ts
5728
+ var dialect3, commonSquashedSchema, commonSchema;
5729
+ var init_schemaValidator = __esm({
5730
+ "src/schemaValidator.ts"() {
5731
+ init_lib();
5732
+ init_mysqlSchema();
5733
+ init_pgSchema();
5734
+ init_sqliteSchema();
5735
+ dialect3 = enumType(["pg", "mysql", "sqlite"]);
5736
+ commonSquashedSchema = unionType([
5737
+ pgSchemaSquashed,
5738
+ mysqlSchemaSquashed,
5739
+ SQLiteSchemaSquashed
5740
+ ]);
5741
+ commonSchema = unionType([
5742
+ pgSchema,
5743
+ mysqlSchema,
5744
+ sqliteSchema
5745
+ ]);
5746
+ }
5747
+ });
5748
+
5727
5749
  // src/cli/validations/common.ts
5728
- var checkCollisions;
5750
+ var assertCollisions, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema;
5729
5751
  var init_common = __esm({
5730
5752
  "src/cli/validations/common.ts"() {
5731
5753
  init_outputs();
5732
- checkCollisions = (options, command, inputWhitelist = []) => {
5754
+ init_lib();
5755
+ init_schemaValidator();
5756
+ assertCollisions = (options, command, inputWhitelist = []) => {
5733
5757
  const { config, ...rest } = options;
5734
5758
  let atLeastOneParam = false;
5735
5759
  for (const key of Object.keys(rest)) {
@@ -5738,29 +5762,87 @@ var init_common = __esm({
5738
5762
  atLeastOneParam = true;
5739
5763
  }
5740
5764
  if (!atLeastOneParam && typeof config !== "undefined") {
5741
- return {
5742
- success: true,
5743
- action: "config"
5744
- };
5765
+ return "config";
5745
5766
  }
5746
5767
  if (typeof config === "undefined" && atLeastOneParam) {
5747
- return {
5748
- success: true,
5749
- action: "cli"
5750
- };
5768
+ return "cli";
5751
5769
  }
5752
5770
  if (typeof config === "undefined" && !atLeastOneParam) {
5753
- return {
5754
- success: true,
5755
- action: "config"
5756
- };
5771
+ return "config";
5757
5772
  }
5758
- return {
5759
- success: false,
5760
- message: outputs.common.ambiguousParams(command),
5761
- action: "error"
5762
- };
5773
+ console.log(outputs.common.ambiguousParams(command));
5774
+ process.exit(1);
5763
5775
  };
5776
+ driver = unionType([
5777
+ literalType("better-sqlite"),
5778
+ literalType("turso"),
5779
+ literalType("libsql"),
5780
+ literalType("d1"),
5781
+ literalType("expo"),
5782
+ literalType("pg"),
5783
+ literalType("mysql2")
5784
+ ]);
5785
+ configCommonSchema = objectType({
5786
+ dialect: dialect3,
5787
+ schema: unionType([stringType(), stringType().array()]),
5788
+ out: stringType().optional(),
5789
+ breakpoints: booleanType().default(true),
5790
+ driver: driver.optional(),
5791
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5792
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
5793
+ });
5794
+ introspectCasing = objectType({
5795
+ casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
5796
+ }).default({ casing: "camel" });
5797
+ configIntrospectSchema = objectType({
5798
+ schema: unionType([stringType(), stringType().array()]).optional(),
5799
+ out: stringType().optional().default("./drizzle"),
5800
+ breakpoints: booleanType().default(true),
5801
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5802
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
5803
+ introspect: introspectCasing
5804
+ });
5805
+ configIntrospectCliSchema = objectType({
5806
+ schema: unionType([stringType(), stringType().array()]).optional(),
5807
+ out: stringType().optional().default("./drizzle"),
5808
+ breakpoints: booleanType().default(true),
5809
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5810
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
5811
+ introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
5812
+ "camel"
5813
+ )
5814
+ });
5815
+ configGenerateSchema = objectType({
5816
+ schema: unionType([stringType(), stringType().array()]),
5817
+ out: stringType().optional().default("./drizzle"),
5818
+ breakpoints: booleanType().default(true)
5819
+ });
5820
+ configPushSchema = objectType({
5821
+ dialect: dialect3,
5822
+ schema: unionType([stringType(), stringType().array()]),
5823
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
5824
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
5825
+ verbose: booleanType().default(false),
5826
+ strict: booleanType().default(false)
5827
+ });
5828
+ mysqlConnectionSchema = unionType([
5829
+ objectType({
5830
+ host: stringType(),
5831
+ port: coerce.number().optional(),
5832
+ user: stringType().default("mysql"),
5833
+ password: stringType().optional(),
5834
+ database: stringType()
5835
+ // ssl: boolean().optional(),
5836
+ }),
5837
+ objectType({
5838
+ connectionString: stringType()
5839
+ }),
5840
+ objectType({})
5841
+ ]);
5842
+ mySqlCliConfigSchema = intersectionType(
5843
+ configCommonSchema,
5844
+ mysqlConnectionSchema
5845
+ );
5764
5846
  }
5765
5847
  });
5766
5848
 
@@ -5771,6 +5853,7 @@ var init_mysql = __esm({
5771
5853
  init_lib();
5772
5854
  init_utils();
5773
5855
  init_common();
5856
+ init_common();
5774
5857
  init_outputs();
5775
5858
  mysqlConnectionCli = unionType([
5776
5859
  objectType({
@@ -5839,12 +5922,8 @@ var init_mysql = __esm({
5839
5922
  }
5840
5923
  };
5841
5924
  validateMySqlIntrospect = async (options) => {
5842
- const collisionRes = checkCollisions(options, "introspect:mysql");
5843
- if (!collisionRes.success) {
5844
- console.log(collisionRes.message);
5845
- process.exit(1);
5846
- }
5847
- if (collisionRes.action === "config") {
5925
+ const action = assertCollisions(options, "introspect:mysql");
5926
+ if (action === "config") {
5848
5927
  const drizzleConfig = await readDrizzleConfig(options.config);
5849
5928
  const configRes = mysqlConfigIntrospectSchema.safeParse(drizzleConfig);
5850
5929
  if (!configRes.success) {
@@ -5889,6 +5968,7 @@ var init_pg = __esm({
5889
5968
  init_lib();
5890
5969
  init_utils();
5891
5970
  init_common();
5971
+ init_common();
5892
5972
  init_outputs();
5893
5973
  pgConnectionCli = unionType([
5894
5974
  objectType({
@@ -5963,12 +6043,8 @@ var init_pg = __esm({
5963
6043
  }
5964
6044
  };
5965
6045
  validatePgIntrospect = async (options) => {
5966
- const collisionRes = checkCollisions(options, "introspect:pg");
5967
- if (!collisionRes.success) {
5968
- console.log(collisionRes.message);
5969
- process.exit(1);
5970
- }
5971
- if (collisionRes.action === "config") {
6046
+ const action = assertCollisions(options, "introspect:pg");
6047
+ if (action === "config") {
5972
6048
  const drizzleConfig = await readDrizzleConfig(options.config);
5973
6049
  const configRes = pgConfigIntrospectSchema.safeParse(drizzleConfig);
5974
6050
  if (!configRes.success) {
@@ -6010,12 +6086,30 @@ var init_pg = __esm({
6010
6086
  }
6011
6087
  });
6012
6088
 
6013
- // src/cli/commands/sqliteUtils.ts
6014
- var sqliteConnectionSchema, sqliteCliConfigSchema;
6015
- var init_sqliteUtils = __esm({
6016
- "src/cli/commands/sqliteUtils.ts"() {
6089
+ // src/cli/validations/sqlite.ts
6090
+ var sqliteConnectionCli, sqliteConnectionSchema, sqliteCliConfigSchema, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams, printCliConnectionIssues3, printConfigConnectionIssues3, validateIntrospect;
6091
+ var init_sqlite = __esm({
6092
+ "src/cli/validations/sqlite.ts"() {
6017
6093
  init_lib();
6018
6094
  init_utils();
6095
+ init_common();
6096
+ init_common();
6097
+ init_outputs();
6098
+ sqliteConnectionCli = unionType([
6099
+ objectType({
6100
+ driver: literalType("turso"),
6101
+ url: stringType(),
6102
+ authToken: stringType()
6103
+ }),
6104
+ objectType({
6105
+ driver: literalType("better-sqlite"),
6106
+ url: stringType()
6107
+ }),
6108
+ objectType({
6109
+ driver: literalType("libsql"),
6110
+ url: stringType()
6111
+ })
6112
+ ]);
6019
6113
  sqliteConnectionSchema = unionType([
6020
6114
  objectType({
6021
6115
  driver: literalType("turso"),
@@ -6041,33 +6135,6 @@ var init_sqliteUtils = __esm({
6041
6135
  configIntrospectSchema,
6042
6136
  sqliteConnectionSchema
6043
6137
  );
6044
- }
6045
- });
6046
-
6047
- // src/cli/validations/sqlite.ts
6048
- var sqliteConnectionCli, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams, printCliConnectionIssues3, printConfigConnectionIssues3, validateIntrospect;
6049
- var init_sqlite = __esm({
6050
- "src/cli/validations/sqlite.ts"() {
6051
- init_lib();
6052
- init_sqliteUtils();
6053
- init_utils();
6054
- init_common();
6055
- init_outputs();
6056
- sqliteConnectionCli = unionType([
6057
- objectType({
6058
- driver: literalType("turso"),
6059
- url: stringType(),
6060
- authToken: stringType()
6061
- }),
6062
- objectType({
6063
- driver: literalType("better-sqlite"),
6064
- url: stringType()
6065
- }),
6066
- objectType({
6067
- driver: literalType("libsql"),
6068
- url: stringType()
6069
- })
6070
- ]);
6071
6138
  sqliteCliIntrospectParams = intersectionType(
6072
6139
  configIntrospectCliSchema,
6073
6140
  sqliteConnectionCli
@@ -6122,12 +6189,8 @@ var init_sqlite = __esm({
6122
6189
  }
6123
6190
  };
6124
6191
  validateIntrospect = async (options) => {
6125
- const collisionRes = checkCollisions(options, "introspect:sqlite");
6126
- if (!collisionRes.success) {
6127
- console.log(collisionRes.message);
6128
- process.exit(1);
6129
- }
6130
- if (collisionRes.action === "config") {
6192
+ const action = assertCollisions(options, "introspect:sqlite");
6193
+ if (action === "config") {
6131
6194
  const drizzleConfig = await readDrizzleConfig(options.config);
6132
6195
  const configRes = sqliteCliConfigSchema.safeParse(drizzleConfig);
6133
6196
  if (!configRes.success) {
@@ -11786,23 +11849,21 @@ var require_node2 = __commonJS({
11786
11849
  });
11787
11850
 
11788
11851
  // src/cli/commands/utils.ts
11789
- var import_path, import_fs, import_hanji2, assertES5, safeRegister, prepareGenerateConfig, preparePushConfig, assertOutFolder, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema, drizzleConfigFromFile, readDrizzleConfig;
11852
+ var import_path, import_fs, import_hanji2, assertES5, safeRegister, prepareGenerateConfig, preparePushConfig, assertOutFolder, drizzleConfigFromFile, readDrizzleConfig;
11790
11853
  var init_utils = __esm({
11791
11854
  "src/cli/commands/utils.ts"() {
11792
11855
  init_serializer();
11793
- init_lib();
11794
11856
  import_path = require("path");
11795
11857
  init_source();
11796
11858
  import_fs = require("fs");
11797
11859
  init_views();
11798
11860
  import_hanji2 = __toESM(require_hanji());
11799
- init_mysql();
11800
- init_pg();
11801
- init_sqlite();
11802
11861
  init_outputs();
11862
+ init_global();
11863
+ init_mysql();
11803
11864
  init_pg();
11804
11865
  init_sqlite();
11805
- init_global();
11866
+ init_common();
11806
11867
  assertES5 = async (unregister) => {
11807
11868
  try {
11808
11869
  init_es5();
@@ -11845,7 +11906,7 @@ var init_utils = __esm({
11845
11906
  return res;
11846
11907
  };
11847
11908
  prepareGenerateConfig = async (options) => {
11848
- const { schema: schema4, out, config, breakpoints, custom } = options;
11909
+ const { schema: schema4, out, config, breakpoints, custom, dialect: dialect7 } = options;
11849
11910
  if (!(schema4 && out)) {
11850
11911
  const drizzleConfig = await drizzleConfigFromFile(config);
11851
11912
  if (!drizzleConfig.out) {
@@ -11853,6 +11914,7 @@ var init_utils = __esm({
11853
11914
  process.exit(1);
11854
11915
  }
11855
11916
  return {
11917
+ dialect: drizzleConfig.dialect,
11856
11918
  custom,
11857
11919
  breakpoints: drizzleConfig.breakpoints ?? false,
11858
11920
  schema: drizzleConfig.schema,
@@ -11861,7 +11923,11 @@ var init_utils = __esm({
11861
11923
  };
11862
11924
  }
11863
11925
  if (!schema4) {
11864
- console.error(`'schema' param must be set`);
11926
+ console.error(`You have to provide 'schema' param`);
11927
+ process.exit(1);
11928
+ }
11929
+ if (!dialect7) {
11930
+ console.error(`You have to provide 'dialect' param`);
11865
11931
  process.exit(1);
11866
11932
  }
11867
11933
  const fileNames = prepareFilenames(schema4);
@@ -11873,14 +11939,21 @@ var init_utils = __esm({
11873
11939
  console.error(`'out' param must be set`);
11874
11940
  process.exit(1);
11875
11941
  }
11876
- return { schema: schema4, out, breakpoints, custom, bundle: false };
11942
+ return { dialect: dialect7, schema: schema4, out, breakpoints, custom, bundle: false };
11877
11943
  };
11878
11944
  preparePushConfig = async (options) => {
11879
11945
  let config;
11880
- const dialect7 = options.dialect;
11881
- const drizzleConfig = options.config ? await readDrizzleConfig(options.config) : options;
11946
+ const from = assertCollisions(options, "push");
11947
+ const drizzleConfig = from === "config" ? await readDrizzleConfig(options.config) : options;
11882
11948
  if (!drizzleConfig.schema) {
11883
- console.error(outputs.common.schema("push:mysql"));
11949
+ console.error(outputs.common.schema("push"));
11950
+ }
11951
+ const dialect7 = drizzleConfig.dialect;
11952
+ if (!dialect7) {
11953
+ console.log(
11954
+ `You have to provide 'dialect' in config file or as a CLI param`
11955
+ );
11956
+ process.exit(1);
11884
11957
  }
11885
11958
  if (dialect7 === "mysql") {
11886
11959
  const parsed = mysqlConfigPushParams.safeParse(drizzleConfig);
@@ -11929,78 +12002,6 @@ var init_utils = __esm({
11929
12002
  }
11930
12003
  return cliConfig.out;
11931
12004
  };
11932
- driver = unionType([
11933
- literalType("better-sqlite"),
11934
- literalType("turso"),
11935
- literalType("libsql"),
11936
- literalType("d1"),
11937
- literalType("expo"),
11938
- literalType("pg"),
11939
- literalType("mysql2")
11940
- ]);
11941
- configCommonSchema = objectType({
11942
- schema: unionType([stringType(), stringType().array()]),
11943
- out: stringType().optional(),
11944
- breakpoints: booleanType().default(true),
11945
- driver: driver.optional(),
11946
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11947
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
11948
- });
11949
- introspectCasing = objectType({
11950
- casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
11951
- }).default({ casing: "camel" });
11952
- configIntrospectSchema = objectType({
11953
- schema: unionType([stringType(), stringType().array()]).optional(),
11954
- out: stringType().optional().default("./drizzle"),
11955
- breakpoints: booleanType().default(true),
11956
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11957
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11958
- introspect: introspectCasing
11959
- });
11960
- configIntrospectCliSchema = objectType({
11961
- schema: unionType([stringType(), stringType().array()]).optional(),
11962
- out: stringType().optional().default("./drizzle"),
11963
- breakpoints: booleanType().default(true),
11964
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11965
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11966
- introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
11967
- "camel"
11968
- )
11969
- });
11970
- configGenerateSchema = objectType({
11971
- schema: unionType([stringType(), stringType().array()]),
11972
- out: stringType().optional().default("./drizzle"),
11973
- breakpoints: booleanType().default(true)
11974
- });
11975
- configPushSchema = objectType({
11976
- schema: unionType([stringType(), stringType().array()]),
11977
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11978
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11979
- verbose: booleanType().default(false),
11980
- strict: booleanType().default(false)
11981
- });
11982
- mysqlConnectionSchema = unionType([
11983
- objectType({
11984
- host: stringType(),
11985
- port: coerce.number().optional(),
11986
- user: stringType().default("mysql"),
11987
- password: stringType().optional(),
11988
- database: stringType()
11989
- // ssl: boolean().optional(),
11990
- }),
11991
- objectType({
11992
- connectionString: stringType()
11993
- }),
11994
- objectType({})
11995
- ]);
11996
- mySqlCliConfigSchema = intersectionType(
11997
- configCommonSchema,
11998
- mysqlConnectionSchema
11999
- );
12000
- mySqlIntrospectConfigSchema = intersectionType(
12001
- configIntrospectSchema,
12002
- mysqlConnectionSchema
12003
- );
12004
12005
  drizzleConfigFromFile = async (configPath) => {
12005
12006
  const defaultTsConfigExists = (0, import_fs.existsSync)((0, import_path.join)((0, import_path.resolve)("drizzle.config.ts")));
12006
12007
  const defaultJsConfigExists = (0, import_fs.existsSync)((0, import_path.join)((0, import_path.resolve)("drizzle.config.js")));
@@ -12130,7 +12131,7 @@ function clearDefaults(defaultValue, collate) {
12130
12131
  return `${resultDefault}`;
12131
12132
  }
12132
12133
  }
12133
- var import_mysql_core2, import_drizzle_orm2, import_mysql_core3, import_drizzle_orm3, dialect3, indexName, generateMySqlSnapshot, fromDatabase;
12134
+ var import_mysql_core2, import_drizzle_orm2, import_mysql_core3, import_drizzle_orm3, dialect4, indexName, generateMySqlSnapshot, fromDatabase;
12134
12135
  var init_mysqlSerializer = __esm({
12135
12136
  "src/serializer/mysqlSerializer.ts"() {
12136
12137
  import_mysql_core2 = require("drizzle-orm/mysql-core");
@@ -12140,7 +12141,7 @@ var init_mysqlSerializer = __esm({
12140
12141
  init_serializer();
12141
12142
  init_outputs();
12142
12143
  init_source();
12143
- dialect3 = new import_mysql_core2.MySqlDialect();
12144
+ dialect4 = new import_mysql_core2.MySqlDialect();
12144
12145
  indexName = (tableName, columns) => {
12145
12146
  return `${tableName}_${columns.join("_")}_index`;
12146
12147
  };
@@ -12297,7 +12298,7 @@ The unique constraint ${source_default.underline.blue(
12297
12298
  const name = value.config.name;
12298
12299
  let indexColumns = columns2.map((it) => {
12299
12300
  if ((0, import_drizzle_orm2.is)(it, import_drizzle_orm3.SQL)) {
12300
- return dialect3.sqlToQuery(it).sql;
12301
+ return dialect4.sqlToQuery(it).sql;
12301
12302
  } else {
12302
12303
  return it.name;
12303
12304
  }
@@ -12689,7 +12690,7 @@ __export(pgSerializer_exports, {
12689
12690
  generatePgSnapshot: () => generatePgSnapshot,
12690
12691
  indexName: () => indexName2
12691
12692
  });
12692
- var import_pg_core2, import_pg_core3, import_drizzle_orm5, dialect4, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
12693
+ var import_pg_core2, import_pg_core3, import_drizzle_orm5, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
12693
12694
  var init_pgSerializer = __esm({
12694
12695
  "src/serializer/pgSerializer.ts"() {
12695
12696
  import_pg_core2 = require("drizzle-orm/pg-core");
@@ -12698,7 +12699,7 @@ var init_pgSerializer = __esm({
12698
12699
  init_serializer();
12699
12700
  init_source();
12700
12701
  init_outputs();
12701
- dialect4 = new import_pg_core2.PgDialect();
12702
+ dialect5 = new import_pg_core2.PgDialect();
12702
12703
  indexName2 = (tableName, columns) => {
12703
12704
  return `${tableName}_${columns.join("_")}_index`;
12704
12705
  };
@@ -12827,7 +12828,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12827
12828
  const onUpdate = fk4.onUpdate;
12828
12829
  const reference = fk4.reference();
12829
12830
  const tableTo = (0, import_drizzle_orm5.getTableName)(reference.foreignTable);
12830
- const schemaTo = (0, import_pg_core3.getTableConfig)(reference.foreignTable).schema;
12831
+ const schemaTo = (0, import_pg_core3.getTableConfig)(reference.foreignTable).schema || "public";
12831
12832
  const columnsFrom = reference.columns.map((it) => it.name);
12832
12833
  const columnsTo = reference.foreignColumns.map((it) => it.name);
12833
12834
  return {
@@ -12853,7 +12854,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12853
12854
  );
12854
12855
  let indexColumns = columns2.map((it) => {
12855
12856
  if ((0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL)) {
12856
- return dialect4.sqlToQuery(it).sql;
12857
+ return dialect5.sqlToQuery(it).sql;
12857
12858
  } else {
12858
12859
  return it.name;
12859
12860
  }
@@ -13412,7 +13413,7 @@ function mapSqlToSqliteType(sqlType) {
13412
13413
  return "numeric";
13413
13414
  }
13414
13415
  }
13415
- var import_drizzle_orm7, import_sqlite_core2, dialect5, generateSqliteSnapshot, fromDatabase3;
13416
+ var import_drizzle_orm7, import_sqlite_core2, dialect6, generateSqliteSnapshot, fromDatabase3;
13416
13417
  var init_sqliteSerializer = __esm({
13417
13418
  "src/serializer/sqliteSerializer.ts"() {
13418
13419
  import_drizzle_orm7 = require("drizzle-orm");
@@ -13420,7 +13421,7 @@ var init_sqliteSerializer = __esm({
13420
13421
  init_serializer();
13421
13422
  init_outputs();
13422
13423
  init_source();
13423
- dialect5 = new import_sqlite_core2.SQLiteSyncDialect();
13424
+ dialect6 = new import_sqlite_core2.SQLiteSyncDialect();
13424
13425
  generateSqliteSnapshot = (tables, enums) => {
13425
13426
  const result = {};
13426
13427
  for (const table4 of tables) {
@@ -13509,7 +13510,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
13509
13510
  const name = value.config.name;
13510
13511
  let indexColumns = columns2.map((it) => {
13511
13512
  if ((0, import_drizzle_orm7.is)(it, import_drizzle_orm7.SQL)) {
13512
- return dialect5.sqlToQuery(it).sql;
13513
+ return dialect6.sqlToQuery(it).sql;
13513
13514
  } else {
13514
13515
  return it.name;
13515
13516
  }
@@ -13517,7 +13518,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
13517
13518
  let where = void 0;
13518
13519
  if (value.config.where !== void 0) {
13519
13520
  if ((0, import_drizzle_orm7.is)(value.config.where, import_drizzle_orm7.SQL)) {
13520
- where = dialect5.sqlToQuery(value.config.where).sql;
13521
+ where = dialect6.sqlToQuery(value.config.where).sql;
13521
13522
  }
13522
13523
  }
13523
13524
  indexesObject[name] = {
@@ -56077,7 +56078,7 @@ var init_mysqlIntrospect = __esm({
56077
56078
  init_mjs();
56078
56079
  init_drivers();
56079
56080
  connectToMySQL = async (config) => {
56080
- const client = await (0, import_promise.createConnection)(config.dbCredentials);
56081
+ const connection = await (0, import_promise.createConnection)(config.dbCredentials);
56081
56082
  let databaseName;
56082
56083
  if ("uri" in config.dbCredentials) {
56083
56084
  const connectionUrl = new URL(config.dbCredentials.uri);
@@ -56095,8 +56096,8 @@ var init_mysqlIntrospect = __esm({
56095
56096
  "Either `connectionString` or `host, port, etc.` params be provided in config file"
56096
56097
  );
56097
56098
  }
56098
- await client.connect();
56099
- return { client: new MySQL2Client(client), databaseName };
56099
+ await connection.connect();
56100
+ return { client: new MySQL2Client(connection), databaseName };
56100
56101
  };
56101
56102
  mysqlIntrospect = async (config, filters) => {
56102
56103
  const { client, databaseName } = await connectToMySQL(config);
@@ -60792,14 +60793,14 @@ var pgConnect_exports = {};
60792
60793
  __export(pgConnect_exports, {
60793
60794
  connectToPg: () => connectToPg
60794
60795
  });
60795
- var import_pg3, connectToPg;
60796
+ var import_pg2, connectToPg;
60796
60797
  var init_pgConnect = __esm({
60797
60798
  "src/cli/commands/pgConnect.ts"() {
60798
- import_pg3 = __toESM(require_lib4());
60799
+ import_pg2 = __toESM(require_lib4());
60799
60800
  init_drivers();
60800
60801
  connectToPg = async (config) => {
60801
60802
  if (config.driver === "pg") {
60802
- const client = new import_pg3.Client(config.dbCredentials);
60803
+ const client = new import_pg2.Client(config.dbCredentials);
60803
60804
  await client.connect();
60804
60805
  const connection = new PgPostgres(client);
60805
60806
  return { client: connection };
@@ -62232,7 +62233,6 @@ var init_studio = __esm({
62232
62233
  init_lib();
62233
62234
  init_pg();
62234
62235
  init_mysql();
62235
- init_sqliteUtils();
62236
62236
  init_utils();
62237
62237
  init_outputs();
62238
62238
  init_pg();
@@ -63088,24 +63088,8 @@ var certs = async () => {
63088
63088
  };
63089
63089
  certs();
63090
63090
 
63091
- // src/schemaValidator.ts
63092
- init_lib();
63093
- init_mysqlSchema();
63094
- init_pgSchema();
63095
- init_sqliteSchema();
63096
- var dialect6 = enumType(["pg", "mysql", "sqlite"]);
63097
- var commonSquashedSchema = unionType([
63098
- pgSchemaSquashed,
63099
- mysqlSchemaSquashed,
63100
- SQLiteSchemaSquashed
63101
- ]);
63102
- var commonSchema = unionType([
63103
- pgSchema,
63104
- mysqlSchema,
63105
- sqliteSchema
63106
- ]);
63107
-
63108
63091
  // src/cli/index.ts
63092
+ init_schemaValidator();
63109
63093
  var printVersions = async () => {
63110
63094
  const v = await versions();
63111
63095
  console.log(`${source_default.gray(v)}
@@ -63113,35 +63097,29 @@ var printVersions = async () => {
63113
63097
  };
63114
63098
  var versions = async () => {
63115
63099
  const { npmVersion } = await ormCoreVersions();
63116
- const ormVersion = npmVersion ? `
63117
- drizzle-orm: v${npmVersion}` : "";
63118
- const versions2 = `drizzle-kit: v${"0.20.14"}${ormVersion}`;
63100
+ const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
63101
+ const envVersion = "0.20.14";
63102
+ const kitVersion = envVersion ? `v${envVersion}` : "--";
63103
+ const versions2 = `drizzle-kit: ${kitVersion}
63104
+ ${ormVersion}`;
63119
63105
  return versions2;
63120
63106
  };
63121
- var optionsSchemaGenerate = objectType({
63122
- dialect: dialect6,
63107
+ var cliConfigGenerate = objectType({
63108
+ dialect: dialect3.optional(),
63123
63109
  schema: unionType([stringType(), stringType().array()]).optional(),
63124
63110
  out: stringType().optional().default("./drizzle"),
63125
63111
  config: stringType().optional(),
63126
63112
  breakpoints: booleanType().optional().default(true),
63127
63113
  custom: booleanType().optional().default(false)
63128
63114
  }).strict();
63129
- var generateCommand = new import_commander.Command("generate").option("--dialict <dialect>", "Database dialect [pg, mysql, sqlite]").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
63115
+ var generateCommand = new import_commander.Command("generate").option("--dialect <dialect>", "Database dialect [pg, mysql, sqlite]").option("--schema <schema...>", "Path to a schema file or folder").option("--out <out>", `Output folder, 'drizzle' by default`).option("--breakpoints", `Prepare SQL statements with breakpoints`).option("--custom", "Prepare empty migration file for custom SQL").option(
63130
63116
  "--config <config>",
63131
63117
  "Path to a config.json file, drizzle.config.ts by default"
63132
63118
  ).action(async (options) => {
63133
63119
  await printVersions();
63134
63120
  await assertOrmCoreVersion();
63135
- const collisionRes = checkCollisions(
63136
- options,
63137
- "generate",
63138
- ["custom"]
63139
- );
63140
- if (!collisionRes.success) {
63141
- console.log(collisionRes.message);
63142
- process.exit(1);
63143
- }
63144
- const parsed = optionsSchemaGenerate.parse(options);
63121
+ assertCollisions(options, "generate", ["custom"]);
63122
+ const parsed = cliConfigGenerate.parse(options);
63145
63123
  const result = await prepareGenerateConfig(parsed);
63146
63124
  await assertPackages("drizzle-orm");
63147
63125
  const {
@@ -63149,22 +63127,23 @@ var generateCommand = new import_commander.Command("generate").option("--dialict
63149
63127
  prepareAndMigrateMySql: prepareAndMigrateMySql2,
63150
63128
  prepareAndMigrateSqlite: prepareAndMigrateSqlite2
63151
63129
  } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
63152
- if (parsed.dialect === "pg") {
63130
+ const dialect7 = result.dialect;
63131
+ if (dialect7 === "pg") {
63153
63132
  await prepareAndMigratePg2(result);
63154
- } else if (parsed.dialect === "mysql") {
63133
+ } else if (dialect7 === "mysql") {
63155
63134
  await prepareAndMigrateMySql2(result);
63156
- } else if (parsed.dialect === "sqlite") {
63135
+ } else if (dialect7 === "sqlite") {
63157
63136
  await prepareAndMigrateSqlite2(result);
63158
63137
  } else {
63159
- assertUnreachable(parsed.dialect);
63138
+ assertUnreachable(dialect7);
63160
63139
  }
63161
63140
  });
63162
63141
  var cliParamsPush = objectType({
63163
63142
  config: stringType().optional(),
63164
- dialect: dialect6,
63143
+ dialect: dialect3.optional(),
63165
63144
  schema: unionType([stringType(), stringType().array()]).optional(),
63166
63145
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
63167
- driver: stringType(),
63146
+ driver: stringType().optional(),
63168
63147
  // mysql / pg
63169
63148
  connectionString: stringType().optional(),
63170
63149
  host: stringType().optional(),
@@ -63176,8 +63155,8 @@ var cliParamsPush = objectType({
63176
63155
  // turso / libsql / sqlite
63177
63156
  uri: stringType().optional(),
63178
63157
  authToken: stringType().optional(),
63179
- verbose: booleanType().default(false),
63180
- strict: booleanType().default(false)
63158
+ verbose: booleanType().optional(),
63159
+ strict: booleanType().optional()
63181
63160
  }).strict();
63182
63161
  var dbPushCommand = new import_commander.Command("push").option(
63183
63162
  "--config <config>",
@@ -63190,17 +63169,18 @@ var dbPushCommand = new import_commander.Command("push").option(
63190
63169
  const { config, tablesFilter, schemaFiles } = await preparePushConfig(
63191
63170
  cliParams
63192
63171
  );
63193
- if (cliParams.dialect === "mysql") {
63172
+ const dialect7 = config.dialect;
63173
+ if (dialect7 === "mysql") {
63194
63174
  const { mysqlPush: mysqlPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
63195
63175
  await mysqlPush2(config, tablesFilter);
63196
- } else if (cliParams.dialect === "pg") {
63176
+ } else if (dialect7 === "pg") {
63197
63177
  const { pgPush: pgPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
63198
63178
  await pgPush2(config, tablesFilter);
63199
- } else if (cliParams.dialect === "sqlite") {
63179
+ } else if (dialect7 === "sqlite") {
63200
63180
  const { sqlitePush: sqlitePush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
63201
63181
  await sqlitePush2(config, tablesFilter);
63202
63182
  } else {
63203
- assertUnreachable(cliParams.dialect);
63183
+ assertUnreachable(dialect7);
63204
63184
  }
63205
63185
  process.exit(0);
63206
63186
  });
@@ -63212,14 +63192,7 @@ var checkSchema = objectType({
63212
63192
  var checkPgCommand = new import_commander.Command("check:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63213
63193
  await printVersions();
63214
63194
  await assertOrmCoreVersion();
63215
- const collisionRes = checkCollisions(
63216
- options,
63217
- "check:pg"
63218
- );
63219
- if (!collisionRes.success) {
63220
- console.log(collisionRes.message);
63221
- process.exit(1);
63222
- }
63195
+ assertCollisions(options, "check:pg");
63223
63196
  const params = checkSchema.parse(options);
63224
63197
  const out = await assertOutFolder(params);
63225
63198
  checkHandler(out, "pg");
@@ -63228,14 +63201,7 @@ var checkPgCommand = new import_commander.Command("check:pg").option("--out <out
63228
63201
  var checkSqliteCommand = new import_commander.Command("check:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63229
63202
  await printVersions();
63230
63203
  await assertOrmCoreVersion();
63231
- const collisionRes = checkCollisions(
63232
- options,
63233
- "check:sqlite"
63234
- );
63235
- if (!collisionRes.success) {
63236
- console.log(collisionRes.message);
63237
- process.exit(1);
63238
- }
63204
+ assertCollisions(options, "check:sqlite");
63239
63205
  const params = checkSchema.parse(options);
63240
63206
  const out = await assertOutFolder(params);
63241
63207
  checkHandler(out, "sqlite");
@@ -63244,14 +63210,7 @@ var checkSqliteCommand = new import_commander.Command("check:sqlite").option("--
63244
63210
  var checkMySqlCommand = new import_commander.Command("check:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63245
63211
  await printVersions();
63246
63212
  await assertOrmCoreVersion();
63247
- const collisionRes = checkCollisions(
63248
- options,
63249
- "check:mysql"
63250
- );
63251
- if (!collisionRes.success) {
63252
- console.log(collisionRes.message);
63253
- process.exit(1);
63254
- }
63213
+ assertCollisions(options, "check:mysql");
63255
63214
  const params = checkSchema.parse(options);
63256
63215
  const out = await assertOutFolder(params);
63257
63216
  checkHandler(out, "mysql");
@@ -63260,14 +63219,7 @@ var checkMySqlCommand = new import_commander.Command("check:mysql").option("--ou
63260
63219
  var upPgCommand = new import_commander.Command("up:pg").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63261
63220
  await printVersions();
63262
63221
  await assertOrmCoreVersion();
63263
- const collisionRes = checkCollisions(
63264
- options,
63265
- "up:pg"
63266
- );
63267
- if (!collisionRes.success) {
63268
- console.log(collisionRes.message);
63269
- process.exit(1);
63270
- }
63222
+ assertCollisions(options, "up:pg");
63271
63223
  const params = checkSchema.parse(options);
63272
63224
  const out = await assertOutFolder(params);
63273
63225
  await assertPackages("drizzle-orm");
@@ -63278,14 +63230,7 @@ var upPgCommand = new import_commander.Command("up:pg").option("--out <out>", `O
63278
63230
  var upMysqlCommand = new import_commander.Command("up:mysql").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63279
63231
  await printVersions();
63280
63232
  await assertOrmCoreVersion();
63281
- const collisionRes = checkCollisions(
63282
- options,
63283
- "up:mysql"
63284
- );
63285
- if (!collisionRes.success) {
63286
- console.log(collisionRes.message);
63287
- process.exit(1);
63288
- }
63233
+ assertCollisions(options, "up:mysql");
63289
63234
  const params = checkSchema.parse(options);
63290
63235
  const out = await assertOutFolder(params);
63291
63236
  await assertPackages("drizzle-orm");
@@ -63296,14 +63241,7 @@ var upMysqlCommand = new import_commander.Command("up:mysql").option("--out <out
63296
63241
  var upSqliteCommand = new import_commander.Command("up:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63297
63242
  await printVersions();
63298
63243
  await assertOrmCoreVersion();
63299
- const collisionRes = checkCollisions(
63300
- options,
63301
- "up:sqlite"
63302
- );
63303
- if (!collisionRes.success) {
63304
- console.log(collisionRes.message);
63305
- process.exit(1);
63306
- }
63244
+ assertCollisions(options, "up:sqlite");
63307
63245
  const params = checkSchema.parse(options);
63308
63246
  const out = await assertOutFolder(params);
63309
63247
  upSqliteHandlerV4(out);
@@ -63476,14 +63414,7 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
63476
63414
  var dropCommand = new import_commander.Command("drop").option("--out <out>", `Output folder`).option("--driver <driver>", `Driver used for querying the database`).option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
63477
63415
  await printVersions();
63478
63416
  await assertOrmCoreVersion();
63479
- const collisionRes = checkCollisions(
63480
- options,
63481
- "drop"
63482
- );
63483
- if (!collisionRes.success) {
63484
- console.log(collisionRes.message);
63485
- process.exit(1);
63486
- }
63417
+ assertCollisions(options, "drop");
63487
63418
  const params = checkSchema.parse(options);
63488
63419
  const out = await assertOutFolder(params);
63489
63420
  let bundle = false;