drizzle-kit 0.20.5-fd4dd75 → 0.20.6-88f61dc

Sign up to get free protection for your applications and to get access to all the features.
package/utils.js CHANGED
@@ -11888,10 +11888,9 @@ var pgSerializer_exports = {};
11888
11888
  __export(pgSerializer_exports, {
11889
11889
  fromDatabase: () => fromDatabase2,
11890
11890
  generatePgSnapshot: () => generatePgSnapshot,
11891
- indexName: () => indexName2,
11892
- toDrizzle: () => toDrizzle
11891
+ indexName: () => indexName2
11893
11892
  });
11894
- var import_pg_core2, import_pg_core3, import_drizzle_orm5, dialect4, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn, toDrizzle;
11893
+ var import_pg_core2, import_pg_core3, import_drizzle_orm5, dialect4, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
11895
11894
  var init_pgSerializer = __esm({
11896
11895
  "src/serializer/pgSerializer.ts"() {
11897
11896
  import_pg_core2 = require("drizzle-orm/pg-core");
@@ -12502,108 +12501,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
12502
12501
  }
12503
12502
  }
12504
12503
  };
12505
- toDrizzle = (schema4, schemaName) => {
12506
- const tables = {};
12507
- Object.values(schema4.tables).forEach((t) => {
12508
- const columns = {};
12509
- Object.values(t.columns).forEach((c) => {
12510
- const columnName = c.name;
12511
- const type = c.type;
12512
- let columnBuilder;
12513
- if (type === "bigint") {
12514
- columnBuilder = new import_pg_core2.PgBigInt53Builder(columnName);
12515
- } else if (type === "bigserial") {
12516
- columnBuilder = new import_pg_core2.PgBigSerial53Builder(columnName);
12517
- } else if (type === "boolean") {
12518
- columnBuilder = new import_pg_core2.PgBooleanBuilder(columnName);
12519
- } else if (type === "cidr") {
12520
- columnBuilder = new import_pg_core2.PgCidrBuilder(columnName);
12521
- } else if (type === "date") {
12522
- columnBuilder = new import_pg_core2.PgDateBuilder(columnName);
12523
- } else if (type === "double precision") {
12524
- columnBuilder = new import_pg_core2.PgDoublePrecisionBuilder(columnName);
12525
- } else if (type === "inet") {
12526
- columnBuilder = new import_pg_core2.PgInetBuilder(columnName);
12527
- } else if (type === "integer") {
12528
- columnBuilder = new import_pg_core2.PgIntegerBuilder(columnName);
12529
- } else if (type === "interval" || type.startsWith("interval ")) {
12530
- columnBuilder = new import_pg_core2.PgIntervalBuilder(columnName, {});
12531
- } else if (type === "json") {
12532
- columnBuilder = new import_pg_core2.PgJsonBuilder(columnName);
12533
- } else if (type === "jsonb") {
12534
- columnBuilder = new import_pg_core2.PgJsonbBuilder(columnName);
12535
- } else if (type === "macaddr") {
12536
- columnBuilder = new import_pg_core2.PgMacaddrBuilder(columnName);
12537
- } else if (type === "macaddr8") {
12538
- columnBuilder = new import_pg_core2.PgMacaddr8Builder(columnName);
12539
- } else if (type === "numeric" || type.startsWith("numeric(")) {
12540
- columnBuilder = new import_pg_core2.PgNumericBuilder(columnName);
12541
- } else if (type === "real") {
12542
- columnBuilder = new import_pg_core2.PgRealBuilder(columnName);
12543
- } else if (type === "serial") {
12544
- columnBuilder = new import_pg_core2.PgSerialBuilder(columnName);
12545
- } else if (type === "smallint") {
12546
- columnBuilder = new import_pg_core2.PgSmallIntBuilder(columnName);
12547
- } else if (type === "smallserial") {
12548
- columnBuilder = new import_pg_core2.PgSmallSerialBuilder(columnName);
12549
- } else if (type === "text") {
12550
- columnBuilder = new import_pg_core2.PgTextBuilder(columnName, {});
12551
- } else if (type === "time" || type.startsWith("time(") || type === "time with time zone") {
12552
- columnBuilder = new import_pg_core2.PgTimeBuilder(columnName, false, void 0);
12553
- } else if (type === "timestamp" || type.startsWith("timestamp(") || type === "timestamp with time zone") {
12554
- columnBuilder = new import_pg_core2.PgTimestampBuilder(columnName, false, void 0);
12555
- } else if (type === "uuid") {
12556
- columnBuilder = new import_pg_core2.PgUUIDBuilder(columnName);
12557
- } else if (type === "varchar" || type.startsWith("varchar(")) {
12558
- columnBuilder = new import_pg_core2.PgVarcharBuilder(columnName, {});
12559
- } else if (type === "char" || type.startsWith("char(")) {
12560
- columnBuilder = new import_pg_core2.PgCharBuilder(columnName, {});
12561
- } else {
12562
- columnBuilder = (0, import_pg_core2.customType)({
12563
- dataType() {
12564
- return type;
12565
- }
12566
- })(columnName);
12567
- }
12568
- if (c.notNull) {
12569
- columnBuilder = columnBuilder.notNull();
12570
- }
12571
- if (c.default) {
12572
- columnBuilder = columnBuilder.default(c.default);
12573
- }
12574
- if (c.primaryKey) {
12575
- columnBuilder = columnBuilder.primaryKey();
12576
- }
12577
- columns[columnName] = columnBuilder;
12578
- });
12579
- if (schemaName === "public") {
12580
- tables[t.name] = (0, import_pg_core2.pgTable)(t.name, columns, (cb) => {
12581
- const res = {};
12582
- Object.values(t.compositePrimaryKeys).forEach((cpk) => {
12583
- const gh = cpk.columns.map((c) => cb[c]);
12584
- res[cpk.name] = new import_pg_core2.PrimaryKeyBuilder(
12585
- gh,
12586
- cpk.name
12587
- );
12588
- });
12589
- return res;
12590
- });
12591
- } else {
12592
- tables[t.name] = (0, import_pg_core2.pgSchema)(schemaName).table(t.name, columns, (cb) => {
12593
- const res = {};
12594
- Object.values(t.compositePrimaryKeys).forEach((cpk) => {
12595
- const gh = cpk.columns.map((c) => cb[c]);
12596
- res[cpk.name] = new import_pg_core2.PrimaryKeyBuilder(
12597
- gh,
12598
- cpk.name
12599
- );
12600
- });
12601
- return res;
12602
- });
12603
- }
12604
- });
12605
- return tables;
12606
- };
12607
12504
  }
12608
12505
  });
12609
12506
 
@@ -12642,8 +12539,7 @@ var init_sqliteImports = __esm({
12642
12539
  var sqliteSerializer_exports = {};
12643
12540
  __export(sqliteSerializer_exports, {
12644
12541
  fromDatabase: () => fromDatabase3,
12645
- generateSqliteSnapshot: () => generateSqliteSnapshot,
12646
- toDrizzle: () => toDrizzle2
12542
+ generateSqliteSnapshot: () => generateSqliteSnapshot
12647
12543
  });
12648
12544
  function mapSqlToSqliteType(sqlType) {
12649
12545
  if ([
@@ -12680,7 +12576,7 @@ function mapSqlToSqliteType(sqlType) {
12680
12576
  return "numeric";
12681
12577
  }
12682
12578
  }
12683
- var import_drizzle_orm7, import_sqlite_core2, dialect5, generateSqliteSnapshot, fromDatabase3, toDrizzle2;
12579
+ var import_drizzle_orm7, import_sqlite_core2, dialect5, generateSqliteSnapshot, fromDatabase3;
12684
12580
  var init_sqliteSerializer = __esm({
12685
12581
  "src/serializer/sqliteSerializer.ts"() {
12686
12582
  import_drizzle_orm7 = require("drizzle-orm");
@@ -13048,50 +12944,6 @@ WHERE
13048
12944
  }
13049
12945
  };
13050
12946
  };
13051
- toDrizzle2 = (schema4) => {
13052
- const tables = {};
13053
- Object.values(schema4.tables).forEach((t) => {
13054
- const columns = {};
13055
- Object.values(t.columns).forEach((c) => {
13056
- const columnName = c.name;
13057
- const type = c.type;
13058
- let columnBuilder;
13059
- if (type === "integer") {
13060
- columnBuilder = new import_sqlite_core2.SQLiteIntegerBuilder(columnName);
13061
- } else if (type === "text") {
13062
- columnBuilder = new import_sqlite_core2.SQLiteTextBuilder(columnName, {});
13063
- } else if (type === "blob") {
13064
- columnBuilder = new import_sqlite_core2.SQLiteBlobBufferBuilder(columnName);
13065
- } else if (type === "real") {
13066
- columnBuilder = new import_sqlite_core2.SQLiteRealBuilder(columnName);
13067
- } else {
13068
- columnBuilder = new import_sqlite_core2.SQLiteNumericBuilder(columnName);
13069
- }
13070
- if (c.notNull) {
13071
- columnBuilder = columnBuilder.notNull();
13072
- }
13073
- if (c.default) {
13074
- columnBuilder = columnBuilder.default(c.default);
13075
- }
13076
- if (c.primaryKey) {
13077
- columnBuilder = columnBuilder.primaryKey();
13078
- }
13079
- columns[columnName] = columnBuilder;
13080
- });
13081
- tables[t.name] = (0, import_sqlite_core2.sqliteTable)(t.name, columns, (cb) => {
13082
- const res = {};
13083
- Object.values(t.compositePrimaryKeys).forEach((cpk) => {
13084
- const gh = cpk.columns.map((c) => cb[c]);
13085
- res[cpk.name] = new import_sqlite_core2.PrimaryKeyBuilder(
13086
- gh,
13087
- cpk.name
13088
- );
13089
- });
13090
- return res;
13091
- });
13092
- });
13093
- return tables;
13094
- };
13095
12947
  }
13096
12948
  });
13097
12949
 
@@ -24858,6 +24710,161 @@ var init_sqliteIntrospect = __esm({
24858
24710
  }
24859
24711
  });
24860
24712
 
24713
+ // src/serializer/schemaToDrizzle.ts
24714
+ var import_pg_core4, import_sqlite_core3, pgSchemaToDrizzle, sqliteSchemaToDrizzle;
24715
+ var init_schemaToDrizzle = __esm({
24716
+ "src/serializer/schemaToDrizzle.ts"() {
24717
+ import_pg_core4 = require("drizzle-orm/pg-core");
24718
+ import_sqlite_core3 = require("drizzle-orm/sqlite-core");
24719
+ pgSchemaToDrizzle = (schema4, schemaName) => {
24720
+ const tables = {};
24721
+ Object.values(schema4.tables).forEach((t) => {
24722
+ const columns = {};
24723
+ Object.values(t.columns).forEach((c) => {
24724
+ const columnName = c.name;
24725
+ const type = c.type;
24726
+ let columnBuilder;
24727
+ if (type === "bigint") {
24728
+ columnBuilder = new import_pg_core4.PgBigInt53Builder(columnName);
24729
+ } else if (type === "bigserial") {
24730
+ columnBuilder = new import_pg_core4.PgBigSerial53Builder(columnName);
24731
+ } else if (type === "boolean") {
24732
+ columnBuilder = new import_pg_core4.PgBooleanBuilder(columnName);
24733
+ } else if (type === "cidr") {
24734
+ columnBuilder = new import_pg_core4.PgCidrBuilder(columnName);
24735
+ } else if (type === "date") {
24736
+ columnBuilder = new import_pg_core4.PgDateBuilder(columnName);
24737
+ } else if (type === "double precision") {
24738
+ columnBuilder = new import_pg_core4.PgDoublePrecisionBuilder(columnName);
24739
+ } else if (type === "inet") {
24740
+ columnBuilder = new import_pg_core4.PgInetBuilder(columnName);
24741
+ } else if (type === "integer") {
24742
+ columnBuilder = new import_pg_core4.PgIntegerBuilder(columnName);
24743
+ } else if (type === "interval" || type.startsWith("interval ")) {
24744
+ columnBuilder = new import_pg_core4.PgIntervalBuilder(columnName, {});
24745
+ } else if (type === "json") {
24746
+ columnBuilder = new import_pg_core4.PgJsonBuilder(columnName);
24747
+ } else if (type === "jsonb") {
24748
+ columnBuilder = new import_pg_core4.PgJsonbBuilder(columnName);
24749
+ } else if (type === "macaddr") {
24750
+ columnBuilder = new import_pg_core4.PgMacaddrBuilder(columnName);
24751
+ } else if (type === "macaddr8") {
24752
+ columnBuilder = new import_pg_core4.PgMacaddr8Builder(columnName);
24753
+ } else if (type === "numeric" || type.startsWith("numeric(")) {
24754
+ columnBuilder = new import_pg_core4.PgNumericBuilder(columnName);
24755
+ } else if (type === "real") {
24756
+ columnBuilder = new import_pg_core4.PgRealBuilder(columnName);
24757
+ } else if (type === "serial") {
24758
+ columnBuilder = new import_pg_core4.PgSerialBuilder(columnName);
24759
+ } else if (type === "smallint") {
24760
+ columnBuilder = new import_pg_core4.PgSmallIntBuilder(columnName);
24761
+ } else if (type === "smallserial") {
24762
+ columnBuilder = new import_pg_core4.PgSmallSerialBuilder(columnName);
24763
+ } else if (type === "text") {
24764
+ columnBuilder = new import_pg_core4.PgTextBuilder(columnName, {});
24765
+ } else if (type === "time" || type.startsWith("time(") || type === "time with time zone") {
24766
+ columnBuilder = new import_pg_core4.PgTimeBuilder(columnName, false, void 0);
24767
+ } else if (type === "timestamp" || type.startsWith("timestamp(") || type === "timestamp with time zone") {
24768
+ columnBuilder = new import_pg_core4.PgTimestampBuilder(columnName, false, void 0);
24769
+ } else if (type === "uuid") {
24770
+ columnBuilder = new import_pg_core4.PgUUIDBuilder(columnName);
24771
+ } else if (type === "varchar" || type.startsWith("varchar(")) {
24772
+ columnBuilder = new import_pg_core4.PgVarcharBuilder(columnName, {});
24773
+ } else if (type === "char" || type.startsWith("char(")) {
24774
+ columnBuilder = new import_pg_core4.PgCharBuilder(columnName, {});
24775
+ } else {
24776
+ columnBuilder = (0, import_pg_core4.customType)({
24777
+ dataType() {
24778
+ return type;
24779
+ }
24780
+ })(columnName);
24781
+ }
24782
+ if (c.notNull) {
24783
+ columnBuilder = columnBuilder.notNull();
24784
+ }
24785
+ if (c.default) {
24786
+ columnBuilder = columnBuilder.default(c.default);
24787
+ }
24788
+ if (c.primaryKey) {
24789
+ columnBuilder = columnBuilder.primaryKey();
24790
+ }
24791
+ columns[columnName] = columnBuilder;
24792
+ });
24793
+ if (schemaName === "public") {
24794
+ tables[t.name] = (0, import_pg_core4.pgTable)(t.name, columns, (cb) => {
24795
+ const res = {};
24796
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
24797
+ const gh = cpk.columns.map((c) => cb[c]);
24798
+ res[cpk.name] = new import_pg_core4.PrimaryKeyBuilder(
24799
+ gh,
24800
+ cpk.name
24801
+ );
24802
+ });
24803
+ return res;
24804
+ });
24805
+ } else {
24806
+ tables[t.name] = (0, import_pg_core4.pgSchema)(schemaName).table(t.name, columns, (cb) => {
24807
+ const res = {};
24808
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
24809
+ const gh = cpk.columns.map((c) => cb[c]);
24810
+ res[cpk.name] = new import_pg_core4.PrimaryKeyBuilder(
24811
+ gh,
24812
+ cpk.name
24813
+ );
24814
+ });
24815
+ return res;
24816
+ });
24817
+ }
24818
+ });
24819
+ return tables;
24820
+ };
24821
+ sqliteSchemaToDrizzle = (schema4) => {
24822
+ const tables = {};
24823
+ Object.values(schema4.tables).forEach((t) => {
24824
+ const columns = {};
24825
+ Object.values(t.columns).forEach((c) => {
24826
+ const columnName = c.name;
24827
+ const type = c.type;
24828
+ let columnBuilder;
24829
+ if (type === "integer") {
24830
+ columnBuilder = new import_sqlite_core3.SQLiteIntegerBuilder(columnName);
24831
+ } else if (type === "text") {
24832
+ columnBuilder = new import_sqlite_core3.SQLiteTextBuilder(columnName, {});
24833
+ } else if (type === "blob") {
24834
+ columnBuilder = new import_sqlite_core3.SQLiteBlobBufferBuilder(columnName);
24835
+ } else if (type === "real") {
24836
+ columnBuilder = new import_sqlite_core3.SQLiteRealBuilder(columnName);
24837
+ } else {
24838
+ columnBuilder = new import_sqlite_core3.SQLiteNumericBuilder(columnName);
24839
+ }
24840
+ if (c.notNull) {
24841
+ columnBuilder = columnBuilder.notNull();
24842
+ }
24843
+ if (c.default) {
24844
+ columnBuilder = columnBuilder.default(c.default);
24845
+ }
24846
+ if (c.primaryKey) {
24847
+ columnBuilder = columnBuilder.primaryKey();
24848
+ }
24849
+ columns[columnName] = columnBuilder;
24850
+ });
24851
+ tables[t.name] = (0, import_sqlite_core3.sqliteTable)(t.name, columns, (cb) => {
24852
+ const res = {};
24853
+ Object.values(t.compositePrimaryKeys).forEach((cpk) => {
24854
+ const gh = cpk.columns.map((c) => cb[c]);
24855
+ res[cpk.name] = new import_sqlite_core3.PrimaryKeyBuilder(
24856
+ gh,
24857
+ cpk.name
24858
+ );
24859
+ });
24860
+ return res;
24861
+ });
24862
+ });
24863
+ return tables;
24864
+ };
24865
+ }
24866
+ });
24867
+
24861
24868
  // node_modules/.pnpm/semver@7.5.4/node_modules/semver/internal/constants.js
24862
24869
  var require_constants = __commonJS({
24863
24870
  "node_modules/.pnpm/semver@7.5.4/node_modules/semver/internal/constants.js"(exports, module2) {
@@ -43201,15 +43208,15 @@ var require_promise = __commonJS({
43201
43208
  });
43202
43209
 
43203
43210
  // src/orm-extenstions/d1-driver/session.ts
43204
- var import_drizzle_orm10, import_drizzle_orm11, import_drizzle_orm12, import_sqlite_core3, import_drizzle_orm13, _a, SQLiteWranglerD1Session, _a2, PreparedQuery;
43211
+ var import_drizzle_orm10, import_drizzle_orm11, import_drizzle_orm12, import_sqlite_core4, import_drizzle_orm13, _a, SQLiteWranglerD1Session, _a2, PreparedQuery;
43205
43212
  var init_session = __esm({
43206
43213
  "src/orm-extenstions/d1-driver/session.ts"() {
43207
43214
  import_drizzle_orm10 = require("drizzle-orm");
43208
43215
  import_drizzle_orm11 = require("drizzle-orm");
43209
43216
  import_drizzle_orm12 = require("drizzle-orm");
43210
- import_sqlite_core3 = require("drizzle-orm/sqlite-core");
43217
+ import_sqlite_core4 = require("drizzle-orm/sqlite-core");
43211
43218
  import_drizzle_orm13 = require("drizzle-orm");
43212
- SQLiteWranglerD1Session = class extends import_sqlite_core3.SQLiteSession {
43219
+ SQLiteWranglerD1Session = class extends import_sqlite_core4.SQLiteSession {
43213
43220
  constructor(client, configPath, dbName, dialect6, schema4, options = {}) {
43214
43221
  super(dialect6);
43215
43222
  this.client = client;
@@ -43238,7 +43245,7 @@ var init_session = __esm({
43238
43245
  };
43239
43246
  _a = import_drizzle_orm10.entityKind;
43240
43247
  SQLiteWranglerD1Session[_a] = "SQLiteD1Session";
43241
- PreparedQuery = class extends import_sqlite_core3.SQLitePreparedQuery {
43248
+ PreparedQuery = class extends import_sqlite_core4.SQLitePreparedQuery {
43242
43249
  constructor(stmt, configPath, dbName, queryString, params, logger, fields, executeMethod, customResultMapper) {
43243
43250
  super("async", executeMethod, {
43244
43251
  sql: queryString,
@@ -43363,20 +43370,20 @@ function drizzle(client, configPath, dbName, config = {}) {
43363
43370
  const session = new SQLiteWranglerD1Session(client, configPath, dbName, dialect6, schema4, {
43364
43371
  logger
43365
43372
  });
43366
- return new import_sqlite_core4.BaseSQLiteDatabase(
43373
+ return new import_sqlite_core5.BaseSQLiteDatabase(
43367
43374
  "async",
43368
43375
  dialect6,
43369
43376
  session,
43370
43377
  schema4
43371
43378
  );
43372
43379
  }
43373
- var import_drizzle_orm14, import_sqlite_core4, WranglerDialect;
43380
+ var import_drizzle_orm14, import_sqlite_core5, WranglerDialect;
43374
43381
  var init_driver = __esm({
43375
43382
  "src/orm-extenstions/d1-driver/driver.ts"() {
43376
43383
  import_drizzle_orm14 = require("drizzle-orm");
43377
- import_sqlite_core4 = require("drizzle-orm/sqlite-core");
43384
+ import_sqlite_core5 = require("drizzle-orm/sqlite-core");
43378
43385
  init_session();
43379
- WranglerDialect = class extends import_sqlite_core4.SQLiteAsyncDialect {
43386
+ WranglerDialect = class extends import_sqlite_core5.SQLiteAsyncDialect {
43380
43387
  sqlToQuery(sql2) {
43381
43388
  return sql2.toQuery({
43382
43389
  escapeName: this.escapeName,
@@ -58692,13 +58699,13 @@ var init_wrangler_client = __esm({
58692
58699
  });
58693
58700
 
58694
58701
  // src/serializer/studioUtils.ts
58695
- var import_drizzle_orm15, import_mysql_core4, import_pg_core4, import_sqlite_core5, drizzleDb;
58702
+ var import_drizzle_orm15, import_mysql_core4, import_pg_core5, import_sqlite_core6, drizzleDb;
58696
58703
  var init_studioUtils = __esm({
58697
58704
  "src/serializer/studioUtils.ts"() {
58698
58705
  import_drizzle_orm15 = require("drizzle-orm");
58699
58706
  import_mysql_core4 = require("drizzle-orm/mysql-core");
58700
- import_pg_core4 = require("drizzle-orm/pg-core");
58701
- import_sqlite_core5 = require("drizzle-orm/sqlite-core");
58707
+ import_pg_core5 = require("drizzle-orm/pg-core");
58708
+ import_sqlite_core6 = require("drizzle-orm/sqlite-core");
58702
58709
  init_utils();
58703
58710
  init_utils3();
58704
58711
  init_global();
@@ -58807,8 +58814,7 @@ var init_utils5 = __esm({
58807
58814
  init_pgIntrospect();
58808
58815
  init_pgPushUtils();
58809
58816
  init_sqliteIntrospect();
58810
- init_sqliteSerializer();
58811
- init_pgSerializer();
58817
+ init_schemaToDrizzle();
58812
58818
  init_studioUtils();
58813
58819
  init_pgConnect();
58814
58820
  assertV1OutFolder = (out, dialect6) => {
@@ -59127,7 +59133,7 @@ var init_utils5 = __esm({
59127
59133
  preparedConnection.client,
59128
59134
  []
59129
59135
  );
59130
- const models = toDrizzle2(schema4);
59136
+ const models = sqliteSchemaToDrizzle(schema4);
59131
59137
  const drizzleDbInstance = await drizzleDb(
59132
59138
  connection,
59133
59139
  { sqliteSchema: models },
@@ -59152,7 +59158,7 @@ var init_utils5 = __esm({
59152
59158
  [],
59153
59159
  [schemaName]
59154
59160
  );
59155
- const models = toDrizzle(schema4, schemaName);
59161
+ const models = pgSchemaToDrizzle(schema4, schemaName);
59156
59162
  response[schemaName] = await drizzleDb(
59157
59163
  // @ts-ignore I don't know how to fix it yet. But will find a way
59158
59164
  connection,