drizzle-kit 0.26.2 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (10) hide show
  1. package/api.d.mts +170 -8
  2. package/api.d.ts +170 -8
  3. package/api.js +2453 -1178
  4. package/api.mjs +2453 -1178
  5. package/bin.cjs +1749 -410
  6. package/index.d.mts +7 -0
  7. package/index.d.ts +7 -0
  8. package/package.json +6 -6
  9. package/utils.js +32 -11
  10. package/utils.mjs +32 -10
package/bin.cjs CHANGED
@@ -1075,7 +1075,7 @@ var require_hanji = __commonJS({
1075
1075
  });
1076
1076
 
1077
1077
  // src/cli/views.ts
1078
- var import_hanji, warning, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, MigrateProgress, ProgressView, DropMigrationView, trimmedRange;
1078
+ var import_hanji, warning, err, info, grey, error, schema, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelectNamed, ResolveSelect, ResolveSchemasSelect, Spinner, IntrospectProgress, MigrateProgress, ProgressView, DropMigrationView, trimmedRange;
1079
1079
  var init_views = __esm({
1080
1080
  "src/cli/views.ts"() {
1081
1081
  "use strict";
@@ -1178,6 +1178,53 @@ Is ${source_default.bold.blue(
1178
1178
  tableKey = (it) => {
1179
1179
  return it.schema === "public" || !it.schema ? it.name : `${it.schema}.${it.name}`;
1180
1180
  };
1181
+ ResolveSelectNamed = class extends import_hanji.Prompt {
1182
+ constructor(base, data, entityType) {
1183
+ super();
1184
+ this.base = base;
1185
+ this.entityType = entityType;
1186
+ this.on("attach", (terminal) => terminal.toggleCursor("hide"));
1187
+ this.state = new import_hanji.SelectState(data);
1188
+ this.state.bind(this);
1189
+ this.base = base;
1190
+ }
1191
+ render(status) {
1192
+ if (status === "submitted" || status === "aborted") {
1193
+ return "";
1194
+ }
1195
+ const key = this.base.name;
1196
+ let text = `
1197
+ Is ${source_default.bold.blue(key)} ${this.entityType} created or renamed from another ${this.entityType}?
1198
+ `;
1199
+ const isSelectedRenamed = isRenamePromptItem(
1200
+ this.state.items[this.state.selectedIdx]
1201
+ );
1202
+ const selectedPrefix = isSelectedRenamed ? source_default.yellow("\u276F ") : source_default.green("\u276F ");
1203
+ const labelLength = this.state.items.filter((it) => isRenamePromptItem(it)).map((_2) => {
1204
+ const it = _2;
1205
+ const keyFrom = it.from.name;
1206
+ return key.length + 3 + keyFrom.length;
1207
+ }).reduce((a, b) => {
1208
+ if (a > b) {
1209
+ return a;
1210
+ }
1211
+ return b;
1212
+ }, 0);
1213
+ const entityType = this.entityType;
1214
+ this.state.items.forEach((it, idx) => {
1215
+ const isSelected = idx === this.state.selectedIdx;
1216
+ const isRenamed = isRenamePromptItem(it);
1217
+ const title = isRenamed ? `${it.from.name} \u203A ${it.to.name}`.padEnd(labelLength, " ") : it.name.padEnd(labelLength, " ");
1218
+ const label = isRenamed ? `${source_default.yellow("~")} ${title} ${source_default.gray(`rename ${entityType}`)}` : `${source_default.green("+")} ${title} ${source_default.gray(`create ${entityType}`)}`;
1219
+ text += isSelected ? `${selectedPrefix}${label}` : ` ${label}`;
1220
+ text += idx != this.state.items.length - 1 ? "\n" : "";
1221
+ });
1222
+ return text;
1223
+ }
1224
+ result() {
1225
+ return this.state.items[this.state.selectedIdx];
1226
+ }
1227
+ };
1181
1228
  ResolveSelect = class extends import_hanji.Prompt {
1182
1229
  constructor(base, data, entityType) {
1183
1230
  super();
@@ -1316,6 +1363,11 @@ Is ${source_default.bold.blue(
1316
1363
  name: "foreign keys",
1317
1364
  status: "fetching"
1318
1365
  },
1366
+ policies: {
1367
+ count: 0,
1368
+ name: "policies",
1369
+ status: "fetching"
1370
+ },
1319
1371
  checks: {
1320
1372
  count: 0,
1321
1373
  name: "check constraints",
@@ -1362,6 +1414,7 @@ Is ${source_default.bold.blue(
1362
1414
  info2 += this.hasEnums ? this.statusText(spin, this.state.enums) : "";
1363
1415
  info2 += this.statusText(spin, this.state.indexes);
1364
1416
  info2 += this.statusText(spin, this.state.fks);
1417
+ info2 += this.statusText(spin, this.state.policies);
1365
1418
  info2 += this.statusText(spin, this.state.checks);
1366
1419
  info2 += this.statusText(spin, this.state.views);
1367
1420
  return info2;
@@ -1748,8 +1801,8 @@ var init_lib = __esm({
1748
1801
  return void 0;
1749
1802
  };
1750
1803
  util2.isInteger = typeof Number.isInteger === "function" ? (val2) => Number.isInteger(val2) : (val2) => typeof val2 === "number" && isFinite(val2) && Math.floor(val2) === val2;
1751
- function joinValues(array, separator = " | ") {
1752
- return array.map((val2) => typeof val2 === "string" ? `'${val2}'` : val2).join(separator);
1804
+ function joinValues(array2, separator = " | ") {
1805
+ return array2.map((val2) => typeof val2 === "string" ? `'${val2}'` : val2).join(separator);
1753
1806
  }
1754
1807
  util2.joinValues = joinValues;
1755
1808
  util2.jsonStringifyReplacer = (_2, value) => {
@@ -5779,7 +5832,7 @@ var init_vector = __esm({
5779
5832
  });
5780
5833
 
5781
5834
  // src/serializer/pgSchema.ts
5782
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, viewWithOption, matViewWithOption, mergedViewWithOption, view2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
5835
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, roleSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
5783
5836
  var init_pgSchema = __esm({
5784
5837
  "src/serializer/pgSchema.ts"() {
5785
5838
  "use strict";
@@ -5911,6 +5964,12 @@ var init_pgSchema = __esm({
5911
5964
  cycle: booleanType().optional(),
5912
5965
  schema: stringType()
5913
5966
  }).strict();
5967
+ roleSchema = objectType({
5968
+ name: stringType(),
5969
+ createDb: booleanType().optional(),
5970
+ createRole: booleanType().optional(),
5971
+ inherit: booleanType().optional()
5972
+ }).strict();
5914
5973
  sequenceSquashed = objectType({
5915
5974
  name: stringType(),
5916
5975
  schema: stringType(),
@@ -5978,6 +6037,19 @@ var init_pgSchema = __esm({
5978
6037
  columns: stringType().array(),
5979
6038
  nullsNotDistinct: booleanType()
5980
6039
  }).strict();
6040
+ policy = objectType({
6041
+ name: stringType(),
6042
+ as: enumType(["PERMISSIVE", "RESTRICTIVE"]).optional(),
6043
+ for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
6044
+ to: stringType().array().optional(),
6045
+ using: stringType().optional(),
6046
+ withCheck: stringType().optional(),
6047
+ on: stringType().optional()
6048
+ }).strict();
6049
+ policySquashed = objectType({
6050
+ name: stringType(),
6051
+ values: stringType()
6052
+ }).strict();
5981
6053
  viewWithOption = objectType({
5982
6054
  checkOption: enumType(["local", "cascaded"]).optional(),
5983
6055
  securityBarrier: booleanType().optional(),
@@ -6058,7 +6130,9 @@ var init_pgSchema = __esm({
6058
6130
  foreignKeys: recordType(stringType(), fk2),
6059
6131
  compositePrimaryKeys: recordType(stringType(), compositePK2),
6060
6132
  uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
6061
- checkConstraints: recordType(stringType(), checkConstraint2).default({})
6133
+ policies: recordType(stringType(), policy).default({}),
6134
+ checkConstraints: recordType(stringType(), checkConstraint2).default({}),
6135
+ isRLSEnabled: booleanType().default(false)
6062
6136
  }).strict();
6063
6137
  schemaHash2 = objectType({
6064
6138
  id: stringType(),
@@ -6153,6 +6227,8 @@ var init_pgSchema = __esm({
6153
6227
  schemas: recordType(stringType(), stringType()),
6154
6228
  views: recordType(stringType(), view2).default({}),
6155
6229
  sequences: recordType(stringType(), sequenceSchema).default({}),
6230
+ roles: recordType(stringType(), roleSchema).default({}),
6231
+ policies: recordType(stringType(), policy).default({}),
6156
6232
  _meta: objectType({
6157
6233
  schemas: recordType(stringType(), stringType()),
6158
6234
  tables: recordType(stringType(), stringType()),
@@ -6168,7 +6244,9 @@ var init_pgSchema = __esm({
6168
6244
  foreignKeys: recordType(stringType(), stringType()),
6169
6245
  compositePrimaryKeys: recordType(stringType(), stringType()),
6170
6246
  uniqueConstraints: recordType(stringType(), stringType()),
6171
- checkConstraints: recordType(stringType(), stringType())
6247
+ policies: recordType(stringType(), stringType()),
6248
+ checkConstraints: recordType(stringType(), stringType()),
6249
+ isRLSEnabled: booleanType().default(false)
6172
6250
  }).strict();
6173
6251
  tableSquashedV42 = objectType({
6174
6252
  name: stringType(),
@@ -6198,7 +6276,9 @@ var init_pgSchema = __esm({
6198
6276
  enums: recordType(stringType(), enumSchema),
6199
6277
  schemas: recordType(stringType(), stringType()),
6200
6278
  views: recordType(stringType(), view2),
6201
- sequences: recordType(stringType(), sequenceSquashed)
6279
+ sequences: recordType(stringType(), sequenceSquashed),
6280
+ roles: recordType(stringType(), roleSchema).default({}),
6281
+ policies: recordType(stringType(), policySquashed).default({})
6202
6282
  }).strict();
6203
6283
  pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
6204
6284
  pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
@@ -6281,6 +6361,26 @@ var init_pgSchema = __esm({
6281
6361
  squashFK: (fk4) => {
6282
6362
  return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
6283
6363
  },
6364
+ squashPolicy: (policy4) => {
6365
+ var _a;
6366
+ return `${policy4.name}--${policy4.as}--${policy4.for}--${(_a = policy4.to) == null ? void 0 : _a.join(",")}--${policy4.using}--${policy4.withCheck}--${policy4.on}`;
6367
+ },
6368
+ unsquashPolicy: (policy4) => {
6369
+ const splitted = policy4.split("--");
6370
+ return {
6371
+ name: splitted[0],
6372
+ as: splitted[1],
6373
+ for: splitted[2],
6374
+ to: splitted[3].split(","),
6375
+ using: splitted[4] !== "undefined" ? splitted[4] : void 0,
6376
+ withCheck: splitted[5] !== "undefined" ? splitted[5] : void 0,
6377
+ on: splitted[6] !== "undefined" ? splitted[6] : void 0
6378
+ };
6379
+ },
6380
+ squashPolicyPush: (policy4) => {
6381
+ var _a;
6382
+ return `${policy4.name}--${policy4.as}--${policy4.for}--${(_a = policy4.to) == null ? void 0 : _a.join(",")}--${policy4.on}`;
6383
+ },
6284
6384
  squashPK: (pk) => {
6285
6385
  return `${pk.columns.join(",")};${pk.name}`;
6286
6386
  },
@@ -6393,6 +6493,9 @@ var init_pgSchema = __esm({
6393
6493
  return PgSquasher.squashUnique(unq);
6394
6494
  }
6395
6495
  );
6496
+ const squashedPolicies = mapValues(it[1].policies, (policy4) => {
6497
+ return action === "push" ? PgSquasher.squashPolicyPush(policy4) : PgSquasher.squashPolicy(policy4);
6498
+ });
6396
6499
  const squashedChecksContraints = mapValues(
6397
6500
  it[1].checkConstraints,
6398
6501
  (check2) => {
@@ -6409,7 +6512,9 @@ var init_pgSchema = __esm({
6409
6512
  foreignKeys: squashedFKs,
6410
6513
  compositePrimaryKeys: squashedPKs,
6411
6514
  uniqueConstraints: squashedUniqueConstraints,
6412
- checkConstraints: squashedChecksContraints
6515
+ policies: squashedPolicies,
6516
+ checkConstraints: squashedChecksContraints,
6517
+ isRLSEnabled: it[1].isRLSEnabled ?? false
6413
6518
  }
6414
6519
  ];
6415
6520
  })
@@ -6426,6 +6531,17 @@ var init_pgSchema = __esm({
6426
6531
  ];
6427
6532
  })
6428
6533
  );
6534
+ const mappedPolicies = Object.fromEntries(
6535
+ Object.entries(json.policies).map((it) => {
6536
+ return [
6537
+ it[0],
6538
+ {
6539
+ name: it[1].name,
6540
+ values: action === "push" ? PgSquasher.squashPolicyPush(it[1]) : PgSquasher.squashPolicy(it[1])
6541
+ }
6542
+ ];
6543
+ })
6544
+ );
6429
6545
  return {
6430
6546
  version: "7",
6431
6547
  dialect: json.dialect,
@@ -6433,7 +6549,9 @@ var init_pgSchema = __esm({
6433
6549
  enums: json.enums,
6434
6550
  schemas: json.schemas,
6435
6551
  views: json.views,
6436
- sequences: mappedSequences
6552
+ policies: mappedPolicies,
6553
+ sequences: mappedSequences,
6554
+ roles: json.roles
6437
6555
  };
6438
6556
  };
6439
6557
  dryPg = pgSchema.parse({
@@ -6444,6 +6562,8 @@ var init_pgSchema = __esm({
6444
6562
  tables: {},
6445
6563
  enums: {},
6446
6564
  schemas: {},
6565
+ policies: {},
6566
+ roles: {},
6447
6567
  sequences: {},
6448
6568
  _meta: {
6449
6569
  schemas: {},
@@ -6762,17 +6882,11 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
6762
6882
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
6763
6883
  return { addedColumns, removedColumns };
6764
6884
  }
6765
- function getColumnCasing(column7, casing2) {
6766
- if (!column7.name)
6767
- return "";
6768
- return !column7.keyAsName || casing2 === void 0 ? column7.name : casing2 === "camelCase" ? (0, import_casing.toCamelCase)(column7.name) : (0, import_casing.toSnakeCase)(column7.name);
6769
- }
6770
- var import_casing, import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
6885
+ var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
6771
6886
  var init_utils = __esm({
6772
6887
  "src/utils.ts"() {
6773
6888
  "use strict";
6774
6889
  init_source();
6775
- import_casing = require("drizzle-orm/casing");
6776
6890
  import_fs = require("fs");
6777
6891
  import_path = require("path");
6778
6892
  import_url = require("url");
@@ -8842,7 +8956,7 @@ var init_utils2 = __esm({
8842
8956
  process.exit(1);
8843
8957
  }
8844
8958
  };
8845
- requiredApiVersion = 9;
8959
+ requiredApiVersion = 10;
8846
8960
  assertOrmCoreVersion = async () => {
8847
8961
  try {
8848
8962
  const { compatibilityVersion } = await import("drizzle-orm/version");
@@ -10770,10 +10884,10 @@ var require_inflight = __commonJS({
10770
10884
  }
10771
10885
  function slice(args) {
10772
10886
  var length = args.length;
10773
- var array = [];
10887
+ var array2 = [];
10774
10888
  for (var i2 = 0; i2 < length; i2++)
10775
- array[i2] = args[i2];
10776
- return array;
10889
+ array2[i2] = args[i2];
10890
+ return array2;
10777
10891
  }
10778
10892
  }
10779
10893
  });
@@ -11384,10 +11498,10 @@ var init_outputs = __esm({
11384
11498
  )
11385
11499
  },
11386
11500
  common: {
11387
- ambiguousParams: (command2) => withStyle.error(
11388
- `You can't use both --config and other cli options for ${command2} command`
11501
+ ambiguousParams: (command) => withStyle.error(
11502
+ `You can't use both --config and other cli options for ${command} command`
11389
11503
  ),
11390
- schema: (command2) => withStyle.error(`"--schema" is a required field for ${command2} command`)
11504
+ schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`)
11391
11505
  },
11392
11506
  postgres: {
11393
11507
  connection: {
@@ -11438,7 +11552,7 @@ var init_common = __esm({
11438
11552
  init_lib();
11439
11553
  init_schemaValidator();
11440
11554
  init_outputs();
11441
- assertCollisions = (command2, options, whitelist, remainingKeys) => {
11555
+ assertCollisions = (command, options, whitelist, remainingKeys) => {
11442
11556
  const { config, ...rest } = options;
11443
11557
  let atLeastOneParam = false;
11444
11558
  for (const key of Object.keys(rest)) {
@@ -11452,7 +11566,7 @@ var init_common = __esm({
11452
11566
  if (!atLeastOneParam) {
11453
11567
  return "config";
11454
11568
  }
11455
- console.log(outputs.common.ambiguousParams(command2));
11569
+ console.log(outputs.common.ambiguousParams(command));
11456
11570
  process.exit(1);
11457
11571
  };
11458
11572
  sqliteDriversLiterals = [
@@ -11583,7 +11697,14 @@ var init_cli = __esm({
11583
11697
  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
11584
11698
  extensionsFilters: literalType("postgis").array().optional(),
11585
11699
  verbose: booleanType().optional(),
11586
- strict: booleanType().optional()
11700
+ strict: booleanType().optional(),
11701
+ entities: objectType({
11702
+ roles: booleanType().or(objectType({
11703
+ provider: stringType().optional(),
11704
+ include: stringType().array().optional(),
11705
+ exclude: stringType().array().optional()
11706
+ })).optional().default(false)
11707
+ }).optional()
11587
11708
  }).passthrough();
11588
11709
  pullParams = objectType({
11589
11710
  config: stringType().optional(),
@@ -11596,6 +11717,13 @@ var init_cli = __esm({
11596
11717
  breakpoints: booleanType().optional().default(true),
11597
11718
  migrations: objectType({
11598
11719
  prefix: prefix.optional().default("index")
11720
+ }).optional(),
11721
+ entities: objectType({
11722
+ roles: booleanType().or(objectType({
11723
+ provider: stringType().optional(),
11724
+ include: stringType().array().optional(),
11725
+ exclude: stringType().array().optional()
11726
+ })).optional().default(false)
11599
11727
  }).optional()
11600
11728
  }).passthrough();
11601
11729
  configCheck = objectType({
@@ -11623,7 +11751,7 @@ var init_libsql = __esm({
11623
11751
  url: stringType().min(1),
11624
11752
  authToken: stringType().min(1).optional()
11625
11753
  });
11626
- printConfigConnectionIssues = (options, command2) => {
11754
+ printConfigConnectionIssues = (options, command) => {
11627
11755
  let text = `Please provide required params for 'turso' dialect:
11628
11756
  `;
11629
11757
  console.log(error(text));
@@ -11804,25 +11932,25 @@ var init_sqlite = __esm({
11804
11932
  return o;
11805
11933
  })
11806
11934
  ]);
11807
- printConfigConnectionIssues4 = (options, command2) => {
11935
+ printConfigConnectionIssues4 = (options, command) => {
11808
11936
  const parsedDriver = sqliteDriver.safeParse(options.driver);
11809
11937
  const driver2 = parsedDriver.success ? parsedDriver.data : "";
11810
11938
  if (driver2 === "expo") {
11811
- if (command2 === "migrate") {
11939
+ if (command === "migrate") {
11812
11940
  console.log(
11813
11941
  error(
11814
11942
  `You can't use 'migrate' command with Expo SQLite, please follow migration instructions in our docs - https://orm.drizzle.team/docs/get-started-sqlite#expo-sqlite`
11815
11943
  )
11816
11944
  );
11817
- } else if (command2 === "studio") {
11945
+ } else if (command === "studio") {
11818
11946
  console.log(
11819
11947
  error(
11820
11948
  `You can't use 'studio' command with Expo SQLite, please use Expo Plugin https://www.npmjs.com/package/expo-drizzle-studio-plugin`
11821
11949
  )
11822
11950
  );
11823
- } else if (command2 === "pull") {
11951
+ } else if (command === "pull") {
11824
11952
  console.log(error("You can't use 'pull' command with Expo SQLite"));
11825
- } else if (command2 === "push") {
11953
+ } else if (command === "push") {
11826
11954
  console.log(error("You can't use 'push' command with Expo SQLite"));
11827
11955
  } else {
11828
11956
  console.log(error("Unexpected error with expo driver \u{1F914}"));
@@ -17686,7 +17814,8 @@ var init_utils4 = __esm({
17686
17814
  credentials: parsed2.data,
17687
17815
  casing: config.casing,
17688
17816
  tablesFilter,
17689
- schemasFilter
17817
+ schemasFilter,
17818
+ entities: config.entities
17690
17819
  };
17691
17820
  }
17692
17821
  if (config.dialect === "mysql") {
@@ -17783,7 +17912,8 @@ var init_utils4 = __esm({
17783
17912
  credentials: parsed2.data,
17784
17913
  tablesFilter,
17785
17914
  schemasFilter,
17786
- prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
17915
+ prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index",
17916
+ entities: config.entities
17787
17917
  };
17788
17918
  }
17789
17919
  if (dialect4 === "mysql") {
@@ -17800,7 +17930,8 @@ var init_utils4 = __esm({
17800
17930
  credentials: parsed2.data,
17801
17931
  tablesFilter,
17802
17932
  schemasFilter,
17803
- prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
17933
+ prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index",
17934
+ entities: config.entities
17804
17935
  };
17805
17936
  }
17806
17937
  if (dialect4 === "sqlite") {
@@ -17817,7 +17948,8 @@ var init_utils4 = __esm({
17817
17948
  credentials: parsed2.data,
17818
17949
  tablesFilter,
17819
17950
  schemasFilter,
17820
- prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
17951
+ prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index",
17952
+ entities: config.entities
17821
17953
  };
17822
17954
  }
17823
17955
  if (dialect4 === "turso") {
@@ -17834,7 +17966,8 @@ var init_utils4 = __esm({
17834
17966
  credentials: parsed2.data,
17835
17967
  tablesFilter,
17836
17968
  schemasFilter,
17837
- prefix: ((_d = config.migrations) == null ? void 0 : _d.prefix) || "index"
17969
+ prefix: ((_d = config.migrations) == null ? void 0 : _d.prefix) || "index",
17970
+ entities: config.entities
17838
17971
  };
17839
17972
  }
17840
17973
  assertUnreachable(dialect4);
@@ -18078,6 +18211,34 @@ var init_mysqlImports = __esm({
18078
18211
  }
18079
18212
  });
18080
18213
 
18214
+ // src/serializer/utils.ts
18215
+ function getColumnCasing(column7, casing2) {
18216
+ if (!column7.name)
18217
+ return "";
18218
+ return !column7.keyAsName || casing2 === void 0 ? column7.name : casing2 === "camelCase" ? (0, import_casing.toCamelCase)(column7.name) : (0, import_casing.toSnakeCase)(column7.name);
18219
+ }
18220
+ var import_casing, sqlToStr;
18221
+ var init_utils5 = __esm({
18222
+ "src/serializer/utils.ts"() {
18223
+ "use strict";
18224
+ import_casing = require("drizzle-orm/casing");
18225
+ sqlToStr = (sql, casing2) => {
18226
+ return sql.toQuery({
18227
+ escapeName: () => {
18228
+ throw new Error("we don't support params for `sql` default values");
18229
+ },
18230
+ escapeParam: () => {
18231
+ throw new Error("we don't support params for `sql` default values");
18232
+ },
18233
+ escapeString: () => {
18234
+ throw new Error("we don't support params for `sql` default values");
18235
+ },
18236
+ casing: new import_casing.CasingCache(casing2)
18237
+ }).sql;
18238
+ };
18239
+ }
18240
+ });
18241
+
18081
18242
  // src/serializer/mysqlSerializer.ts
18082
18243
  var mysqlSerializer_exports = {};
18083
18244
  __export(mysqlSerializer_exports, {
@@ -18102,24 +18263,20 @@ function clearDefaults(defaultValue, collate) {
18102
18263
  return `(${resultDefault})`;
18103
18264
  }
18104
18265
  }
18105
- var import_drizzle_orm2, import_drizzle_orm3, import_mysql_core2, import_mysql_core3, import_mysql_core4, indexName, generateMySqlSnapshot, fromDatabase;
18266
+ var import_drizzle_orm2, import_mysql_core2, indexName, generateMySqlSnapshot, fromDatabase;
18106
18267
  var init_mysqlSerializer = __esm({
18107
18268
  "src/serializer/mysqlSerializer.ts"() {
18108
18269
  "use strict";
18109
18270
  init_source();
18110
18271
  import_drizzle_orm2 = require("drizzle-orm");
18111
- import_drizzle_orm3 = require("drizzle-orm");
18112
18272
  import_mysql_core2 = require("drizzle-orm/mysql-core");
18113
- import_mysql_core3 = require("drizzle-orm/mysql-core");
18114
- import_mysql_core4 = require("drizzle-orm/mysql-core");
18115
18273
  init_outputs();
18116
- init_utils();
18117
- init_serializer();
18274
+ init_utils5();
18118
18275
  indexName = (tableName, columns) => {
18119
18276
  return `${tableName}_${columns.join("_")}_index`;
18120
18277
  };
18121
18278
  generateMySqlSnapshot = (tables, views, casing2) => {
18122
- const dialect4 = new import_mysql_core3.MySqlDialect({ casing: casing2 });
18279
+ const dialect4 = new import_mysql_core2.MySqlDialect({ casing: casing2 });
18123
18280
  const result = {};
18124
18281
  const resultViews = {};
18125
18282
  const internal = { tables: {}, indexes: {} };
@@ -18133,7 +18290,7 @@ var init_mysqlSerializer = __esm({
18133
18290
  checks,
18134
18291
  primaryKeys,
18135
18292
  uniqueConstraints
18136
- } = (0, import_mysql_core4.getTableConfig)(table4);
18293
+ } = (0, import_mysql_core2.getTableConfig)(table4);
18137
18294
  const columnsObject = {};
18138
18295
  const indexesObject = {};
18139
18296
  const foreignKeysObject = {};
@@ -18157,7 +18314,7 @@ var init_mysqlSerializer = __esm({
18157
18314
  autoincrement: autoIncrement,
18158
18315
  onUpdate: column7.hasOnUpdateNow,
18159
18316
  generated: generated ? {
18160
- as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm3.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
18317
+ as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm2.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
18161
18318
  type: generated.mode ?? "stored"
18162
18319
  } : void 0
18163
18320
  };
@@ -18192,7 +18349,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18192
18349
  };
18193
18350
  }
18194
18351
  if (column7.default !== void 0) {
18195
- if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm3.SQL)) {
18352
+ if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm2.SQL)) {
18196
18353
  columnToSet.default = sqlToStr(column7.default, casing2);
18197
18354
  } else {
18198
18355
  if (typeof column7.default === "string") {
@@ -18236,7 +18393,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18236
18393
  });
18237
18394
  uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
18238
18395
  const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
18239
- const name = unq.name ?? (0, import_mysql_core3.uniqueKeyName)(table4, columnNames);
18396
+ const name = unq.name ?? (0, import_mysql_core2.uniqueKeyName)(table4, columnNames);
18240
18397
  const existingUnique = uniqueConstraintObject[name];
18241
18398
  if (typeof existingUnique !== "undefined") {
18242
18399
  console.log(
@@ -18300,7 +18457,7 @@ The unique constraint ${source_default.underline.blue(
18300
18457
  const name = value.config.name;
18301
18458
  let indexColumns = columns2.map((it) => {
18302
18459
  var _a;
18303
- if ((0, import_drizzle_orm2.is)(it, import_drizzle_orm3.SQL)) {
18460
+ if ((0, import_drizzle_orm2.is)(it, import_drizzle_orm2.SQL)) {
18304
18461
  const sql = dialect4.sqlToQuery(it, "indexes").sql;
18305
18462
  if (typeof internal.indexes[name] === "undefined") {
18306
18463
  internal.indexes[name] = {
@@ -18451,12 +18608,12 @@ ${withStyle.errorWarning(
18451
18608
  autoincrement: autoIncrement,
18452
18609
  onUpdate: column7.hasOnUpdateNow,
18453
18610
  generated: generated ? {
18454
- as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm3.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
18611
+ as: (0, import_drizzle_orm2.is)(generated.as, import_drizzle_orm2.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
18455
18612
  type: generated.mode ?? "stored"
18456
18613
  } : void 0
18457
18614
  };
18458
18615
  if (column7.default !== void 0) {
18459
- if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm3.SQL)) {
18616
+ if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm2.SQL)) {
18460
18617
  columnToSet.default = sqlToStr(column7.default, casing2);
18461
18618
  } else {
18462
18619
  if (typeof column7.default === "string") {
@@ -18849,11 +19006,11 @@ __export(pgImports_exports, {
18849
19006
  prepareFromExports: () => prepareFromExports2,
18850
19007
  prepareFromPgImports: () => prepareFromPgImports
18851
19008
  });
18852
- var import_drizzle_orm4, import_pg_core, prepareFromExports2, prepareFromPgImports;
19009
+ var import_drizzle_orm3, import_pg_core, prepareFromExports2, prepareFromPgImports;
18853
19010
  var init_pgImports = __esm({
18854
19011
  "src/serializer/pgImports.ts"() {
18855
19012
  "use strict";
18856
- import_drizzle_orm4 = require("drizzle-orm");
19013
+ import_drizzle_orm3 = require("drizzle-orm");
18857
19014
  import_pg_core = require("drizzle-orm/pg-core");
18858
19015
  init_utils4();
18859
19016
  prepareFromExports2 = (exports2) => {
@@ -18861,6 +19018,8 @@ var init_pgImports = __esm({
18861
19018
  const enums = [];
18862
19019
  const schemas = [];
18863
19020
  const sequences = [];
19021
+ const roles = [];
19022
+ const policies = [];
18864
19023
  const views = [];
18865
19024
  const matViews = [];
18866
19025
  const i0values = Object.values(exports2);
@@ -18869,10 +19028,10 @@ var init_pgImports = __esm({
18869
19028
  enums.push(t2);
18870
19029
  return;
18871
19030
  }
18872
- if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgTable)) {
19031
+ if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgTable)) {
18873
19032
  tables.push(t2);
18874
19033
  }
18875
- if ((0, import_drizzle_orm4.is)(t2, import_pg_core.PgSchema)) {
19034
+ if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgSchema)) {
18876
19035
  schemas.push(t2);
18877
19036
  }
18878
19037
  if ((0, import_pg_core.isPgView)(t2)) {
@@ -18884,8 +19043,14 @@ var init_pgImports = __esm({
18884
19043
  if ((0, import_pg_core.isPgSequence)(t2)) {
18885
19044
  sequences.push(t2);
18886
19045
  }
19046
+ if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgRole)) {
19047
+ roles.push(t2);
19048
+ }
19049
+ if ((0, import_drizzle_orm3.is)(t2, import_pg_core.PgPolicy)) {
19050
+ policies.push(t2);
19051
+ }
18887
19052
  });
18888
- return { tables, enums, schemas, sequences, views, matViews };
19053
+ return { tables, enums, schemas, sequences, views, matViews, roles, policies };
18889
19054
  };
18890
19055
  prepareFromPgImports = async (imports) => {
18891
19056
  const tables = [];
@@ -18893,6 +19058,8 @@ var init_pgImports = __esm({
18893
19058
  const schemas = [];
18894
19059
  const sequences = [];
18895
19060
  const views = [];
19061
+ const roles = [];
19062
+ const policies = [];
18896
19063
  const matViews = [];
18897
19064
  const { unregister } = await safeRegister();
18898
19065
  for (let i2 = 0; i2 < imports.length; i2++) {
@@ -18905,9 +19072,11 @@ var init_pgImports = __esm({
18905
19072
  sequences.push(...prepared.sequences);
18906
19073
  views.push(...prepared.views);
18907
19074
  matViews.push(...prepared.matViews);
19075
+ roles.push(...prepared.roles);
19076
+ policies.push(...prepared.policies);
18908
19077
  }
18909
19078
  unregister();
18910
- return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews };
19079
+ return { tables: Array.from(new Set(tables)), enums, schemas, sequences, views, matViews, roles, policies };
18911
19080
  };
18912
19081
  }
18913
19082
  });
@@ -18915,6 +19084,7 @@ var init_pgImports = __esm({
18915
19084
  // src/serializer/pgSerializer.ts
18916
19085
  var pgSerializer_exports = {};
18917
19086
  __export(pgSerializer_exports, {
19087
+ buildArrayString: () => buildArrayString,
18918
19088
  fromDatabase: () => fromDatabase2,
18919
19089
  generatePgSnapshot: () => generatePgSnapshot,
18920
19090
  indexName: () => indexName2
@@ -18926,14 +19096,14 @@ function maxRangeForIdentityBasedOn(columnType) {
18926
19096
  return columnType === "integer" ? "2147483647" : columnType === "bigint" ? "9223372036854775807" : "32767";
18927
19097
  }
18928
19098
  function minRangeForIdentityBasedOn(columnType) {
18929
- return columnType === "integer" ? "-2147483648" : columnType === "bitint" ? "-9223372036854775808" : "-32768";
19099
+ return columnType === "integer" ? "-2147483648" : columnType === "bigint" ? "-9223372036854775808" : "-32768";
18930
19100
  }
18931
19101
  function stringFromDatabaseIdentityProperty(field) {
18932
19102
  return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
18933
19103
  }
18934
- function buildArrayString(array, sqlType) {
19104
+ function buildArrayString(array2, sqlType) {
18935
19105
  sqlType = sqlType.split("[")[0];
18936
- const values = array.map((value) => {
19106
+ const values = array2.map((value) => {
18937
19107
  if (typeof value === "number" || typeof value === "bigint") {
18938
19108
  return value.toString();
18939
19109
  } else if (typeof value === "boolean") {
@@ -18955,31 +19125,77 @@ function buildArrayString(array, sqlType) {
18955
19125
  }).join(",");
18956
19126
  return `{${values}}`;
18957
19127
  }
18958
- var import_drizzle_orm5, import_pg_core2, import_pg_core3, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn, getColumnsInfoQuery;
19128
+ function prepareRoles(entities) {
19129
+ let useRoles = false;
19130
+ const includeRoles = [];
19131
+ const excludeRoles = [];
19132
+ if (entities && entities.roles) {
19133
+ if (typeof entities.roles === "object") {
19134
+ if (entities.roles.provider) {
19135
+ if (entities.roles.provider === "supabase") {
19136
+ excludeRoles.push(...[
19137
+ "anon",
19138
+ "authenticator",
19139
+ "authenticated",
19140
+ "service_role",
19141
+ "supabase_auth_admin",
19142
+ "supabase_storage_admin",
19143
+ "dashboard_user",
19144
+ "supabase_admin"
19145
+ ]);
19146
+ } else if (entities.roles.provider === "neon") {
19147
+ excludeRoles.push(...["authenticated", "anonymous"]);
19148
+ }
19149
+ }
19150
+ if (entities.roles.include) {
19151
+ includeRoles.push(...entities.roles.include);
19152
+ }
19153
+ if (entities.roles.exclude) {
19154
+ excludeRoles.push(...entities.roles.exclude);
19155
+ }
19156
+ } else {
19157
+ useRoles = entities.roles;
19158
+ }
19159
+ }
19160
+ return { useRoles, includeRoles, excludeRoles };
19161
+ }
19162
+ var import_drizzle_orm4, import_pg_core2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn, getColumnsInfoQuery;
18959
19163
  var init_pgSerializer = __esm({
18960
19164
  "src/serializer/pgSerializer.ts"() {
18961
19165
  "use strict";
18962
19166
  init_source();
18963
- import_drizzle_orm5 = require("drizzle-orm");
19167
+ import_drizzle_orm4 = require("drizzle-orm");
18964
19168
  import_pg_core2 = require("drizzle-orm/pg-core");
18965
- import_pg_core3 = require("drizzle-orm/pg-core");
18966
19169
  init_vector();
18967
19170
  init_outputs();
18968
19171
  init_utils();
18969
- init_serializer();
19172
+ init_utils5();
18970
19173
  indexName2 = (tableName, columns) => {
18971
19174
  return `${tableName}_${columns.join("_")}_index`;
18972
19175
  };
18973
- generatePgSnapshot = (tables, enums, schemas, sequences, views, matViews, casing2, schemaFilter) => {
18974
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
19176
+ generatePgSnapshot = (tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter) => {
19177
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
18975
19178
  const dialect4 = new import_pg_core2.PgDialect({ casing: casing2 });
18976
19179
  const result = {};
18977
19180
  const resultViews = {};
18978
19181
  const sequencesToReturn = {};
19182
+ const rolesToReturn = {};
19183
+ const policiesToReturn = {};
18979
19184
  const indexesInSchema = {};
18980
19185
  for (const table4 of tables) {
18981
19186
  const checksInTable = {};
18982
- const { name: tableName, columns, indexes, foreignKeys, checks, schema: schema5, primaryKeys, uniqueConstraints } = (0, import_pg_core3.getTableConfig)(table4);
19187
+ const {
19188
+ name: tableName,
19189
+ columns,
19190
+ indexes,
19191
+ foreignKeys,
19192
+ checks,
19193
+ schema: schema5,
19194
+ primaryKeys,
19195
+ uniqueConstraints,
19196
+ policies: policies2,
19197
+ enableRLS
19198
+ } = (0, import_pg_core2.getTableConfig)(table4);
18983
19199
  if (schemaFilter && !schemaFilter.includes(schema5 ?? "public")) {
18984
19200
  continue;
18985
19201
  }
@@ -18989,13 +19205,14 @@ var init_pgSerializer = __esm({
18989
19205
  const foreignKeysObject = {};
18990
19206
  const primaryKeysObject = {};
18991
19207
  const uniqueConstraintObject = {};
19208
+ const policiesObject = {};
18992
19209
  columns.forEach((column7) => {
18993
19210
  var _a2, _b2, _c2, _d2, _e2, _f2;
18994
19211
  const name = getColumnCasing(column7, casing2);
18995
19212
  const notNull = column7.notNull;
18996
19213
  const primaryKey = column7.primary;
18997
19214
  const sqlTypeLowered = column7.getSQLType().toLowerCase();
18998
- const typeSchema = (0, import_drizzle_orm5.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
19215
+ const typeSchema = (0, import_drizzle_orm4.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
18999
19216
  const generated = column7.generated;
19000
19217
  const identity = column7.generatedIdentity;
19001
19218
  const increment = stringFromIdentityProperty((_a2 = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _a2.increment) ?? "1";
@@ -19010,7 +19227,7 @@ var init_pgSerializer = __esm({
19010
19227
  primaryKey,
19011
19228
  notNull,
19012
19229
  generated: generated ? {
19013
- as: (0, import_drizzle_orm5.is)(generated.as, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
19230
+ as: (0, import_drizzle_orm4.is)(generated.as, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
19014
19231
  type: "stored"
19015
19232
  } : void 0,
19016
19233
  identity: identity ? {
@@ -19051,7 +19268,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19051
19268
  };
19052
19269
  }
19053
19270
  if (column7.default !== void 0) {
19054
- if ((0, import_drizzle_orm5.is)(column7.default, import_drizzle_orm5.SQL)) {
19271
+ if ((0, import_drizzle_orm4.is)(column7.default, import_drizzle_orm4.SQL)) {
19055
19272
  columnToSet.default = sqlToStr(column7.default, casing2);
19056
19273
  } else {
19057
19274
  if (typeof column7.default === "string") {
@@ -19119,8 +19336,8 @@ ${withStyle.errorWarning(
19119
19336
  const onDelete = fk4.onDelete;
19120
19337
  const onUpdate = fk4.onUpdate;
19121
19338
  const reference = fk4.reference();
19122
- const tableTo = (0, import_drizzle_orm5.getTableName)(reference.foreignTable);
19123
- const schemaTo = (0, import_pg_core3.getTableConfig)(reference.foreignTable).schema;
19339
+ const tableTo = (0, import_drizzle_orm4.getTableName)(reference.foreignTable);
19340
+ const schemaTo = (0, import_pg_core2.getTableConfig)(reference.foreignTable).schema;
19124
19341
  const originalColumnsFrom = reference.columns.map((it) => it.name);
19125
19342
  const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
19126
19343
  const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
@@ -19152,12 +19369,12 @@ ${withStyle.errorWarning(
19152
19369
  const columns2 = value.config.columns;
19153
19370
  let indexColumnNames = [];
19154
19371
  columns2.forEach((it) => {
19155
- if ((0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL)) {
19372
+ if ((0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL)) {
19156
19373
  if (typeof value.config.name === "undefined") {
19157
19374
  console.log(
19158
19375
  `
19159
19376
  ${withStyle.errorWarning(
19160
- `Please specify an index name in ${(0, import_drizzle_orm5.getTableName)(value.config.table)} table that has "${dialect4.sqlToQuery(it).sql}" expression. We can generate index names for indexes on columns only; for expressions in indexes, you need to specify the name yourself.`
19377
+ `Please specify an index name in ${(0, import_drizzle_orm4.getTableName)(value.config.table)} table that has "${dialect4.sqlToQuery(it).sql}" expression. We can generate index names for indexes on columns only; for expressions in indexes, you need to specify the name yourself.`
19161
19378
  )}`
19162
19379
  );
19163
19380
  process.exit(1);
@@ -19165,7 +19382,7 @@ ${withStyle.errorWarning(
19165
19382
  }
19166
19383
  it = it;
19167
19384
  const name2 = getColumnCasing(it, casing2);
19168
- if (!(0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL) && it.type === "PgVector" && typeof it.indexConfig.opClass === "undefined") {
19385
+ if (!(0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL) && it.type === "PgVector" && typeof it.indexConfig.opClass === "undefined") {
19169
19386
  console.log(
19170
19387
  `
19171
19388
  ${withStyle.errorWarning(
@@ -19193,7 +19410,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
19193
19410
  let indexColumns = columns2.map(
19194
19411
  (it) => {
19195
19412
  var _a2, _b2, _c2, _d2, _e2;
19196
- if ((0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL)) {
19413
+ if ((0, import_drizzle_orm4.is)(it, import_drizzle_orm4.SQL)) {
19197
19414
  return {
19198
19415
  expression: dialect4.sqlToQuery(it, "indexes").sql,
19199
19416
  asc: true,
@@ -19238,6 +19455,46 @@ ${withStyle.errorWarning(
19238
19455
  with: value.config.with ?? {}
19239
19456
  };
19240
19457
  });
19458
+ policies2.forEach((policy4) => {
19459
+ var _a2, _b2;
19460
+ const mappedTo = [];
19461
+ if (!policy4.to) {
19462
+ mappedTo.push("public");
19463
+ } else {
19464
+ if (policy4.to && typeof policy4.to === "string") {
19465
+ mappedTo.push(policy4.to);
19466
+ } else if (policy4.to && (0, import_drizzle_orm4.is)(policy4.to, import_pg_core2.PgRole)) {
19467
+ mappedTo.push(policy4.to.name);
19468
+ } else if (policy4.to && Array.isArray(policy4.to)) {
19469
+ policy4.to.forEach((it) => {
19470
+ if (typeof it === "string") {
19471
+ mappedTo.push(it);
19472
+ } else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
19473
+ mappedTo.push(it.name);
19474
+ }
19475
+ });
19476
+ }
19477
+ }
19478
+ if (policiesObject[policy4.name] !== void 0) {
19479
+ console.log(
19480
+ `
19481
+ ${withStyle.errorWarning(
19482
+ `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
19483
+ policy4.name
19484
+ )} name`
19485
+ )}`
19486
+ );
19487
+ process.exit(1);
19488
+ }
19489
+ policiesObject[policy4.name] = {
19490
+ name: policy4.name,
19491
+ as: ((_a2 = policy4.as) == null ? void 0 : _a2.toUpperCase()) ?? "PERMISSIVE",
19492
+ for: ((_b2 = policy4.for) == null ? void 0 : _b2.toUpperCase()) ?? "ALL",
19493
+ to: mappedTo.sort(),
19494
+ using: (0, import_drizzle_orm4.is)(policy4.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
19495
+ withCheck: (0, import_drizzle_orm4.is)(policy4.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
19496
+ };
19497
+ });
19241
19498
  checks.forEach((check2) => {
19242
19499
  const checkName = check2.name;
19243
19500
  if (typeof checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] !== "undefined") {
@@ -19274,17 +19531,77 @@ ${withStyle.errorWarning(
19274
19531
  foreignKeys: foreignKeysObject,
19275
19532
  compositePrimaryKeys: primaryKeysObject,
19276
19533
  uniqueConstraints: uniqueConstraintObject,
19277
- checkConstraints: checksObject
19534
+ policies: policiesObject,
19535
+ checkConstraints: checksObject,
19536
+ isRLSEnabled: enableRLS
19278
19537
  };
19279
19538
  }
19539
+ for (const policy4 of policies) {
19540
+ if (!policy4._linkedTable) {
19541
+ console.log(
19542
+ `
19543
+ ${withStyle.errorWarning(
19544
+ `"Policy ${policy4.name} was skipped because it was not linked to any table. You should either include the policy in a table or use .link() on the policy to link it to any table you have. For more information, please check:`
19545
+ )}`
19546
+ );
19547
+ continue;
19548
+ }
19549
+ const tableConfig = (0, import_pg_core2.getTableConfig)(policy4._linkedTable);
19550
+ const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
19551
+ const mappedTo = [];
19552
+ if (!policy4.to) {
19553
+ mappedTo.push("public");
19554
+ } else {
19555
+ if (policy4.to && typeof policy4.to === "string") {
19556
+ mappedTo.push(policy4.to);
19557
+ } else if (policy4.to && (0, import_drizzle_orm4.is)(policy4.to, import_pg_core2.PgRole)) {
19558
+ mappedTo.push(policy4.to.name);
19559
+ } else if (policy4.to && Array.isArray(policy4.to)) {
19560
+ policy4.to.forEach((it) => {
19561
+ if (typeof it === "string") {
19562
+ mappedTo.push(it);
19563
+ } else if ((0, import_drizzle_orm4.is)(it, import_pg_core2.PgRole)) {
19564
+ mappedTo.push(it.name);
19565
+ }
19566
+ });
19567
+ }
19568
+ }
19569
+ if (((_a = result[tableKey2]) == null ? void 0 : _a.policies[policy4.name]) !== void 0 || policiesToReturn[policy4.name] !== void 0) {
19570
+ console.log(
19571
+ `
19572
+ ${withStyle.errorWarning(
19573
+ `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
19574
+ policy4.name
19575
+ )} name`
19576
+ )}`
19577
+ );
19578
+ process.exit(1);
19579
+ }
19580
+ const mappedPolicy = {
19581
+ name: policy4.name,
19582
+ as: ((_b = policy4.as) == null ? void 0 : _b.toUpperCase()) ?? "PERMISSIVE",
19583
+ for: ((_c = policy4.for) == null ? void 0 : _c.toUpperCase()) ?? "ALL",
19584
+ to: mappedTo.sort(),
19585
+ using: (0, import_drizzle_orm4.is)(policy4.using, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
19586
+ withCheck: (0, import_drizzle_orm4.is)(policy4.withCheck, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
19587
+ };
19588
+ if (result[tableKey2]) {
19589
+ result[tableKey2].policies[policy4.name] = mappedPolicy;
19590
+ } else {
19591
+ policiesToReturn[policy4.name] = {
19592
+ ...mappedPolicy,
19593
+ on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
19594
+ };
19595
+ }
19596
+ }
19280
19597
  for (const sequence of sequences) {
19281
19598
  const name = sequence.seqName;
19282
19599
  if (typeof sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] === "undefined") {
19283
- const increment = stringFromIdentityProperty((_a = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _a.increment) ?? "1";
19284
- const minValue = stringFromIdentityProperty((_b = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _b.minValue) ?? (parseFloat(increment) < 0 ? "-9223372036854775808" : "1");
19285
- const maxValue = stringFromIdentityProperty((_c = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _c.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : "9223372036854775807");
19286
- const startWith = stringFromIdentityProperty((_d = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _d.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
19287
- const cache = stringFromIdentityProperty((_e = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _e.cache) ?? "1";
19600
+ const increment = stringFromIdentityProperty((_d = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _d.increment) ?? "1";
19601
+ const minValue = stringFromIdentityProperty((_e = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _e.minValue) ?? (parseFloat(increment) < 0 ? "-9223372036854775808" : "1");
19602
+ const maxValue = stringFromIdentityProperty((_f = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _f.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : "9223372036854775807");
19603
+ const startWith = stringFromIdentityProperty((_g = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _g.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
19604
+ const cache = stringFromIdentityProperty((_h = sequence == null ? void 0 : sequence.seqOptions) == null ? void 0 : _h.cache) ?? "1";
19288
19605
  sequencesToReturn[`${sequence.schema ?? "public"}.${name}`] = {
19289
19606
  name,
19290
19607
  schema: sequence.schema ?? "public",
@@ -19293,11 +19610,21 @@ ${withStyle.errorWarning(
19293
19610
  minValue,
19294
19611
  maxValue,
19295
19612
  cache,
19296
- cycle: ((_f = sequence.seqOptions) == null ? void 0 : _f.cycle) ?? false
19613
+ cycle: ((_i = sequence.seqOptions) == null ? void 0 : _i.cycle) ?? false
19297
19614
  };
19298
19615
  } else {
19299
19616
  }
19300
19617
  }
19618
+ for (const role of roles) {
19619
+ if (!role._existing) {
19620
+ rolesToReturn[role.name] = {
19621
+ name: role.name,
19622
+ createDb: role.createDb === void 0 ? false : role.createDb,
19623
+ createRole: role.createRole === void 0 ? false : role.createRole,
19624
+ inherit: role.inherit === void 0 ? true : role.inherit
19625
+ };
19626
+ }
19627
+ }
19301
19628
  const combinedViews = [...views, ...matViews];
19302
19629
  for (const view4 of combinedViews) {
19303
19630
  let viewName;
@@ -19310,7 +19637,7 @@ ${withStyle.errorWarning(
19310
19637
  let using;
19311
19638
  let withNoData;
19312
19639
  let materialized = false;
19313
- if ((0, import_drizzle_orm5.is)(view4, import_pg_core2.PgView)) {
19640
+ if ((0, import_drizzle_orm4.is)(view4, import_pg_core2.PgView)) {
19314
19641
  ({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption } = (0, import_pg_core2.getViewConfig)(view4));
19315
19642
  } else {
19316
19643
  ({ name: viewName, schema: schema5, query, selectedFields, isExisting, with: withOption, tablespace, using, withNoData } = (0, import_pg_core2.getMaterializedViewConfig)(view4));
@@ -19331,19 +19658,19 @@ ${withStyle.errorWarning(
19331
19658
  process.exit(1);
19332
19659
  }
19333
19660
  for (const key in selectedFields) {
19334
- if ((0, import_drizzle_orm5.is)(selectedFields[key], import_pg_core2.PgColumn)) {
19661
+ if ((0, import_drizzle_orm4.is)(selectedFields[key], import_pg_core2.PgColumn)) {
19335
19662
  const column7 = selectedFields[key];
19336
19663
  const notNull = column7.notNull;
19337
19664
  const primaryKey = column7.primary;
19338
19665
  const sqlTypeLowered = column7.getSQLType().toLowerCase();
19339
- const typeSchema = (0, import_drizzle_orm5.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
19666
+ const typeSchema = (0, import_drizzle_orm4.is)(column7, import_pg_core2.PgEnumColumn) ? column7.enum.schema || "public" : void 0;
19340
19667
  const generated = column7.generated;
19341
19668
  const identity = column7.generatedIdentity;
19342
- const increment = stringFromIdentityProperty((_g = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _g.increment) ?? "1";
19343
- const minValue = stringFromIdentityProperty((_h = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _h.minValue) ?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column7.columnType) : "1");
19344
- const maxValue = stringFromIdentityProperty((_i = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _i.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : maxRangeForIdentityBasedOn(column7.getSQLType()));
19345
- const startWith = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
19346
- const cache = stringFromIdentityProperty((_k = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _k.cache) ?? "1";
19669
+ const increment = stringFromIdentityProperty((_j = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _j.increment) ?? "1";
19670
+ const minValue = stringFromIdentityProperty((_k = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _k.minValue) ?? (parseFloat(increment) < 0 ? minRangeForIdentityBasedOn(column7.columnType) : "1");
19671
+ const maxValue = stringFromIdentityProperty((_l = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _l.maxValue) ?? (parseFloat(increment) < 0 ? "-1" : maxRangeForIdentityBasedOn(column7.getSQLType()));
19672
+ const startWith = stringFromIdentityProperty((_m = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _m.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
19673
+ const cache = stringFromIdentityProperty((_n = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _n.cache) ?? "1";
19347
19674
  const columnToSet = {
19348
19675
  name: column7.name,
19349
19676
  type: column7.getSQLType(),
@@ -19351,7 +19678,7 @@ ${withStyle.errorWarning(
19351
19678
  primaryKey,
19352
19679
  notNull,
19353
19680
  generated: generated ? {
19354
- as: (0, import_drizzle_orm5.is)(generated.as, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
19681
+ as: (0, import_drizzle_orm4.is)(generated.as, import_drizzle_orm4.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
19355
19682
  type: "stored"
19356
19683
  } : void 0,
19357
19684
  identity: identity ? {
@@ -19363,7 +19690,7 @@ ${withStyle.errorWarning(
19363
19690
  minValue,
19364
19691
  maxValue,
19365
19692
  cache,
19366
- cycle: ((_l = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _l.cycle) ?? false
19693
+ cycle: ((_o = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _o.cycle) ?? false
19367
19694
  } : void 0
19368
19695
  };
19369
19696
  if (column7.isUnique) {
@@ -19388,7 +19715,7 @@ ${withStyle.errorWarning(
19388
19715
  };
19389
19716
  }
19390
19717
  if (column7.default !== void 0) {
19391
- if ((0, import_drizzle_orm5.is)(column7.default, import_drizzle_orm5.SQL)) {
19718
+ if ((0, import_drizzle_orm4.is)(column7.default, import_drizzle_orm4.SQL)) {
19392
19719
  columnToSet.default = sqlToStr(column7.default, casing2);
19393
19720
  } else {
19394
19721
  if (typeof column7.default === "string") {
@@ -19454,6 +19781,8 @@ ${withStyle.errorWarning(
19454
19781
  enums: enumsToReturn,
19455
19782
  schemas: schemasObject,
19456
19783
  sequences: sequencesToReturn,
19784
+ roles: rolesToReturn,
19785
+ policies: policiesToReturn,
19457
19786
  views: resultViews,
19458
19787
  _meta: {
19459
19788
  schemas: {},
@@ -19471,7 +19800,7 @@ ${withStyle.errorWarning(
19471
19800
  --end;
19472
19801
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
19473
19802
  };
19474
- fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
19803
+ fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback) => {
19475
19804
  const result = {};
19476
19805
  const views = {};
19477
19806
  const internals = { tables: {} };
@@ -19484,7 +19813,8 @@ ${withStyle.errorWarning(
19484
19813
  WHEN c.relkind = 'r' THEN 'table'
19485
19814
  WHEN c.relkind = 'v' THEN 'view'
19486
19815
  WHEN c.relkind = 'm' THEN 'materialized_view'
19487
- END AS type
19816
+ END AS type,
19817
+ c.relrowsecurity AS rls_enabled
19488
19818
  FROM
19489
19819
  pg_catalog.pg_class c
19490
19820
  JOIN
@@ -19570,6 +19900,64 @@ WHERE
19570
19900
  if (progressCallback) {
19571
19901
  progressCallback("enums", Object.keys(enumsToReturn).length, "done");
19572
19902
  }
19903
+ const allRoles = await db.query(
19904
+ `SELECT rolname, rolinherit, rolcreatedb, rolcreaterole FROM pg_roles;`
19905
+ );
19906
+ const rolesToReturn = {};
19907
+ const preparedRoles = prepareRoles(entities);
19908
+ if (preparedRoles.useRoles || !(preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)) {
19909
+ for (const dbRole of allRoles) {
19910
+ if (preparedRoles.useRoles) {
19911
+ rolesToReturn[dbRole.rolname] = {
19912
+ createDb: dbRole.rolcreatedb,
19913
+ createRole: dbRole.rolcreatedb,
19914
+ inherit: dbRole.rolinherit,
19915
+ name: dbRole.rolname
19916
+ };
19917
+ } else {
19918
+ if (preparedRoles.includeRoles.length === 0 && preparedRoles.excludeRoles.length === 0)
19919
+ continue;
19920
+ if (preparedRoles.includeRoles.includes(dbRole.rolname) && preparedRoles.excludeRoles.includes(dbRole.rolname))
19921
+ continue;
19922
+ if (preparedRoles.excludeRoles.includes(dbRole.rolname))
19923
+ continue;
19924
+ if (!preparedRoles.includeRoles.includes(dbRole.rolname))
19925
+ continue;
19926
+ rolesToReturn[dbRole.rolname] = {
19927
+ createDb: dbRole.rolcreatedb,
19928
+ createRole: dbRole.rolcreaterole,
19929
+ inherit: dbRole.rolinherit,
19930
+ name: dbRole.rolname
19931
+ };
19932
+ }
19933
+ }
19934
+ }
19935
+ const wherePolicies = schemaFilters.map((t2) => `schemaname = '${t2}'`).join(" or ");
19936
+ const policiesByTable = {};
19937
+ const allPolicies = await db.query(`SELECT schemaname, tablename, policyname as name, permissive as "as", roles as to, cmd as for, qual as using, with_check as "withCheck" FROM pg_policies${wherePolicies === "" ? "" : ` WHERE ${wherePolicies}`};`);
19938
+ for (const dbPolicy of allPolicies) {
19939
+ const { tablename, schemaname, to, withCheck, using, ...rest } = dbPolicy;
19940
+ const tableForPolicy = policiesByTable[`${schemaname}.${tablename}`];
19941
+ const parsedTo = typeof to === "string" ? to.slice(1, -1).split(",") : to;
19942
+ const parsedWithCheck = withCheck === null ? void 0 : withCheck;
19943
+ const parsedUsing = using === null ? void 0 : using;
19944
+ if (tableForPolicy) {
19945
+ tableForPolicy[dbPolicy.name] = { ...rest, to: parsedTo };
19946
+ } else {
19947
+ policiesByTable[`${schemaname}.${tablename}`] = {
19948
+ [dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
19949
+ };
19950
+ }
19951
+ }
19952
+ if (progressCallback) {
19953
+ progressCallback(
19954
+ "policies",
19955
+ Object.values(policiesByTable).reduce((total, innerRecord) => {
19956
+ return total + Object.keys(innerRecord).length;
19957
+ }, 0),
19958
+ "done"
19959
+ );
19960
+ }
19573
19961
  const sequencesInColumns = [];
19574
19962
  const all = allTables.filter((it) => it.type === "table").map((row) => {
19575
19963
  return new Promise(async (res, rej) => {
@@ -19934,7 +20322,7 @@ WHERE
19934
20322
  }
19935
20323
  ],
19936
20324
  isUnique: indexIsUnique,
19937
- // should not be a part of diff detecs
20325
+ // should not be a part of diff detects
19938
20326
  concurrently: false,
19939
20327
  method: indexMethod,
19940
20328
  where: indexWhere === null ? void 0 : indexWhere,
@@ -19954,7 +20342,9 @@ WHERE
19954
20342
  foreignKeys: foreignKeysToReturn,
19955
20343
  compositePrimaryKeys: primaryKeys,
19956
20344
  uniqueConstraints: uniqueConstrains,
19957
- checkConstraints
20345
+ checkConstraints,
20346
+ policies: policiesByTable[`${tableSchema}.${tableName}`] ?? {},
20347
+ isRLSEnabled: row.rls_enabled
19958
20348
  };
19959
20349
  } catch (e2) {
19960
20350
  rej(e2);
@@ -20154,6 +20544,8 @@ WHERE
20154
20544
  enums: enumsToReturn,
20155
20545
  schemas: schemasObject,
20156
20546
  sequences: sequencesToReturn,
20547
+ roles: rolesToReturn,
20548
+ policies: {},
20157
20549
  views,
20158
20550
  _meta: {
20159
20551
  schemas: {},
@@ -20311,11 +20703,11 @@ __export(sqliteImports_exports, {
20311
20703
  prepareFromExports: () => prepareFromExports3,
20312
20704
  prepareFromSqliteImports: () => prepareFromSqliteImports
20313
20705
  });
20314
- var import_drizzle_orm6, import_sqlite_core, prepareFromExports3, prepareFromSqliteImports;
20706
+ var import_drizzle_orm5, import_sqlite_core, prepareFromExports3, prepareFromSqliteImports;
20315
20707
  var init_sqliteImports = __esm({
20316
20708
  "src/serializer/sqliteImports.ts"() {
20317
20709
  "use strict";
20318
- import_drizzle_orm6 = require("drizzle-orm");
20710
+ import_drizzle_orm5 = require("drizzle-orm");
20319
20711
  import_sqlite_core = require("drizzle-orm/sqlite-core");
20320
20712
  init_utils4();
20321
20713
  prepareFromExports3 = (exports2) => {
@@ -20323,10 +20715,10 @@ var init_sqliteImports = __esm({
20323
20715
  const views = [];
20324
20716
  const i0values = Object.values(exports2);
20325
20717
  i0values.forEach((t2) => {
20326
- if ((0, import_drizzle_orm6.is)(t2, import_sqlite_core.SQLiteTable)) {
20718
+ if ((0, import_drizzle_orm5.is)(t2, import_sqlite_core.SQLiteTable)) {
20327
20719
  tables.push(t2);
20328
20720
  }
20329
- if ((0, import_drizzle_orm6.is)(t2, import_sqlite_core.SQLiteView)) {
20721
+ if ((0, import_drizzle_orm5.is)(t2, import_sqlite_core.SQLiteView)) {
20330
20722
  views.push(t2);
20331
20723
  }
20332
20724
  });
@@ -20416,16 +20808,15 @@ function extractGeneratedColumns(input) {
20416
20808
  }
20417
20809
  return columns;
20418
20810
  }
20419
- var import_drizzle_orm7, import_sqlite_core2, generateSqliteSnapshot, fromDatabase3;
20811
+ var import_drizzle_orm6, import_sqlite_core2, generateSqliteSnapshot, fromDatabase3;
20420
20812
  var init_sqliteSerializer = __esm({
20421
20813
  "src/serializer/sqliteSerializer.ts"() {
20422
20814
  "use strict";
20423
20815
  init_source();
20424
- import_drizzle_orm7 = require("drizzle-orm");
20816
+ import_drizzle_orm6 = require("drizzle-orm");
20425
20817
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
20426
20818
  init_outputs();
20427
- init_utils();
20428
- init_serializer();
20819
+ init_utils5();
20429
20820
  generateSqliteSnapshot = (tables, views, casing2) => {
20430
20821
  const dialect4 = new import_sqlite_core2.SQLiteSyncDialect({ casing: casing2 });
20431
20822
  const result = {};
@@ -20458,14 +20849,14 @@ var init_sqliteSerializer = __esm({
20458
20849
  type: column7.getSQLType(),
20459
20850
  primaryKey,
20460
20851
  notNull,
20461
- autoincrement: (0, import_drizzle_orm7.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
20852
+ autoincrement: (0, import_drizzle_orm6.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
20462
20853
  generated: generated ? {
20463
- as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
20854
+ as: (0, import_drizzle_orm6.is)(generated.as, import_drizzle_orm6.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
20464
20855
  type: generated.mode ?? "virtual"
20465
20856
  } : void 0
20466
20857
  };
20467
20858
  if (column7.default !== void 0) {
20468
- if ((0, import_drizzle_orm7.is)(column7.default, import_drizzle_orm7.SQL)) {
20859
+ if ((0, import_drizzle_orm6.is)(column7.default, import_drizzle_orm6.SQL)) {
20469
20860
  columnToSet.default = sqlToStr(column7.default, casing2);
20470
20861
  } else {
20471
20862
  columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
@@ -20504,7 +20895,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
20504
20895
  const onUpdate = fk4.onUpdate ?? "no action";
20505
20896
  const reference = fk4.reference();
20506
20897
  const referenceFT = reference.foreignTable;
20507
- const tableTo = (0, import_drizzle_orm7.getTableName)(referenceFT);
20898
+ const tableTo = (0, import_drizzle_orm6.getTableName)(referenceFT);
20508
20899
  const originalColumnsFrom = reference.columns.map((it) => it.name);
20509
20900
  const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
20510
20901
  const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
@@ -20536,7 +20927,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
20536
20927
  const name = value.config.name;
20537
20928
  let indexColumns = columns2.map((it) => {
20538
20929
  var _a;
20539
- if ((0, import_drizzle_orm7.is)(it, import_drizzle_orm7.SQL)) {
20930
+ if ((0, import_drizzle_orm6.is)(it, import_drizzle_orm6.SQL)) {
20540
20931
  const sql = dialect4.sqlToQuery(it, "indexes").sql;
20541
20932
  if (typeof internal.indexes[name] === "undefined") {
20542
20933
  internal.indexes[name] = {
@@ -20562,7 +20953,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
20562
20953
  });
20563
20954
  let where = void 0;
20564
20955
  if (value.config.where !== void 0) {
20565
- if ((0, import_drizzle_orm7.is)(value.config.where, import_drizzle_orm7.SQL)) {
20956
+ if ((0, import_drizzle_orm6.is)(value.config.where, import_drizzle_orm6.SQL)) {
20566
20957
  where = dialect4.sqlToQuery(value.config.where).sql;
20567
20958
  }
20568
20959
  }
@@ -20671,7 +21062,7 @@ ${withStyle.errorWarning(
20671
21062
  process.exit(1);
20672
21063
  }
20673
21064
  for (const key in selectedFields) {
20674
- if ((0, import_drizzle_orm7.is)(selectedFields[key], import_sqlite_core2.SQLiteColumn)) {
21065
+ if ((0, import_drizzle_orm6.is)(selectedFields[key], import_sqlite_core2.SQLiteColumn)) {
20675
21066
  const column7 = selectedFields[key];
20676
21067
  const notNull = column7.notNull;
20677
21068
  const primaryKey = column7.primary;
@@ -20681,14 +21072,14 @@ ${withStyle.errorWarning(
20681
21072
  type: column7.getSQLType(),
20682
21073
  primaryKey,
20683
21074
  notNull,
20684
- autoincrement: (0, import_drizzle_orm7.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
21075
+ autoincrement: (0, import_drizzle_orm6.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
20685
21076
  generated: generated ? {
20686
- as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
21077
+ as: (0, import_drizzle_orm6.is)(generated.as, import_drizzle_orm6.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
20687
21078
  type: generated.mode ?? "virtual"
20688
21079
  } : void 0
20689
21080
  };
20690
21081
  if (column7.default !== void 0) {
20691
- if ((0, import_drizzle_orm7.is)(column7.default, import_drizzle_orm7.SQL)) {
21082
+ if ((0, import_drizzle_orm6.is)(column7.default, import_drizzle_orm6.SQL)) {
20692
21083
  columnToSet.default = sqlToStr(column7.default, casing2);
20693
21084
  } else {
20694
21085
  columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
@@ -21025,30 +21416,15 @@ WHERE
21025
21416
  });
21026
21417
 
21027
21418
  // src/serializer/index.ts
21028
- var import_casing2, import_fs3, glob, import_path3, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
21419
+ var import_fs3, glob, import_path3, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
21029
21420
  var init_serializer = __esm({
21030
21421
  "src/serializer/index.ts"() {
21031
21422
  "use strict";
21032
21423
  init_source();
21033
- import_casing2 = require("drizzle-orm/casing");
21034
21424
  import_fs3 = __toESM(require("fs"));
21035
21425
  glob = __toESM(require_glob());
21036
21426
  import_path3 = __toESM(require("path"));
21037
21427
  init_views();
21038
- sqlToStr = (sql, casing2) => {
21039
- return sql.toQuery({
21040
- escapeName: () => {
21041
- throw new Error("we don't support params for `sql` default values");
21042
- },
21043
- escapeParam: () => {
21044
- throw new Error("we don't support params for `sql` default values");
21045
- },
21046
- escapeString: () => {
21047
- throw new Error("we don't support params for `sql` default values");
21048
- },
21049
- casing: new import_casing2.CasingCache(casing2)
21050
- }).sql;
21051
- };
21052
21428
  serializeMySql = async (path5, casing2) => {
21053
21429
  const filenames = prepareFilenames(path5);
21054
21430
  console.log(source_default.gray(`Reading schema files:
@@ -21063,10 +21439,10 @@ ${filenames.join("\n")}
21063
21439
  const filenames = prepareFilenames(path5);
21064
21440
  const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
21065
21441
  const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
21066
- const { tables, enums, schemas, sequences, views, matViews } = await prepareFromPgImports2(
21442
+ const { tables, enums, schemas, sequences, views, matViews, roles, policies } = await prepareFromPgImports2(
21067
21443
  filenames
21068
21444
  );
21069
- return generatePgSnapshot2(tables, enums, schemas, sequences, views, matViews, casing2, schemaFilter);
21445
+ return generatePgSnapshot2(tables, enums, schemas, sequences, roles, policies, views, matViews, casing2, schemaFilter);
21070
21446
  };
21071
21447
  serializeSQLite = async (path5, casing2) => {
21072
21448
  const filenames = prepareFilenames(path5);
@@ -21261,57 +21637,57 @@ var require_heap = __commonJS({
21261
21637
  }
21262
21638
  return [].splice.apply(a, [lo, lo - lo].concat(x2)), x2;
21263
21639
  };
21264
- heappush = function(array, item, cmp) {
21640
+ heappush = function(array2, item, cmp) {
21265
21641
  if (cmp == null) {
21266
21642
  cmp = defaultCmp;
21267
21643
  }
21268
- array.push(item);
21269
- return _siftdown(array, 0, array.length - 1, cmp);
21644
+ array2.push(item);
21645
+ return _siftdown(array2, 0, array2.length - 1, cmp);
21270
21646
  };
21271
- heappop = function(array, cmp) {
21647
+ heappop = function(array2, cmp) {
21272
21648
  var lastelt, returnitem;
21273
21649
  if (cmp == null) {
21274
21650
  cmp = defaultCmp;
21275
21651
  }
21276
- lastelt = array.pop();
21277
- if (array.length) {
21278
- returnitem = array[0];
21279
- array[0] = lastelt;
21280
- _siftup(array, 0, cmp);
21652
+ lastelt = array2.pop();
21653
+ if (array2.length) {
21654
+ returnitem = array2[0];
21655
+ array2[0] = lastelt;
21656
+ _siftup(array2, 0, cmp);
21281
21657
  } else {
21282
21658
  returnitem = lastelt;
21283
21659
  }
21284
21660
  return returnitem;
21285
21661
  };
21286
- heapreplace = function(array, item, cmp) {
21662
+ heapreplace = function(array2, item, cmp) {
21287
21663
  var returnitem;
21288
21664
  if (cmp == null) {
21289
21665
  cmp = defaultCmp;
21290
21666
  }
21291
- returnitem = array[0];
21292
- array[0] = item;
21293
- _siftup(array, 0, cmp);
21667
+ returnitem = array2[0];
21668
+ array2[0] = item;
21669
+ _siftup(array2, 0, cmp);
21294
21670
  return returnitem;
21295
21671
  };
21296
- heappushpop = function(array, item, cmp) {
21672
+ heappushpop = function(array2, item, cmp) {
21297
21673
  var _ref;
21298
21674
  if (cmp == null) {
21299
21675
  cmp = defaultCmp;
21300
21676
  }
21301
- if (array.length && cmp(array[0], item) < 0) {
21302
- _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];
21303
- _siftup(array, 0, cmp);
21677
+ if (array2.length && cmp(array2[0], item) < 0) {
21678
+ _ref = [array2[0], item], item = _ref[0], array2[0] = _ref[1];
21679
+ _siftup(array2, 0, cmp);
21304
21680
  }
21305
21681
  return item;
21306
21682
  };
21307
- heapify = function(array, cmp) {
21683
+ heapify = function(array2, cmp) {
21308
21684
  var i2, _i, _j, _len, _ref, _ref1, _results, _results1;
21309
21685
  if (cmp == null) {
21310
21686
  cmp = defaultCmp;
21311
21687
  }
21312
21688
  _ref1 = function() {
21313
21689
  _results1 = [];
21314
- for (var _j2 = 0, _ref2 = floor(array.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
21690
+ for (var _j2 = 0, _ref2 = floor(array2.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
21315
21691
  _results1.push(_j2);
21316
21692
  }
21317
21693
  return _results1;
@@ -21319,51 +21695,51 @@ var require_heap = __commonJS({
21319
21695
  _results = [];
21320
21696
  for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
21321
21697
  i2 = _ref1[_i];
21322
- _results.push(_siftup(array, i2, cmp));
21698
+ _results.push(_siftup(array2, i2, cmp));
21323
21699
  }
21324
21700
  return _results;
21325
21701
  };
21326
- updateItem = function(array, item, cmp) {
21702
+ updateItem = function(array2, item, cmp) {
21327
21703
  var pos;
21328
21704
  if (cmp == null) {
21329
21705
  cmp = defaultCmp;
21330
21706
  }
21331
- pos = array.indexOf(item);
21707
+ pos = array2.indexOf(item);
21332
21708
  if (pos === -1) {
21333
21709
  return;
21334
21710
  }
21335
- _siftdown(array, 0, pos, cmp);
21336
- return _siftup(array, pos, cmp);
21711
+ _siftdown(array2, 0, pos, cmp);
21712
+ return _siftup(array2, pos, cmp);
21337
21713
  };
21338
- nlargest = function(array, n, cmp) {
21714
+ nlargest = function(array2, n, cmp) {
21339
21715
  var elem, result, _i, _len, _ref;
21340
21716
  if (cmp == null) {
21341
21717
  cmp = defaultCmp;
21342
21718
  }
21343
- result = array.slice(0, n);
21719
+ result = array2.slice(0, n);
21344
21720
  if (!result.length) {
21345
21721
  return result;
21346
21722
  }
21347
21723
  heapify(result, cmp);
21348
- _ref = array.slice(n);
21724
+ _ref = array2.slice(n);
21349
21725
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
21350
21726
  elem = _ref[_i];
21351
21727
  heappushpop(result, elem, cmp);
21352
21728
  }
21353
21729
  return result.sort(cmp).reverse();
21354
21730
  };
21355
- nsmallest = function(array, n, cmp) {
21731
+ nsmallest = function(array2, n, cmp) {
21356
21732
  var elem, i2, los, result, _i, _j, _len, _ref, _ref1, _results;
21357
21733
  if (cmp == null) {
21358
21734
  cmp = defaultCmp;
21359
21735
  }
21360
- if (n * 10 <= array.length) {
21361
- result = array.slice(0, n).sort(cmp);
21736
+ if (n * 10 <= array2.length) {
21737
+ result = array2.slice(0, n).sort(cmp);
21362
21738
  if (!result.length) {
21363
21739
  return result;
21364
21740
  }
21365
21741
  los = result[result.length - 1];
21366
- _ref = array.slice(n);
21742
+ _ref = array2.slice(n);
21367
21743
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
21368
21744
  elem = _ref[_i];
21369
21745
  if (cmp(elem, los) < 0) {
@@ -21374,51 +21750,51 @@ var require_heap = __commonJS({
21374
21750
  }
21375
21751
  return result;
21376
21752
  }
21377
- heapify(array, cmp);
21753
+ heapify(array2, cmp);
21378
21754
  _results = [];
21379
- for (i2 = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i2 = 0 <= _ref1 ? ++_j : --_j) {
21380
- _results.push(heappop(array, cmp));
21755
+ for (i2 = _j = 0, _ref1 = min(n, array2.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i2 = 0 <= _ref1 ? ++_j : --_j) {
21756
+ _results.push(heappop(array2, cmp));
21381
21757
  }
21382
21758
  return _results;
21383
21759
  };
21384
- _siftdown = function(array, startpos, pos, cmp) {
21760
+ _siftdown = function(array2, startpos, pos, cmp) {
21385
21761
  var newitem, parent, parentpos;
21386
21762
  if (cmp == null) {
21387
21763
  cmp = defaultCmp;
21388
21764
  }
21389
- newitem = array[pos];
21765
+ newitem = array2[pos];
21390
21766
  while (pos > startpos) {
21391
21767
  parentpos = pos - 1 >> 1;
21392
- parent = array[parentpos];
21768
+ parent = array2[parentpos];
21393
21769
  if (cmp(newitem, parent) < 0) {
21394
- array[pos] = parent;
21770
+ array2[pos] = parent;
21395
21771
  pos = parentpos;
21396
21772
  continue;
21397
21773
  }
21398
21774
  break;
21399
21775
  }
21400
- return array[pos] = newitem;
21776
+ return array2[pos] = newitem;
21401
21777
  };
21402
- _siftup = function(array, pos, cmp) {
21778
+ _siftup = function(array2, pos, cmp) {
21403
21779
  var childpos, endpos, newitem, rightpos, startpos;
21404
21780
  if (cmp == null) {
21405
21781
  cmp = defaultCmp;
21406
21782
  }
21407
- endpos = array.length;
21783
+ endpos = array2.length;
21408
21784
  startpos = pos;
21409
- newitem = array[pos];
21785
+ newitem = array2[pos];
21410
21786
  childpos = 2 * pos + 1;
21411
21787
  while (childpos < endpos) {
21412
21788
  rightpos = childpos + 1;
21413
- if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {
21789
+ if (rightpos < endpos && !(cmp(array2[childpos], array2[rightpos]) < 0)) {
21414
21790
  childpos = rightpos;
21415
21791
  }
21416
- array[pos] = array[childpos];
21792
+ array2[pos] = array2[childpos];
21417
21793
  pos = childpos;
21418
21794
  childpos = 2 * pos + 1;
21419
21795
  }
21420
- array[pos] = newitem;
21421
- return _siftdown(array, startpos, pos, cmp);
21796
+ array2[pos] = newitem;
21797
+ return _siftdown(array2, startpos, pos, cmp);
21422
21798
  };
21423
21799
  Heap = function() {
21424
21800
  Heap2.push = heappush;
@@ -23331,12 +23707,12 @@ var require_lib = __commonJS({
23331
23707
  }
23332
23708
  return bestMatch;
23333
23709
  }
23334
- scalarize(array, originals, fuzzyOriginals) {
23710
+ scalarize(array2, originals, fuzzyOriginals) {
23335
23711
  const fuzzyMatches = [];
23336
23712
  if (fuzzyOriginals) {
23337
23713
  const keyScores = {};
23338
- for (let index4 = 0; index4 < array.length; index4++) {
23339
- const item = array[index4];
23714
+ for (let index4 = 0; index4 < array2.length; index4++) {
23715
+ const item = array2[index4];
23340
23716
  if (this.isScalar(item)) {
23341
23717
  continue;
23342
23718
  }
@@ -23350,8 +23726,8 @@ var require_lib = __commonJS({
23350
23726
  }
23351
23727
  }
23352
23728
  const result = [];
23353
- for (let index4 = 0; index4 < array.length; index4++) {
23354
- const item = array[index4];
23729
+ for (let index4 = 0; index4 < array2.length; index4++) {
23730
+ const item = array2[index4];
23355
23731
  if (this.isScalar(item)) {
23356
23732
  result.push(item);
23357
23733
  } else {
@@ -23542,6 +23918,14 @@ function diffSchemasOrTables(left, right) {
23542
23918
  const deleted = result.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
23543
23919
  return { added, deleted };
23544
23920
  }
23921
+ function diffIndPolicies(left, right) {
23922
+ left = JSON.parse(JSON.stringify(left));
23923
+ right = JSON.parse(JSON.stringify(right));
23924
+ const result = Object.entries((0, import_json_diff.diff)(left, right) ?? {});
23925
+ const added = result.filter((it) => it[0].endsWith("__added")).map((it) => it[1]);
23926
+ const deleted = result.filter((it) => it[0].endsWith("__deleted")).map((it) => it[1]);
23927
+ return { added, deleted };
23928
+ }
23545
23929
  function diffColumns(left, right) {
23546
23930
  left = JSON.parse(JSON.stringify(left));
23547
23931
  right = JSON.parse(JSON.stringify(right));
@@ -23573,6 +23957,37 @@ function diffColumns(left, right) {
23573
23957
  );
23574
23958
  return alteredTables;
23575
23959
  }
23960
+ function diffPolicies(left, right) {
23961
+ left = JSON.parse(JSON.stringify(left));
23962
+ right = JSON.parse(JSON.stringify(right));
23963
+ const result = (0, import_json_diff.diff)(left, right) ?? {};
23964
+ const alteredTables = Object.fromEntries(
23965
+ Object.entries(result).filter((it) => {
23966
+ return !(it[0].includes("__added") || it[0].includes("__deleted"));
23967
+ }).map((tableEntry) => {
23968
+ const deletedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
23969
+ return it[0].endsWith("__deleted");
23970
+ }).map((it) => {
23971
+ return it[1];
23972
+ });
23973
+ const addedPolicies = Object.entries(tableEntry[1].policies ?? {}).filter((it) => {
23974
+ return it[0].endsWith("__added");
23975
+ }).map((it) => {
23976
+ return it[1];
23977
+ });
23978
+ tableEntry[1].policies = {
23979
+ added: addedPolicies,
23980
+ deleted: deletedPolicies
23981
+ };
23982
+ const table4 = left[tableEntry[0]];
23983
+ return [
23984
+ tableEntry[0],
23985
+ { name: table4.name, schema: table4.schema, ...tableEntry[1] }
23986
+ ];
23987
+ })
23988
+ );
23989
+ return alteredTables;
23990
+ }
23576
23991
  function applyJsonDiff(json1, json2) {
23577
23992
  json1 = JSON.parse(JSON.stringify(json1));
23578
23993
  json2 = JSON.parse(JSON.stringify(json2));
@@ -23582,6 +23997,8 @@ function applyJsonDiff(json1, json2) {
23582
23997
  difference.tables = difference.tables || {};
23583
23998
  difference.enums = difference.enums || {};
23584
23999
  difference.sequences = difference.sequences || {};
24000
+ difference.roles = difference.roles || {};
24001
+ difference.policies = difference.policies || {};
23585
24002
  difference.views = difference.views || {};
23586
24003
  const schemaKeys = Object.keys(difference.schemas);
23587
24004
  for (let key of schemaKeys) {
@@ -23638,6 +24055,14 @@ function applyJsonDiff(json1, json2) {
23638
24055
  const alteredSequences = sequencesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted")) && "values" in it[1]).map((it) => {
23639
24056
  return json2.sequences[it[0]];
23640
24057
  });
24058
+ const rolesEntries = Object.entries(difference.roles);
24059
+ const alteredRoles = rolesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
24060
+ return json2.roles[it[0]];
24061
+ });
24062
+ const policiesEntries = Object.entries(difference.policies);
24063
+ const alteredPolicies = policiesEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map((it) => {
24064
+ return json2.policies[it[0]];
24065
+ });
23641
24066
  const viewsEntries = Object.entries(difference.views);
23642
24067
  const alteredViews = viewsEntries.filter((it) => !(it[0].includes("__added") || it[0].includes("__deleted"))).map(
23643
24068
  ([nameWithSchema, view4]) => {
@@ -23717,7 +24142,9 @@ function applyJsonDiff(json1, json2) {
23717
24142
  alteredTablesWithColumns,
23718
24143
  alteredEnums,
23719
24144
  alteredSequences,
23720
- alteredViews
24145
+ alteredRoles,
24146
+ alteredViews,
24147
+ alteredPolicies
23721
24148
  };
23722
24149
  }
23723
24150
  var import_json_diff, mapArraysDiff, findAlternationsInTable, alternationsInColumn;
@@ -23777,6 +24204,21 @@ var init_jsonDiffer = __esm({
23777
24204
  return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
23778
24205
  })
23779
24206
  );
24207
+ const deletedPolicies = Object.fromEntries(
24208
+ Object.entries(table4.policies__deleted || {}).concat(
24209
+ Object.entries(table4.policies || {}).filter((it) => it[0].includes("__deleted"))
24210
+ ).map((entry) => [entry[0].replace("__deleted", ""), entry[1]])
24211
+ );
24212
+ const addedPolicies = Object.fromEntries(
24213
+ Object.entries(table4.policies__added || {}).concat(
24214
+ Object.entries(table4.policies || {}).filter((it) => it[0].includes("__added"))
24215
+ ).map((entry) => [entry[0].replace("__added", ""), entry[1]])
24216
+ );
24217
+ const alteredPolicies = Object.fromEntries(
24218
+ Object.entries(table4.policies || {}).filter((it) => {
24219
+ return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
24220
+ })
24221
+ );
23780
24222
  const deletedForeignKeys = Object.fromEntries(
23781
24223
  Object.entries(table4.foreignKeys__deleted || {}).concat(
23782
24224
  Object.entries(table4.foreignKeys || {}).filter((it) => it[0].includes("__deleted"))
@@ -23854,6 +24296,9 @@ var init_jsonDiffer = __esm({
23854
24296
  addedUniqueConstraints,
23855
24297
  deletedUniqueConstraints,
23856
24298
  alteredUniqueConstraints,
24299
+ deletedPolicies,
24300
+ addedPolicies,
24301
+ alteredPolicies,
23857
24302
  addedCheckConstraints,
23858
24303
  deletedCheckConstraints,
23859
24304
  alteredCheckConstraints
@@ -24156,7 +24601,7 @@ function fromJson(statements, dialect4, action, json2) {
24156
24601
  }).filter((it) => it !== "");
24157
24602
  return result;
24158
24603
  }
24159
- var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
24604
+ var pgNativeTypes, isPgNativeType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
24160
24605
  var init_sqlgenerator = __esm({
24161
24606
  "src/sqlgenerator.ts"() {
24162
24607
  "use strict";
@@ -24213,12 +24658,154 @@ var init_sqlgenerator = __esm({
24213
24658
  };
24214
24659
  Convertor = class {
24215
24660
  };
24661
+ PgCreateRoleConvertor = class extends Convertor {
24662
+ can(statement, dialect4) {
24663
+ return statement.type === "create_role" && dialect4 === "postgresql";
24664
+ }
24665
+ convert(statement) {
24666
+ return `CREATE ROLE "${statement.name}"${statement.values.createDb || statement.values.createRole || !statement.values.inherit ? ` WITH${statement.values.createDb ? " CREATEDB" : ""}${statement.values.createRole ? " CREATEROLE" : ""}${statement.values.inherit ? "" : " NOINHERIT"}` : ""};`;
24667
+ }
24668
+ };
24669
+ PgDropRoleConvertor = class extends Convertor {
24670
+ can(statement, dialect4) {
24671
+ return statement.type === "drop_role" && dialect4 === "postgresql";
24672
+ }
24673
+ convert(statement) {
24674
+ return `DROP ROLE "${statement.name}";`;
24675
+ }
24676
+ };
24677
+ PgRenameRoleConvertor = class extends Convertor {
24678
+ can(statement, dialect4) {
24679
+ return statement.type === "rename_role" && dialect4 === "postgresql";
24680
+ }
24681
+ convert(statement) {
24682
+ return `ALTER ROLE "${statement.nameFrom}" RENAME TO "${statement.nameTo}";`;
24683
+ }
24684
+ };
24685
+ PgAlterRoleConvertor = class extends Convertor {
24686
+ can(statement, dialect4) {
24687
+ return statement.type === "alter_role" && dialect4 === "postgresql";
24688
+ }
24689
+ convert(statement) {
24690
+ return `ALTER ROLE "${statement.name}"${` WITH${statement.values.createDb ? " CREATEDB" : " NOCREATEDB"}${statement.values.createRole ? " CREATEROLE" : " NOCREATEROLE"}${statement.values.inherit ? " INHERIT" : " NOINHERIT"}`};`;
24691
+ }
24692
+ };
24693
+ PgCreatePolicyConvertor = class extends Convertor {
24694
+ can(statement, dialect4) {
24695
+ return statement.type === "create_policy" && dialect4 === "postgresql";
24696
+ }
24697
+ convert(statement) {
24698
+ var _a, _b, _c;
24699
+ const policy4 = statement.data;
24700
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24701
+ const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
24702
+ const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
24703
+ const policyToPart = (_a = policy4.to) == null ? void 0 : _a.map(
24704
+ (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
24705
+ ).join(", ");
24706
+ return `CREATE POLICY "${policy4.name}" ON ${tableNameWithSchema} AS ${(_b = policy4.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy4.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
24707
+ }
24708
+ };
24709
+ PgDropPolicyConvertor = class extends Convertor {
24710
+ can(statement, dialect4) {
24711
+ return statement.type === "drop_policy" && dialect4 === "postgresql";
24712
+ }
24713
+ convert(statement) {
24714
+ const policy4 = statement.data;
24715
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24716
+ return `DROP POLICY "${policy4.name}" ON ${tableNameWithSchema} CASCADE;`;
24717
+ }
24718
+ };
24719
+ PgRenamePolicyConvertor = class extends Convertor {
24720
+ can(statement, dialect4) {
24721
+ return statement.type === "rename_policy" && dialect4 === "postgresql";
24722
+ }
24723
+ convert(statement) {
24724
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24725
+ return `ALTER POLICY "${statement.oldName}" ON ${tableNameWithSchema} RENAME TO "${statement.newName}";`;
24726
+ }
24727
+ };
24728
+ PgAlterPolicyConvertor = class extends Convertor {
24729
+ can(statement, dialect4) {
24730
+ return statement.type === "alter_policy" && dialect4 === "postgresql";
24731
+ }
24732
+ convert(statement) {
24733
+ const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
24734
+ const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
24735
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24736
+ const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
24737
+ const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
24738
+ return `ALTER POLICY "${oldPolicy.name}" ON ${tableNameWithSchema} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
24739
+ }
24740
+ };
24741
+ PgCreateIndPolicyConvertor = class extends Convertor {
24742
+ can(statement, dialect4) {
24743
+ return statement.type === "create_ind_policy" && dialect4 === "postgresql";
24744
+ }
24745
+ convert(statement) {
24746
+ var _a, _b, _c;
24747
+ const policy4 = statement.data;
24748
+ const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
24749
+ const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
24750
+ const policyToPart = (_a = policy4.to) == null ? void 0 : _a.map(
24751
+ (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
24752
+ ).join(", ");
24753
+ return `CREATE POLICY "${policy4.name}" ON ${policy4.on} AS ${(_b = policy4.as) == null ? void 0 : _b.toUpperCase()} FOR ${(_c = policy4.for) == null ? void 0 : _c.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
24754
+ }
24755
+ };
24756
+ PgDropIndPolicyConvertor = class extends Convertor {
24757
+ can(statement, dialect4) {
24758
+ return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
24759
+ }
24760
+ convert(statement) {
24761
+ const policy4 = statement.data;
24762
+ return `DROP POLICY "${policy4.name}" ON ${policy4.on} CASCADE;`;
24763
+ }
24764
+ };
24765
+ PgRenameIndPolicyConvertor = class extends Convertor {
24766
+ can(statement, dialect4) {
24767
+ return statement.type === "rename_ind_policy" && dialect4 === "postgresql";
24768
+ }
24769
+ convert(statement) {
24770
+ return `ALTER POLICY "${statement.oldName}" ON ${statement.tableKey} RENAME TO "${statement.newName}";`;
24771
+ }
24772
+ };
24773
+ PgAlterIndPolicyConvertor = class extends Convertor {
24774
+ can(statement, dialect4) {
24775
+ return statement.type === "alter_ind_policy" && dialect4 === "postgresql";
24776
+ }
24777
+ convert(statement) {
24778
+ const newPolicy = statement.newData;
24779
+ const oldPolicy = statement.oldData;
24780
+ const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
24781
+ const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
24782
+ return `ALTER POLICY "${oldPolicy.name}" ON ${oldPolicy.on} TO ${newPolicy.to}${usingPart}${withCheckPart};`;
24783
+ }
24784
+ };
24785
+ PgEnableRlsConvertor = class extends Convertor {
24786
+ can(statement, dialect4) {
24787
+ return statement.type === "enable_rls" && dialect4 === "postgresql";
24788
+ }
24789
+ convert(statement) {
24790
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24791
+ return `ALTER TABLE ${tableNameWithSchema} ENABLE ROW LEVEL SECURITY;`;
24792
+ }
24793
+ };
24794
+ PgDisableRlsConvertor = class extends Convertor {
24795
+ can(statement, dialect4) {
24796
+ return statement.type === "disable_rls" && dialect4 === "postgresql";
24797
+ }
24798
+ convert(statement) {
24799
+ const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
24800
+ return `ALTER TABLE ${tableNameWithSchema} DISABLE ROW LEVEL SECURITY;`;
24801
+ }
24802
+ };
24216
24803
  PgCreateTableConvertor = class extends Convertor {
24217
24804
  can(statement, dialect4) {
24218
24805
  return statement.type === "create_table" && dialect4 === "postgresql";
24219
24806
  }
24220
24807
  convert(st) {
24221
- const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints } = st;
24808
+ const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = st;
24222
24809
  let statement = "";
24223
24810
  const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
24224
24811
  statement += `CREATE TABLE IF NOT EXISTS ${name} (
@@ -24262,7 +24849,12 @@ var init_sqlgenerator = __esm({
24262
24849
  );`;
24263
24850
  statement += `
24264
24851
  `;
24265
- return statement;
24852
+ const enableRls = new PgEnableRlsConvertor().convert({
24853
+ type: "enable_rls",
24854
+ tableName,
24855
+ schema: schema5
24856
+ });
24857
+ return [statement, ...policies && policies.length > 0 || isRLSEnabled ? [enableRls] : []];
24266
24858
  }
24267
24859
  };
24268
24860
  MySqlCreateTableConvertor = class extends Convertor {
@@ -24867,9 +25459,21 @@ WITH ${withCheckOption} CHECK OPTION` : "";
24867
25459
  return statement.type === "drop_table" && dialect4 === "postgresql";
24868
25460
  }
24869
25461
  convert(statement) {
24870
- const { tableName, schema: schema5 } = statement;
25462
+ const { tableName, schema: schema5, policies } = statement;
24871
25463
  const tableNameWithSchema = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
24872
- return `DROP TABLE ${tableNameWithSchema};`;
25464
+ const dropPolicyConvertor = new PgDropPolicyConvertor();
25465
+ const droppedPolicies = (policies == null ? void 0 : policies.map((p2) => {
25466
+ return dropPolicyConvertor.convert({
25467
+ type: "drop_policy",
25468
+ tableName,
25469
+ data: PgSquasher.unsquashPolicy(p2),
25470
+ schema: schema5
25471
+ });
25472
+ })) ?? [];
25473
+ return [
25474
+ ...droppedPolicies,
25475
+ `DROP TABLE ${tableNameWithSchema} CASCADE;`
25476
+ ];
24873
25477
  }
24874
25478
  };
24875
25479
  MySQLDropTableConvertor = class extends Convertor {
@@ -26074,6 +26678,20 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
26074
26678
  convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
26075
26679
  convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
26076
26680
  convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
26681
+ convertors.push(new PgAlterPolicyConvertor());
26682
+ convertors.push(new PgCreatePolicyConvertor());
26683
+ convertors.push(new PgDropPolicyConvertor());
26684
+ convertors.push(new PgRenamePolicyConvertor());
26685
+ convertors.push(new PgAlterIndPolicyConvertor());
26686
+ convertors.push(new PgCreateIndPolicyConvertor());
26687
+ convertors.push(new PgDropIndPolicyConvertor());
26688
+ convertors.push(new PgRenameIndPolicyConvertor());
26689
+ convertors.push(new PgEnableRlsConvertor());
26690
+ convertors.push(new PgDisableRlsConvertor());
26691
+ convertors.push(new PgDropRoleConvertor());
26692
+ convertors.push(new PgAlterRoleConvertor());
26693
+ convertors.push(new PgCreateRoleConvertor());
26694
+ convertors.push(new PgRenameRoleConvertor());
26077
26695
  convertors.push(new PgAlterTableAlterColumnSetExpressionConvertor());
26078
26696
  convertors.push(new PgAlterTableAlterColumnDropGeneratedConvertor());
26079
26697
  convertors.push(new PgAlterTableAlterColumnAlterrGeneratedConvertor());
@@ -26374,7 +26992,7 @@ var init_sqlitePushUtils = __esm({
26374
26992
  });
26375
26993
 
26376
26994
  // src/jsonStatements.ts
26377
- var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView;
26995
+ var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateRoleJson, prepareAlterRoleJson, prepareDropRoleJson, prepareRenameRoleJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, prepareRenamePolicyJsons, prepareRenameIndPolicyJsons, prepareCreatePolicyJsons, prepareCreateIndPolicyJsons, prepareDropPolicyJsons, prepareDropIndPolicyJsons, prepareAlterPolicyJson, prepareAlterIndPolicyJson, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql, preparePgCreateViewJson, prepareMySqlCreateViewJson, prepareSqliteCreateViewJson, prepareDropViewJson, prepareRenameViewJson, preparePgAlterViewAlterSchemaJson, preparePgAlterViewAddWithOptionJson, preparePgAlterViewDropWithOptionJson, preparePgAlterViewAlterTablespaceJson, preparePgAlterViewAlterUsingJson, prepareMySqlAlterView;
26378
26996
  var init_jsonStatements = __esm({
26379
26997
  "src/jsonStatements.ts"() {
26380
26998
  "use strict";
@@ -26385,7 +27003,7 @@ var init_jsonStatements = __esm({
26385
27003
  init_pgSchema();
26386
27004
  init_sqliteSchema();
26387
27005
  preparePgCreateTableJson = (table4, json2) => {
26388
- const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
27006
+ const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints, policies, isRLSEnabled } = table4;
26389
27007
  const tableKey2 = `${schema5 || "public"}.${name}`;
26390
27008
  const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
26391
27009
  return {
@@ -26396,7 +27014,9 @@ var init_jsonStatements = __esm({
26396
27014
  compositePKs: Object.values(compositePrimaryKeys),
26397
27015
  compositePkName,
26398
27016
  uniqueConstraints: Object.values(uniqueConstraints),
26399
- checkConstraints: Object.values(checkConstraints)
27017
+ policies: Object.values(policies),
27018
+ checkConstraints: Object.values(checkConstraints),
27019
+ isRLSEnabled: isRLSEnabled ?? false
26400
27020
  };
26401
27021
  };
26402
27022
  prepareMySqlCreateTableJson = (table4, json2, internals) => {
@@ -26436,7 +27056,8 @@ var init_jsonStatements = __esm({
26436
27056
  return {
26437
27057
  type: "drop_table",
26438
27058
  tableName: table4.name,
26439
- schema: table4.schema
27059
+ schema: table4.schema,
27060
+ policies: table4.policies ? Object.values(table4.policies) : []
26440
27061
  };
26441
27062
  };
26442
27063
  prepareRenameTableJson = (tableFrom, tableTo) => {
@@ -26555,6 +27176,41 @@ var init_jsonStatements = __esm({
26555
27176
  schema: schema5
26556
27177
  };
26557
27178
  };
27179
+ prepareCreateRoleJson = (role) => {
27180
+ return {
27181
+ type: "create_role",
27182
+ name: role.name,
27183
+ values: {
27184
+ createDb: role.createDb,
27185
+ createRole: role.createRole,
27186
+ inherit: role.inherit
27187
+ }
27188
+ };
27189
+ };
27190
+ prepareAlterRoleJson = (role) => {
27191
+ return {
27192
+ type: "alter_role",
27193
+ name: role.name,
27194
+ values: {
27195
+ createDb: role.createDb,
27196
+ createRole: role.createRole,
27197
+ inherit: role.inherit
27198
+ }
27199
+ };
27200
+ };
27201
+ prepareDropRoleJson = (name) => {
27202
+ return {
27203
+ type: "drop_role",
27204
+ name
27205
+ };
27206
+ };
27207
+ prepareRenameRoleJson = (nameFrom, nameTo) => {
27208
+ return {
27209
+ type: "rename_role",
27210
+ nameFrom,
27211
+ nameTo
27212
+ };
27213
+ };
26558
27214
  prepareCreateSchemasJson = (values) => {
26559
27215
  return values.map((it) => {
26560
27216
  return {
@@ -27455,6 +28111,81 @@ var init_jsonStatements = __esm({
27455
28111
  }
27456
28112
  return [...dropPkStatements, ...setPkStatements, ...statements];
27457
28113
  };
28114
+ prepareRenamePolicyJsons = (tableName, schema5, renames) => {
28115
+ return renames.map((it) => {
28116
+ return {
28117
+ type: "rename_policy",
28118
+ tableName,
28119
+ oldName: it.from.name,
28120
+ newName: it.to.name,
28121
+ schema: schema5
28122
+ };
28123
+ });
28124
+ };
28125
+ prepareRenameIndPolicyJsons = (renames) => {
28126
+ return renames.map((it) => {
28127
+ return {
28128
+ type: "rename_ind_policy",
28129
+ tableKey: it.from.on,
28130
+ oldName: it.from.name,
28131
+ newName: it.to.name
28132
+ };
28133
+ });
28134
+ };
28135
+ prepareCreatePolicyJsons = (tableName, schema5, policies) => {
28136
+ return policies.map((it) => {
28137
+ return {
28138
+ type: "create_policy",
28139
+ tableName,
28140
+ data: it,
28141
+ schema: schema5
28142
+ };
28143
+ });
28144
+ };
28145
+ prepareCreateIndPolicyJsons = (policies) => {
28146
+ return policies.map((it) => {
28147
+ return {
28148
+ type: "create_ind_policy",
28149
+ tableName: it.on,
28150
+ data: it
28151
+ };
28152
+ });
28153
+ };
28154
+ prepareDropPolicyJsons = (tableName, schema5, policies) => {
28155
+ return policies.map((it) => {
28156
+ return {
28157
+ type: "drop_policy",
28158
+ tableName,
28159
+ data: it,
28160
+ schema: schema5
28161
+ };
28162
+ });
28163
+ };
28164
+ prepareDropIndPolicyJsons = (policies) => {
28165
+ return policies.map((it) => {
28166
+ return {
28167
+ type: "drop_ind_policy",
28168
+ tableName: it.on,
28169
+ data: it
28170
+ };
28171
+ });
28172
+ };
28173
+ prepareAlterPolicyJson = (tableName, schema5, oldPolicy, newPolicy) => {
28174
+ return {
28175
+ type: "alter_policy",
28176
+ tableName,
28177
+ oldData: oldPolicy,
28178
+ newData: newPolicy,
28179
+ schema: schema5
28180
+ };
28181
+ };
28182
+ prepareAlterIndPolicyJson = (oldPolicy, newPolicy) => {
28183
+ return {
28184
+ type: "alter_ind_policy",
28185
+ oldData: oldPolicy,
28186
+ newData: newPolicy
28187
+ };
28188
+ };
27458
28189
  preparePgCreateIndexesJson = (tableName, schema5, indexes, fullSchema, action) => {
27459
28190
  if (action === "push") {
27460
28191
  return Object.values(indexes).map((indexData) => {
@@ -28253,7 +28984,9 @@ var init_snapshotsDiffer = __esm({
28253
28984
  foreignKeys: recordType(stringType(), stringType()),
28254
28985
  compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
28255
28986
  uniqueConstraints: recordType(stringType(), stringType()).default({}),
28256
- checkConstraints: recordType(stringType(), stringType()).default({})
28987
+ policies: recordType(stringType(), stringType()).default({}),
28988
+ checkConstraints: recordType(stringType(), stringType()).default({}),
28989
+ isRLSEnabled: booleanType().default(false)
28257
28990
  }).strict();
28258
28991
  alteredTableScheme = objectType({
28259
28992
  name: stringType(),
@@ -28295,6 +29028,15 @@ var init_snapshotsDiffer = __esm({
28295
29028
  __old: stringType()
28296
29029
  })
28297
29030
  ),
29031
+ addedPolicies: recordType(stringType(), stringType()),
29032
+ deletedPolicies: recordType(stringType(), stringType()),
29033
+ alteredPolicies: recordType(
29034
+ stringType(),
29035
+ objectType({
29036
+ __new: stringType(),
29037
+ __old: stringType()
29038
+ })
29039
+ ),
28298
29040
  addedCheckConstraints: recordType(
28299
29041
  stringType(),
28300
29042
  stringType()
@@ -28356,6 +29098,8 @@ var init_snapshotsDiffer = __esm({
28356
29098
  alteredTablesWithColumns: alteredTableScheme.array(),
28357
29099
  alteredEnums: changedEnumSchema.array(),
28358
29100
  alteredSequences: sequenceSquashed.array(),
29101
+ alteredRoles: roleSchema.array(),
29102
+ alteredPolicies: policySquashed.array(),
28359
29103
  alteredViews: alteredPgViewSchema.array()
28360
29104
  }).strict();
28361
29105
  diffResultSchemeMysql = objectType({
@@ -28413,7 +29157,7 @@ var init_snapshotsDiffer = __esm({
28413
29157
  }
28414
29158
  return column7;
28415
29159
  };
28416
- applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
29160
+ applyPgSnapshotsDiff = async (json1, json2, schemasResolver2, enumsResolver2, sequencesResolver2, policyResolver2, indPolicyResolver2, roleResolver2, tablesResolver2, columnsResolver2, viewsResolver2, prevFull, curFull, action) => {
28417
29161
  const schemasDiff = diffSchemasOrTables(json1.schemas, json2.schemas);
28418
29162
  const {
28419
29163
  created: createdSchemas,
@@ -28563,6 +29307,47 @@ var init_snapshotsDiffer = __esm({
28563
29307
  return [tableKey2, tableValue];
28564
29308
  }
28565
29309
  );
29310
+ const rolesDiff = diffSchemasOrTables(
29311
+ schemasPatchedSnap1.roles,
29312
+ json2.roles
29313
+ );
29314
+ const {
29315
+ created: createdRoles,
29316
+ deleted: deletedRoles,
29317
+ renamed: renamedRoles
29318
+ } = await roleResolver2({
29319
+ created: rolesDiff.added,
29320
+ deleted: rolesDiff.deleted
29321
+ });
29322
+ schemasPatchedSnap1.roles = mapEntries(
29323
+ schemasPatchedSnap1.roles,
29324
+ (_2, it) => {
29325
+ const { name } = nameChangeFor(it, renamedRoles);
29326
+ it.name = name;
29327
+ return [name, it];
29328
+ }
29329
+ );
29330
+ const rolesChangeMap = renamedRoles.reduce(
29331
+ (acc, it) => {
29332
+ acc[it.from.name] = {
29333
+ nameFrom: it.from.name,
29334
+ nameTo: it.to.name
29335
+ };
29336
+ return acc;
29337
+ },
29338
+ {}
29339
+ );
29340
+ schemasPatchedSnap1.roles = mapEntries(
29341
+ schemasPatchedSnap1.roles,
29342
+ (roleKey, roleValue) => {
29343
+ const key = roleKey;
29344
+ const change = rolesChangeMap[key];
29345
+ if (change) {
29346
+ roleValue.name = change.nameTo;
29347
+ }
29348
+ return [roleKey, roleValue];
29349
+ }
29350
+ );
28566
29351
  const tablesDiff = diffSchemasOrTables(
28567
29352
  schemasPatchedSnap1.tables,
28568
29353
  json2.tables
@@ -28589,24 +29374,24 @@ var init_snapshotsDiffer = __esm({
28589
29374
  const columnCreates = [];
28590
29375
  const columnDeletes = [];
28591
29376
  for (let entry of Object.values(res)) {
28592
- const { renamed, created, deleted } = await columnsResolver2({
29377
+ const { renamed, created: created2, deleted: deleted2 } = await columnsResolver2({
28593
29378
  tableName: entry.name,
28594
29379
  schema: entry.schema,
28595
29380
  deleted: entry.columns.deleted,
28596
29381
  created: entry.columns.added
28597
29382
  });
28598
- if (created.length > 0) {
29383
+ if (created2.length > 0) {
28599
29384
  columnCreates.push({
28600
29385
  table: entry.name,
28601
29386
  schema: entry.schema,
28602
- columns: created
29387
+ columns: created2
28603
29388
  });
28604
29389
  }
28605
- if (deleted.length > 0) {
29390
+ if (deleted2.length > 0) {
28606
29391
  columnDeletes.push({
28607
29392
  table: entry.name,
28608
29393
  schema: entry.schema,
28609
- columns: deleted
29394
+ columns: deleted2
28610
29395
  });
28611
29396
  }
28612
29397
  if (renamed.length > 0) {
@@ -28641,7 +29426,105 @@ var init_snapshotsDiffer = __esm({
28641
29426
  return [tableKey2, tableValue];
28642
29427
  }
28643
29428
  );
28644
- const viewsDiff = diffSchemasOrTables(json1.views, json2.views);
29429
+ const policyRes = diffPolicies(tablesPatchedSnap1.tables, json2.tables);
29430
+ const policyRenames = [];
29431
+ const policyCreates = [];
29432
+ const policyDeletes = [];
29433
+ for (let entry of Object.values(policyRes)) {
29434
+ const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
29435
+ tableName: entry.name,
29436
+ schema: entry.schema,
29437
+ deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
29438
+ created: entry.policies.added.map(PgSquasher.unsquashPolicy)
29439
+ });
29440
+ if (created2.length > 0) {
29441
+ policyCreates.push({
29442
+ table: entry.name,
29443
+ schema: entry.schema,
29444
+ columns: created2
29445
+ });
29446
+ }
29447
+ if (deleted2.length > 0) {
29448
+ policyDeletes.push({
29449
+ table: entry.name,
29450
+ schema: entry.schema,
29451
+ columns: deleted2
29452
+ });
29453
+ }
29454
+ if (renamed.length > 0) {
29455
+ policyRenames.push({
29456
+ table: entry.name,
29457
+ schema: entry.schema,
29458
+ renames: renamed
29459
+ });
29460
+ }
29461
+ }
29462
+ const policyRenamesDict = columnRenames.reduce(
29463
+ (acc, it) => {
29464
+ acc[`${it.schema || "public"}.${it.table}`] = it.renames;
29465
+ return acc;
29466
+ },
29467
+ {}
29468
+ );
29469
+ const policyPatchedSnap1 = copy(tablesPatchedSnap1);
29470
+ policyPatchedSnap1.tables = mapEntries(
29471
+ policyPatchedSnap1.tables,
29472
+ (tableKey2, tableValue) => {
29473
+ const patchedPolicies = mapKeys(
29474
+ tableValue.policies,
29475
+ (policyKey, policy4) => {
29476
+ const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
29477
+ const newName = columnChangeFor(policyKey, rens);
29478
+ const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
29479
+ unsquashedPolicy.name = newName;
29480
+ policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
29481
+ return newName;
29482
+ }
29483
+ );
29484
+ tableValue.policies = patchedPolicies;
29485
+ return [tableKey2, tableValue];
29486
+ }
29487
+ );
29488
+ const indPolicyRes = diffIndPolicies(policyPatchedSnap1.policies, json2.policies);
29489
+ const indPolicyCreates = [];
29490
+ const indPolicyDeletes = [];
29491
+ const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
29492
+ deleted: indPolicyRes.deleted.map((t2) => PgSquasher.unsquashPolicy(t2.values)),
29493
+ created: indPolicyRes.added.map((t2) => PgSquasher.unsquashPolicy(t2.values))
29494
+ });
29495
+ if (created.length > 0) {
29496
+ indPolicyCreates.push({
29497
+ policies: created
29498
+ });
29499
+ }
29500
+ if (deleted.length > 0) {
29501
+ indPolicyDeletes.push({
29502
+ policies: deleted
29503
+ });
29504
+ }
29505
+ const indPolicyRenamesDict = indPolicyRenames.reduce(
29506
+ (acc, it) => {
29507
+ acc[it.from.name] = {
29508
+ nameFrom: it.from.name,
29509
+ nameTo: it.to.name
29510
+ };
29511
+ return acc;
29512
+ },
29513
+ {}
29514
+ );
29515
+ const indPolicyPatchedSnap1 = copy(policyPatchedSnap1);
29516
+ indPolicyPatchedSnap1.policies = mapEntries(
29517
+ indPolicyPatchedSnap1.policies,
29518
+ (policyKey, policyValue) => {
29519
+ const key = policyKey;
29520
+ const change = indPolicyRenamesDict[key];
29521
+ if (change) {
29522
+ policyValue.name = change.nameTo;
29523
+ }
29524
+ return [policyKey, policyValue];
29525
+ }
29526
+ );
29527
+ const viewsDiff = diffSchemasOrTables(indPolicyPatchedSnap1.views, json2.views);
28645
29528
  const {
28646
29529
  created: createdViews,
28647
29530
  deleted: deletedViews,
@@ -28659,7 +29542,7 @@ var init_snapshotsDiffer = __esm({
28659
29542
  movedViews.forEach((it) => {
28660
29543
  movedViewDic[`${it.schemaFrom}.${it.name}`] = { to: it.schemaTo, from: it.schemaFrom };
28661
29544
  });
28662
- const viewsPatchedSnap1 = copy(columnsPatchedSnap1);
29545
+ const viewsPatchedSnap1 = copy(policyPatchedSnap1);
28663
29546
  viewsPatchedSnap1.views = mapEntries(
28664
29547
  viewsPatchedSnap1.views,
28665
29548
  (viewKey, viewValue) => {
@@ -28718,13 +29601,15 @@ var init_snapshotsDiffer = __esm({
28718
29601
  const jsonDeletedUniqueConstraints = [];
28719
29602
  const jsonAlteredUniqueConstraints = [];
28720
29603
  const jsonSetTableSchemas = [];
28721
- for (let it of movedTables) {
28722
- jsonSetTableSchemas.push({
28723
- type: "alter_table_set_schema",
28724
- tableName: it.name,
28725
- schemaFrom: it.schemaFrom || "public",
28726
- schemaTo: it.schemaTo || "public"
28727
- });
29604
+ if (movedTables) {
29605
+ for (let it of movedTables) {
29606
+ jsonSetTableSchemas.push({
29607
+ type: "alter_table_set_schema",
29608
+ tableName: it.name,
29609
+ schemaFrom: it.schemaFrom || "public",
29610
+ schemaTo: it.schemaTo || "public"
29611
+ });
29612
+ }
28728
29613
  }
28729
29614
  const jsonDeletedCheckConstraints = [];
28730
29615
  const jsonCreatedCheckConstraints = [];
@@ -28781,16 +29666,16 @@ var init_snapshotsDiffer = __esm({
28781
29666
  );
28782
29667
  if (it.alteredUniqueConstraints) {
28783
29668
  const added = {};
28784
- const deleted = {};
29669
+ const deleted2 = {};
28785
29670
  for (const k of Object.keys(it.alteredUniqueConstraints)) {
28786
29671
  added[k] = it.alteredUniqueConstraints[k].__new;
28787
- deleted[k] = it.alteredUniqueConstraints[k].__old;
29672
+ deleted2[k] = it.alteredUniqueConstraints[k].__old;
28788
29673
  }
28789
29674
  addedUniqueConstraints.push(
28790
29675
  ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
28791
29676
  );
28792
29677
  deletedUniqueConstraints.push(
28793
- ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
29678
+ ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted2)
28794
29679
  );
28795
29680
  }
28796
29681
  createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
@@ -28801,13 +29686,13 @@ var init_snapshotsDiffer = __esm({
28801
29686
  );
28802
29687
  if (it.alteredCheckConstraints && action !== "push") {
28803
29688
  const added = {};
28804
- const deleted = {};
29689
+ const deleted2 = {};
28805
29690
  for (const k of Object.keys(it.alteredCheckConstraints)) {
28806
29691
  added[k] = it.alteredCheckConstraints[k].__new;
28807
- deleted[k] = it.alteredCheckConstraints[k].__old;
29692
+ deleted2[k] = it.alteredCheckConstraints[k].__old;
28808
29693
  }
28809
29694
  createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
28810
- deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
29695
+ deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted2));
28811
29696
  }
28812
29697
  jsonCreatedCheckConstraints.push(...createCheckConstraints);
28813
29698
  jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
@@ -28851,7 +29736,166 @@ var init_snapshotsDiffer = __esm({
28851
29736
  it.deletedIndexes || {}
28852
29737
  );
28853
29738
  }).flat();
29739
+ const jsonCreatePoliciesStatements = [];
29740
+ const jsonDropPoliciesStatements = [];
29741
+ const jsonAlterPoliciesStatements = [];
29742
+ const jsonRenamePoliciesStatements = [];
29743
+ const jsonRenameIndPoliciesStatements = [];
29744
+ const jsonCreateIndPoliciesStatements = [];
29745
+ const jsonDropIndPoliciesStatements = [];
29746
+ const jsonAlterIndPoliciesStatements = [];
29747
+ const jsonEnableRLSStatements = [];
29748
+ const jsonDisableRLSStatements = [];
29749
+ for (let it of indPolicyRenames) {
29750
+ jsonRenameIndPoliciesStatements.push(
29751
+ ...prepareRenameIndPolicyJsons([it])
29752
+ );
29753
+ }
29754
+ for (const it of indPolicyCreates) {
29755
+ jsonCreateIndPoliciesStatements.push(
29756
+ ...prepareCreateIndPolicyJsons(
29757
+ it.policies
29758
+ )
29759
+ );
29760
+ }
29761
+ for (const it of indPolicyDeletes) {
29762
+ jsonDropIndPoliciesStatements.push(
29763
+ ...prepareDropIndPolicyJsons(
29764
+ it.policies
29765
+ )
29766
+ );
29767
+ }
29768
+ typedResult.alteredPolicies.forEach(({ values }) => {
29769
+ const policy4 = PgSquasher.unsquashPolicy(values);
29770
+ const newPolicy = PgSquasher.unsquashPolicy(json2.policies[policy4.name].values);
29771
+ const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
29772
+ if (newPolicy.as !== oldPolicy.as) {
29773
+ jsonDropIndPoliciesStatements.push(
29774
+ ...prepareDropIndPolicyJsons(
29775
+ [oldPolicy]
29776
+ )
29777
+ );
29778
+ jsonCreateIndPoliciesStatements.push(
29779
+ ...prepareCreateIndPolicyJsons(
29780
+ [newPolicy]
29781
+ )
29782
+ );
29783
+ return;
29784
+ }
29785
+ if (newPolicy.for !== oldPolicy.for) {
29786
+ jsonDropIndPoliciesStatements.push(
29787
+ ...prepareDropIndPolicyJsons(
29788
+ [oldPolicy]
29789
+ )
29790
+ );
29791
+ jsonCreateIndPoliciesStatements.push(
29792
+ ...prepareCreateIndPolicyJsons(
29793
+ [newPolicy]
29794
+ )
29795
+ );
29796
+ return;
29797
+ }
29798
+ jsonAlterIndPoliciesStatements.push(
29799
+ prepareAlterIndPolicyJson(
29800
+ oldPolicy,
29801
+ newPolicy
29802
+ )
29803
+ );
29804
+ });
29805
+ for (let it of policyRenames) {
29806
+ jsonRenamePoliciesStatements.push(
29807
+ ...prepareRenamePolicyJsons(it.table, it.schema, it.renames)
29808
+ );
29809
+ }
29810
+ for (const it of policyCreates) {
29811
+ jsonCreatePoliciesStatements.push(
29812
+ ...prepareCreatePolicyJsons(
29813
+ it.table,
29814
+ it.schema,
29815
+ it.columns
29816
+ )
29817
+ );
29818
+ }
29819
+ for (const it of policyDeletes) {
29820
+ jsonDropPoliciesStatements.push(
29821
+ ...prepareDropPolicyJsons(
29822
+ it.table,
29823
+ it.schema,
29824
+ it.columns
29825
+ )
29826
+ );
29827
+ }
28854
29828
  alteredTables.forEach((it) => {
29829
+ Object.keys(it.alteredPolicies).forEach((policyName) => {
29830
+ const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
29831
+ const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
29832
+ if (newPolicy.as !== oldPolicy.as) {
29833
+ jsonDropPoliciesStatements.push(
29834
+ ...prepareDropPolicyJsons(
29835
+ it.name,
29836
+ it.schema,
29837
+ [oldPolicy]
29838
+ )
29839
+ );
29840
+ jsonCreatePoliciesStatements.push(
29841
+ ...prepareCreatePolicyJsons(
29842
+ it.name,
29843
+ it.schema,
29844
+ [newPolicy]
29845
+ )
29846
+ );
29847
+ return;
29848
+ }
29849
+ if (newPolicy.for !== oldPolicy.for) {
29850
+ jsonDropPoliciesStatements.push(
29851
+ ...prepareDropPolicyJsons(
29852
+ it.name,
29853
+ it.schema,
29854
+ [oldPolicy]
29855
+ )
29856
+ );
29857
+ jsonCreatePoliciesStatements.push(
29858
+ ...prepareCreatePolicyJsons(
29859
+ it.name,
29860
+ it.schema,
29861
+ [newPolicy]
29862
+ )
29863
+ );
29864
+ return;
29865
+ }
29866
+ jsonAlterPoliciesStatements.push(
29867
+ prepareAlterPolicyJson(
29868
+ it.name,
29869
+ it.schema,
29870
+ it.alteredPolicies[policyName].__old,
29871
+ it.alteredPolicies[policyName].__new
29872
+ )
29873
+ );
29874
+ });
29875
+ for (const table4 of Object.values(json2.tables)) {
29876
+ const policiesInCurrentState = Object.keys(table4.policies);
29877
+ const tableInPreviousState = columnsPatchedSnap1.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
29878
+ const policiesInPreviousState = tableInPreviousState ? Object.keys(tableInPreviousState.policies) : [];
29879
+ if (policiesInPreviousState.length === 0 && policiesInCurrentState.length > 0 && !table4.isRLSEnabled) {
29880
+ jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
29881
+ }
29882
+ if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
29883
+ jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
29884
+ }
29885
+ if (table4.isRLSEnabled !== tableInPreviousState.isRLSEnabled) {
29886
+ if (table4.isRLSEnabled) {
29887
+ jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
29888
+ } else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
29889
+ jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
29890
+ }
29891
+ }
29892
+ }
29893
+ for (const table4 of Object.values(columnsPatchedSnap1.tables)) {
29894
+ const tableInCurrentState = json2.tables[`${table4.schema === "" ? "public" : table4.schema}.${table4.name}`];
29895
+ if (tableInCurrentState === void 0 && !table4.isRLSEnabled) {
29896
+ jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
29897
+ }
29898
+ }
28855
29899
  const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
28856
29900
  (current, item) => {
28857
29901
  current[item] = it.alteredIndexes[item].__old;
@@ -28939,6 +29983,18 @@ var init_snapshotsDiffer = __esm({
28939
29983
  const jsonAlterSequences = typedResult.alteredSequences.map((it) => {
28940
29984
  return prepareAlterSequenceJson(it);
28941
29985
  }).flat() ?? [];
29986
+ const createRoles = createdRoles.map((it) => {
29987
+ return prepareCreateRoleJson(it);
29988
+ }) ?? [];
29989
+ const dropRoles = deletedRoles.map((it) => {
29990
+ return prepareDropRoleJson(it.name);
29991
+ });
29992
+ const renameRoles = renamedRoles.map((it) => {
29993
+ return prepareRenameRoleJson(it.from.name, it.to.name);
29994
+ });
29995
+ const jsonAlterRoles = typedResult.alteredRoles.map((it) => {
29996
+ return prepareAlterRoleJson(it);
29997
+ }).flat() ?? [];
28942
29998
  const createSchemas = prepareCreateSchemasJson(
28943
29999
  createdSchemas.map((it) => it.name)
28944
30000
  );
@@ -28951,6 +30007,11 @@ var init_snapshotsDiffer = __esm({
28951
30007
  const createTables = createdTables.map((it) => {
28952
30008
  return preparePgCreateTableJson(it, curFull);
28953
30009
  });
30010
+ jsonCreatePoliciesStatements.push(...[].concat(
30011
+ ...createdTables.map(
30012
+ (it) => prepareCreatePolicyJsons(it.name, it.schema, Object.values(it.policies).map(PgSquasher.unsquashPolicy))
30013
+ )
30014
+ ));
28954
30015
  const createViews = [];
28955
30016
  const dropViews = [];
28956
30017
  const renameViews = [];
@@ -29092,7 +30153,13 @@ var init_snapshotsDiffer = __esm({
29092
30153
  jsonStatements.push(...moveSequences);
29093
30154
  jsonStatements.push(...renameSequences);
29094
30155
  jsonStatements.push(...jsonAlterSequences);
30156
+ jsonStatements.push(...renameRoles);
30157
+ jsonStatements.push(...dropRoles);
30158
+ jsonStatements.push(...createRoles);
30159
+ jsonStatements.push(...jsonAlterRoles);
29095
30160
  jsonStatements.push(...createTables);
30161
+ jsonStatements.push(...jsonEnableRLSStatements);
30162
+ jsonStatements.push(...jsonDisableRLSStatements);
29096
30163
  jsonStatements.push(...dropViews);
29097
30164
  jsonStatements.push(...renameViews);
29098
30165
  jsonStatements.push(...alterViews);
@@ -29118,6 +30185,14 @@ var init_snapshotsDiffer = __esm({
29118
30185
  jsonStatements.push(...jsonCreatedCheckConstraints);
29119
30186
  jsonStatements.push(...jsonAlteredUniqueConstraints);
29120
30187
  jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
30188
+ jsonStatements.push(...jsonRenamePoliciesStatements);
30189
+ jsonStatements.push(...jsonDropPoliciesStatements);
30190
+ jsonStatements.push(...jsonCreatePoliciesStatements);
30191
+ jsonStatements.push(...jsonAlterPoliciesStatements);
30192
+ jsonStatements.push(...jsonRenameIndPoliciesStatements);
30193
+ jsonStatements.push(...jsonDropIndPoliciesStatements);
30194
+ jsonStatements.push(...jsonCreateIndPoliciesStatements);
30195
+ jsonStatements.push(...jsonAlterIndPoliciesStatements);
29121
30196
  jsonStatements.push(...createViews);
29122
30197
  jsonStatements.push(...dropEnums);
29123
30198
  jsonStatements.push(...dropSequences);
@@ -31702,7 +32777,9 @@ __export(migrate_exports, {
31702
32777
  columnsResolver: () => columnsResolver,
31703
32778
  embeddedMigrations: () => embeddedMigrations,
31704
32779
  enumsResolver: () => enumsResolver,
32780
+ indPolicyResolver: () => indPolicyResolver,
31705
32781
  mySqlViewsResolver: () => mySqlViewsResolver,
32782
+ policyResolver: () => policyResolver,
31706
32783
  prepareAndMigrateLibSQL: () => prepareAndMigrateLibSQL,
31707
32784
  prepareAndMigrateMysql: () => prepareAndMigrateMysql,
31708
32785
  prepareAndMigratePg: () => prepareAndMigratePg,
@@ -31713,8 +32790,10 @@ __export(migrate_exports, {
31713
32790
  prepareSQLitePush: () => prepareSQLitePush,
31714
32791
  prepareSnapshotFolderName: () => prepareSnapshotFolderName,
31715
32792
  promptColumnsConflicts: () => promptColumnsConflicts,
32793
+ promptNamedConflict: () => promptNamedConflict,
31716
32794
  promptNamedWithSchemasConflict: () => promptNamedWithSchemasConflict,
31717
32795
  promptSchemasConflict: () => promptSchemasConflict,
32796
+ roleResolver: () => roleResolver,
31718
32797
  schemasResolver: () => schemasResolver,
31719
32798
  sequencesResolver: () => sequencesResolver,
31720
32799
  sqliteViewsResolver: () => sqliteViewsResolver,
@@ -31722,7 +32801,7 @@ __export(migrate_exports, {
31722
32801
  viewsResolver: () => viewsResolver,
31723
32802
  writeResult: () => writeResult
31724
32803
  });
31725
- var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
32804
+ var import_fs5, import_hanji3, import_path4, schemasResolver, tablesResolver, viewsResolver, mySqlViewsResolver, sqliteViewsResolver, sequencesResolver, roleResolver, policyResolver, indPolicyResolver, enumsResolver, columnsResolver, prepareAndMigratePg, preparePgPush, prepareMySQLPush, prepareAndMigrateMysql, prepareAndMigrateSqlite, prepareAndMigrateLibSQL, prepareSQLitePush, prepareLibSQLPush, promptColumnsConflicts, promptNamedConflict, promptNamedWithSchemasConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
31726
32805
  var init_migrate = __esm({
31727
32806
  "src/cli/commands/migrate.ts"() {
31728
32807
  "use strict";
@@ -31841,6 +32920,44 @@ var init_migrate = __esm({
31841
32920
  throw e2;
31842
32921
  }
31843
32922
  };
32923
+ roleResolver = async (input) => {
32924
+ const result = await promptNamedConflict(
32925
+ input.created,
32926
+ input.deleted,
32927
+ "role"
32928
+ );
32929
+ return {
32930
+ created: result.created,
32931
+ deleted: result.deleted,
32932
+ renamed: result.renamed
32933
+ };
32934
+ };
32935
+ policyResolver = async (input) => {
32936
+ const result = await promptColumnsConflicts(
32937
+ input.tableName,
32938
+ input.created,
32939
+ input.deleted
32940
+ );
32941
+ return {
32942
+ tableName: input.tableName,
32943
+ schema: input.schema,
32944
+ created: result.created,
32945
+ deleted: result.deleted,
32946
+ renamed: result.renamed
32947
+ };
32948
+ };
32949
+ indPolicyResolver = async (input) => {
32950
+ const result = await promptNamedConflict(
32951
+ input.created,
32952
+ input.deleted,
32953
+ "policy"
32954
+ );
32955
+ return {
32956
+ created: result.created,
32957
+ deleted: result.deleted,
32958
+ renamed: result.renamed
32959
+ };
32960
+ };
31844
32961
  enumsResolver = async (input) => {
31845
32962
  try {
31846
32963
  const { created, deleted, moved, renamed } = await promptNamedWithSchemasConflict(
@@ -31911,6 +33028,9 @@ var init_migrate = __esm({
31911
33028
  schemasResolver,
31912
33029
  enumsResolver,
31913
33030
  sequencesResolver,
33031
+ policyResolver,
33032
+ indPolicyResolver,
33033
+ roleResolver,
31914
33034
  tablesResolver,
31915
33035
  columnsResolver,
31916
33036
  viewsResolver,
@@ -31947,6 +33067,9 @@ var init_migrate = __esm({
31947
33067
  schemasResolver,
31948
33068
  enumsResolver,
31949
33069
  sequencesResolver,
33070
+ policyResolver,
33071
+ indPolicyResolver,
33072
+ roleResolver,
31950
33073
  tablesResolver,
31951
33074
  columnsResolver,
31952
33075
  viewsResolver,
@@ -32241,6 +33364,56 @@ var init_migrate = __esm({
32241
33364
  result.deleted.push(...leftMissing);
32242
33365
  return result;
32243
33366
  };
33367
+ promptNamedConflict = async (newItems, missingItems, entity) => {
33368
+ if (missingItems.length === 0 || newItems.length === 0) {
33369
+ return {
33370
+ created: newItems,
33371
+ renamed: [],
33372
+ deleted: missingItems
33373
+ };
33374
+ }
33375
+ const result = { created: [], renamed: [], deleted: [] };
33376
+ let index4 = 0;
33377
+ let leftMissing = [...missingItems];
33378
+ do {
33379
+ const created = newItems[index4];
33380
+ const renames = leftMissing.map((it) => {
33381
+ return { from: it, to: created };
33382
+ });
33383
+ const promptData = [created, ...renames];
33384
+ const { status, data } = await (0, import_hanji3.render)(
33385
+ new ResolveSelectNamed(created, promptData, entity)
33386
+ );
33387
+ if (status === "aborted") {
33388
+ console.error("ERROR");
33389
+ process.exit(1);
33390
+ }
33391
+ if (isRenamePromptItem(data)) {
33392
+ console.log(
33393
+ `${source_default.yellow("~")} ${data.from.name} \u203A ${data.to.name} ${source_default.gray(
33394
+ `${entity} will be renamed/moved`
33395
+ )}`
33396
+ );
33397
+ if (data.from.name !== data.to.name) {
33398
+ result.renamed.push(data);
33399
+ }
33400
+ delete leftMissing[leftMissing.indexOf(data.from)];
33401
+ leftMissing = leftMissing.filter(Boolean);
33402
+ } else {
33403
+ console.log(
33404
+ `${source_default.green("+")} ${data.name} ${source_default.gray(
33405
+ `${entity} will be created`
33406
+ )}`
33407
+ );
33408
+ result.created.push(created);
33409
+ }
33410
+ index4 += 1;
33411
+ } while (index4 < newItems.length);
33412
+ console.log(source_default.gray(`--- all ${entity} conflicts resolved ---
33413
+ `));
33414
+ result.deleted.push(...leftMissing);
33415
+ return result;
33416
+ };
32244
33417
  promptNamedWithSchemasConflict = async (newItems, missingItems, entity) => {
32245
33418
  if (missingItems.length === 0 || newItems.length === 0) {
32246
33419
  return {
@@ -35156,6 +36329,28 @@ var init_dist2 = __esm({
35156
36329
  }
35157
36330
  });
35158
36331
 
36332
+ // ../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/compress/index.js
36333
+ var ENCODING_TYPES, compress;
36334
+ var init_compress = __esm({
36335
+ "../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/compress/index.js"() {
36336
+ ENCODING_TYPES = ["gzip", "deflate"];
36337
+ compress = (options) => {
36338
+ return async function compress2(ctx, next) {
36339
+ await next();
36340
+ const accepted = ctx.req.header("Accept-Encoding");
36341
+ const encoding = (options == null ? void 0 : options.encoding) ?? ENCODING_TYPES.find((encoding2) => accepted == null ? void 0 : accepted.includes(encoding2));
36342
+ if (!encoding || !ctx.res.body) {
36343
+ return;
36344
+ }
36345
+ const stream = new CompressionStream(encoding);
36346
+ ctx.res = new Response(ctx.res.body.pipeThrough(stream), ctx.res);
36347
+ ctx.res.headers.delete("Content-Length");
36348
+ ctx.res.headers.set("Content-Encoding", encoding);
36349
+ };
36350
+ };
36351
+ }
36352
+ });
36353
+
35159
36354
  // ../node_modules/.pnpm/hono@4.5.0/node_modules/hono/dist/middleware/cors/index.js
35160
36355
  var cors;
35161
36356
  var init_cors = __esm({
@@ -41069,9 +42264,9 @@ var init_body2 = __esm({
41069
42264
  // ../node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js
41070
42265
  function fromRawHeaders(headers = []) {
41071
42266
  return new Headers2(
41072
- headers.reduce((result, value, index4, array) => {
42267
+ headers.reduce((result, value, index4, array2) => {
41073
42268
  if (index4 % 2 === 0) {
41074
- result.push(array.slice(index4, index4 + 2));
42269
+ result.push(array2.slice(index4, index4 + 2));
41075
42270
  }
41076
42271
  return result;
41077
42272
  }, []).filter(([name, value]) => {
@@ -41469,7 +42664,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
41469
42664
  if (request.referrer === "no-referrer" || request.referrerPolicy === "") {
41470
42665
  return null;
41471
42666
  }
41472
- const policy = request.referrerPolicy;
42667
+ const policy4 = request.referrerPolicy;
41473
42668
  if (request.referrer === "about:client") {
41474
42669
  return "no-referrer";
41475
42670
  }
@@ -41486,7 +42681,7 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
41486
42681
  referrerOrigin = referrerOriginCallback(referrerOrigin);
41487
42682
  }
41488
42683
  const currentURL = new URL(request.url);
41489
- switch (policy) {
42684
+ switch (policy4) {
41490
42685
  case "no-referrer":
41491
42686
  return "no-referrer";
41492
42687
  case "origin":
@@ -41522,18 +42717,18 @@ function determineRequestsReferrer(request, { referrerURLCallback, referrerOrigi
41522
42717
  }
41523
42718
  return referrerURL;
41524
42719
  default:
41525
- throw new TypeError(`Invalid referrerPolicy: ${policy}`);
42720
+ throw new TypeError(`Invalid referrerPolicy: ${policy4}`);
41526
42721
  }
41527
42722
  }
41528
42723
  function parseReferrerPolicyFromHeader(headers) {
41529
42724
  const policyTokens = (headers.get("referrer-policy") || "").split(/[,\s]+/);
41530
- let policy = "";
42725
+ let policy4 = "";
41531
42726
  for (const token of policyTokens) {
41532
42727
  if (token && ReferrerPolicy.has(token)) {
41533
- policy = token;
42728
+ policy4 = token;
41534
42729
  }
41535
42730
  }
41536
- return policy;
42731
+ return policy4;
41537
42732
  }
41538
42733
  var import_node_net, ReferrerPolicy, DEFAULT_REFERRER_POLICY;
41539
42734
  var init_referrer = __esm({
@@ -44111,8 +45306,8 @@ var require_sender = __commonJS({
44111
45306
  * @param {Function} [cb] Callback
44112
45307
  * @private
44113
45308
  */
44114
- dispatch(data, compress, options, cb) {
44115
- if (!compress) {
45309
+ dispatch(data, compress2, options, cb) {
45310
+ if (!compress2) {
44116
45311
  this.sendFrame(_Sender.frame(data, options), cb);
44117
45312
  return;
44118
45313
  }
@@ -51214,12 +52409,12 @@ var require_dist_cjs32 = __commonJS({
51214
52409
  this.middlewareStack = (0, import_middleware_stack.constructStack)();
51215
52410
  this.config = config;
51216
52411
  }
51217
- send(command2, optionsOrCb, cb) {
52412
+ send(command, optionsOrCb, cb) {
51218
52413
  const options = typeof optionsOrCb !== "function" ? optionsOrCb : void 0;
51219
52414
  const callback = typeof optionsOrCb === "function" ? optionsOrCb : cb;
51220
- const handler = command2.resolveMiddleware(this.middlewareStack, this.config, options);
52415
+ const handler = command.resolveMiddleware(this.middlewareStack, this.config, options);
51221
52416
  if (callback) {
51222
- handler(command2).then(
52417
+ handler(command).then(
51223
52418
  (result) => callback(null, result.output),
51224
52419
  (err2) => callback(err2)
51225
52420
  ).catch(
@@ -51229,7 +52424,7 @@ var require_dist_cjs32 = __commonJS({
51229
52424
  }
51230
52425
  );
51231
52426
  } else {
51232
- return handler(command2).then((result) => result.output);
52427
+ return handler(command).then((result) => result.output);
51233
52428
  }
51234
52429
  }
51235
52430
  destroy() {
@@ -51429,8 +52624,8 @@ var require_dist_cjs32 = __commonJS({
51429
52624
  var ClassBuilder = _ClassBuilder;
51430
52625
  var SENSITIVE_STRING = "***SensitiveInformation***";
51431
52626
  var createAggregatedClient = /* @__PURE__ */ __name((commands, Client2) => {
51432
- for (const command2 of Object.keys(commands)) {
51433
- const CommandCtor = commands[command2];
52627
+ for (const command of Object.keys(commands)) {
52628
+ const CommandCtor = commands[command];
51434
52629
  const methodImpl = /* @__PURE__ */ __name(async function(args, optionsOrCb, cb) {
51435
52630
  const command22 = new CommandCtor(args);
51436
52631
  if (typeof optionsOrCb === "function") {
@@ -51443,7 +52638,7 @@ var require_dist_cjs32 = __commonJS({
51443
52638
  return this.send(command22, optionsOrCb);
51444
52639
  }
51445
52640
  }, "methodImpl");
51446
- const methodName = (command2[0].toLowerCase() + command2.slice(1)).replace(/Command$/, "");
52641
+ const methodName = (command[0].toLowerCase() + command.slice(1)).replace(/Command$/, "");
51447
52642
  Client2.prototype[methodName] = methodImpl;
51448
52643
  }
51449
52644
  }, "createAggregatedClient");
@@ -55656,9 +56851,9 @@ var require_node2json = __commonJS({
55656
56851
  "../node_modules/.pnpm/fast-xml-parser@4.2.5/node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports2) {
55657
56852
  "use strict";
55658
56853
  function prettify(node, options) {
55659
- return compress(node, options);
56854
+ return compress2(node, options);
55660
56855
  }
55661
- function compress(arr, options, jPath) {
56856
+ function compress2(arr, options, jPath) {
55662
56857
  let text;
55663
56858
  const compressedObj = {};
55664
56859
  for (let i2 = 0; i2 < arr.length; i2++) {
@@ -55677,7 +56872,7 @@ var require_node2json = __commonJS({
55677
56872
  } else if (property === void 0) {
55678
56873
  continue;
55679
56874
  } else if (tagObj[property]) {
55680
- let val2 = compress(tagObj[property], options, newJpath);
56875
+ let val2 = compress2(tagObj[property], options, newJpath);
55681
56876
  const isLeaf = isLeafTag(val2, options);
55682
56877
  if (tagObj[":@"]) {
55683
56878
  assignAttributes(val2, tagObj[":@"], newJpath, options);
@@ -62180,7 +63375,7 @@ var require_fromWebToken = __commonJS({
62180
63375
  var fromWebToken2 = (init2) => async () => {
62181
63376
  var _a;
62182
63377
  (_a = init2.logger) == null ? void 0 : _a.debug("@aws-sdk/credential-provider-web-identity", "fromWebToken");
62183
- const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy, durationSeconds } = init2;
63378
+ const { roleArn, roleSessionName, webIdentityToken, providerId, policyArns, policy: policy4, durationSeconds } = init2;
62184
63379
  let { roleAssumerWithWebIdentity } = init2;
62185
63380
  if (!roleAssumerWithWebIdentity) {
62186
63381
  const { getDefaultRoleAssumerWithWebIdentity } = await Promise.resolve().then(() => __importStar2(require_dist_cjs50()));
@@ -62196,7 +63391,7 @@ var require_fromWebToken = __commonJS({
62196
63391
  WebIdentityToken: webIdentityToken,
62197
63392
  ProviderId: providerId,
62198
63393
  PolicyArns: policyArns,
62199
- Policy: policy,
63394
+ Policy: policy4,
62200
63395
  DurationSeconds: durationSeconds
62201
63396
  });
62202
63397
  };
@@ -64080,7 +65275,7 @@ var init_connections = __esm({
64080
65275
  }
64081
65276
  if (driver2 === "pglite") {
64082
65277
  assertPackages("@electric-sql/pglite");
64083
- const { PGlite } = await import("@electric-sql/pglite");
65278
+ const { PGlite, types: types3 } = await import("@electric-sql/pglite");
64084
65279
  const { drizzle } = await import("drizzle-orm/pglite");
64085
65280
  const { migrate: migrate2 } = await import("drizzle-orm/pglite/migrator");
64086
65281
  const pglite = new PGlite(normalisePGliteUrl(credentials2.url));
@@ -64089,19 +65284,24 @@ var init_connections = __esm({
64089
65284
  const migrateFn = async (config) => {
64090
65285
  return migrate2(drzl, config);
64091
65286
  };
65287
+ const parsers = {
65288
+ [types3.TIMESTAMP]: (value) => value,
65289
+ [types3.TIMESTAMPTZ]: (value) => value,
65290
+ [types3.INTERVAL]: (value) => value,
65291
+ [types3.DATE]: (value) => value
65292
+ };
64092
65293
  const query = async (sql, params = []) => {
64093
- const result = await pglite.query(sql, params);
65294
+ const result = await pglite.query(sql, params, {
65295
+ parsers
65296
+ });
64094
65297
  return result.rows;
64095
65298
  };
64096
65299
  const proxy = async (params) => {
64097
65300
  const preparedParams = preparePGliteParams(params.params);
64098
- if (params.method === "values" || params.method === "get" || params.method === "all") {
64099
- const result2 = await pglite.query(params.sql, preparedParams, {
64100
- rowMode: params.mode
64101
- });
64102
- return result2.rows;
64103
- }
64104
- const result = await pglite.query(params.sql, preparedParams);
65301
+ const result = await pglite.query(params.sql, preparedParams, {
65302
+ rowMode: params.mode,
65303
+ parsers
65304
+ });
64105
65305
  return result.rows;
64106
65306
  };
64107
65307
  return { query, proxy, migrate: migrateFn };
@@ -64110,24 +65310,47 @@ var init_connections = __esm({
64110
65310
  }
64111
65311
  if (await checkPackage("pg")) {
64112
65312
  console.log(withStyle.info(`Using 'pg' driver for database querying`));
64113
- const pg = await import("pg");
65313
+ const { default: pg } = await import("pg");
64114
65314
  const { drizzle } = await import("drizzle-orm/node-postgres");
64115
65315
  const { migrate: migrate2 } = await import("drizzle-orm/node-postgres/migrator");
64116
65316
  const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
64117
- const client = "url" in credentials2 ? new pg.default.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.default.Pool({ ...credentials2, ssl, max: 1 });
65317
+ const types3 = {
65318
+ // @ts-ignore
65319
+ getTypeParser: (typeId, format) => {
65320
+ if (typeId === pg.types.builtins.TIMESTAMPTZ) {
65321
+ return (val2) => val2;
65322
+ }
65323
+ if (typeId === pg.types.builtins.TIMESTAMP) {
65324
+ return (val2) => val2;
65325
+ }
65326
+ if (typeId === pg.types.builtins.DATE) {
65327
+ return (val2) => val2;
65328
+ }
65329
+ if (typeId === pg.types.builtins.INTERVAL) {
65330
+ return (val2) => val2;
65331
+ }
65332
+ return pg.types.getTypeParser(typeId, format);
65333
+ }
65334
+ };
65335
+ const client = "url" in credentials2 ? new pg.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.Pool({ ...credentials2, ssl, max: 1 });
64118
65336
  const db = drizzle(client);
64119
65337
  const migrateFn = async (config) => {
64120
65338
  return migrate2(db, config);
64121
65339
  };
64122
65340
  const query = async (sql, params) => {
64123
- const result = await client.query(sql, params ?? []);
65341
+ const result = await client.query({
65342
+ text: sql,
65343
+ values: params ?? [],
65344
+ types: types3
65345
+ });
64124
65346
  return result.rows;
64125
65347
  };
64126
65348
  const proxy = async (params) => {
64127
65349
  const result = await client.query({
64128
65350
  text: params.sql,
64129
65351
  values: params.params,
64130
- ...params.mode === "array" && { rowMode: "array" }
65352
+ ...params.mode === "array" && { rowMode: "array" },
65353
+ types: types3
64131
65354
  });
64132
65355
  return result.rows;
64133
65356
  };
@@ -64141,6 +65364,13 @@ var init_connections = __esm({
64141
65364
  const { drizzle } = await import("drizzle-orm/postgres-js");
64142
65365
  const { migrate: migrate2 } = await import("drizzle-orm/postgres-js/migrator");
64143
65366
  const client = "url" in credentials2 ? postgres.default(credentials2.url, { max: 1 }) : postgres.default({ ...credentials2, max: 1 });
65367
+ const transparentParser = (val2) => val2;
65368
+ for (const type of ["1184", "1082", "1083", "1114"]) {
65369
+ client.options.parsers[type] = transparentParser;
65370
+ client.options.serializers[type] = transparentParser;
65371
+ }
65372
+ client.options.serializers["114"] = transparentParser;
65373
+ client.options.serializers["3802"] = transparentParser;
64144
65374
  const db = drizzle(client);
64145
65375
  const migrateFn = async (config) => {
64146
65376
  return migrate2(db, config);
@@ -64166,10 +65396,28 @@ var init_connections = __esm({
64166
65396
  "'@vercel/postgres' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
64167
65397
  )
64168
65398
  );
64169
- const { VercelPool } = await import("@vercel/postgres");
65399
+ const { VercelPool, types: pgTypes } = await import("@vercel/postgres");
64170
65400
  const { drizzle } = await import("drizzle-orm/vercel-postgres");
64171
65401
  const { migrate: migrate2 } = await import("drizzle-orm/vercel-postgres/migrator");
64172
65402
  const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
65403
+ const types3 = {
65404
+ // @ts-ignore
65405
+ getTypeParser: (typeId, format) => {
65406
+ if (typeId === pgTypes.builtins.TIMESTAMPTZ) {
65407
+ return (val2) => val2;
65408
+ }
65409
+ if (typeId === pgTypes.builtins.TIMESTAMP) {
65410
+ return (val2) => val2;
65411
+ }
65412
+ if (typeId === pgTypes.builtins.DATE) {
65413
+ return (val2) => val2;
65414
+ }
65415
+ if (typeId === pgTypes.builtins.INTERVAL) {
65416
+ return (val2) => val2;
65417
+ }
65418
+ return pgTypes.getTypeParser(typeId, format);
65419
+ }
65420
+ };
64173
65421
  const client = "url" in credentials2 ? new VercelPool({ connectionString: credentials2.url }) : new VercelPool({ ...credentials2, ssl });
64174
65422
  await client.connect();
64175
65423
  const db = drizzle(client);
@@ -64177,14 +65425,19 @@ var init_connections = __esm({
64177
65425
  return migrate2(db, config);
64178
65426
  };
64179
65427
  const query = async (sql, params) => {
64180
- const result = await client.query(sql, params ?? []);
65428
+ const result = await client.query({
65429
+ text: sql,
65430
+ values: params ?? [],
65431
+ types: types3
65432
+ });
64181
65433
  return result.rows;
64182
65434
  };
64183
65435
  const proxy = async (params) => {
64184
65436
  const result = await client.query({
64185
65437
  text: params.sql,
64186
65438
  values: params.params,
64187
- ...params.mode === "array" && { rowMode: "array" }
65439
+ ...params.mode === "array" && { rowMode: "array" },
65440
+ types: types3
64188
65441
  });
64189
65442
  return result.rows;
64190
65443
  };
@@ -64201,10 +65454,28 @@ var init_connections = __esm({
64201
65454
  "'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
64202
65455
  )
64203
65456
  );
64204
- const { Pool, neonConfig } = await import("@neondatabase/serverless");
65457
+ const { Pool, neonConfig, types: pgTypes } = await import("@neondatabase/serverless");
64205
65458
  const { drizzle } = await import("drizzle-orm/neon-serverless");
64206
65459
  const { migrate: migrate2 } = await import("drizzle-orm/neon-serverless/migrator");
64207
65460
  const ssl = "ssl" in credentials2 ? credentials2.ssl === "prefer" || credentials2.ssl === "require" || credentials2.ssl === "allow" ? { rejectUnauthorized: false } : credentials2.ssl === "verify-full" ? {} : credentials2.ssl : {};
65461
+ const types3 = {
65462
+ // @ts-ignore
65463
+ getTypeParser: (typeId, format) => {
65464
+ if (typeId === pgTypes.builtins.TIMESTAMPTZ) {
65465
+ return (val2) => val2;
65466
+ }
65467
+ if (typeId === pgTypes.builtins.TIMESTAMP) {
65468
+ return (val2) => val2;
65469
+ }
65470
+ if (typeId === pgTypes.builtins.DATE) {
65471
+ return (val2) => val2;
65472
+ }
65473
+ if (typeId === pgTypes.builtins.INTERVAL) {
65474
+ return (val2) => val2;
65475
+ }
65476
+ return pgTypes.getTypeParser(typeId, format);
65477
+ }
65478
+ };
64208
65479
  const client = "url" in credentials2 ? new Pool({ connectionString: credentials2.url, max: 1 }) : new Pool({ ...credentials2, max: 1, ssl });
64209
65480
  neonConfig.webSocketConstructor = wrapper_default;
64210
65481
  const db = drizzle(client);
@@ -64212,14 +65483,19 @@ var init_connections = __esm({
64212
65483
  return migrate2(db, config);
64213
65484
  };
64214
65485
  const query = async (sql, params) => {
64215
- const result = await client.query(sql, params ?? []);
65486
+ const result = await client.query({
65487
+ text: sql,
65488
+ values: params ?? [],
65489
+ types: types3
65490
+ });
64216
65491
  return result.rows;
64217
65492
  };
64218
65493
  const proxy = async (params) => {
64219
65494
  const result = await client.query({
64220
65495
  text: params.sql,
64221
65496
  values: params.params,
64222
- ...params.mode === "array" && { rowMode: "array" }
65497
+ ...params.mode === "array" && { rowMode: "array" },
65498
+ types: types3
64223
65499
  });
64224
65500
  return result.rows;
64225
65501
  };
@@ -64261,16 +65537,27 @@ var init_connections = __esm({
64261
65537
  const migrateFn = async (config) => {
64262
65538
  return migrate2(db, config);
64263
65539
  };
65540
+ const typeCast = (field, next) => {
65541
+ if (field.type === "TIMESTAMP" || field.type === "DATETIME" || field.type === "DATE") {
65542
+ return field.string();
65543
+ }
65544
+ return next();
65545
+ };
64264
65546
  await connection.connect();
64265
65547
  const query = async (sql, params) => {
64266
- const res = await connection.execute(sql, params);
65548
+ const res = await connection.execute({
65549
+ sql,
65550
+ values: params,
65551
+ typeCast
65552
+ });
64267
65553
  return res[0];
64268
65554
  };
64269
65555
  const proxy = async (params) => {
64270
65556
  const result2 = await connection.query({
64271
65557
  sql: params.sql,
64272
65558
  values: params.params,
64273
- rowsAsArray: params.mode === "array"
65559
+ rowsAsArray: params.mode === "array",
65560
+ typeCast
64274
65561
  });
64275
65562
  return result2[0];
64276
65563
  };
@@ -64282,10 +65569,10 @@ var init_connections = __esm({
64282
65569
  };
64283
65570
  }
64284
65571
  if (await checkPackage("@planetscale/database")) {
64285
- const { connect } = await import("@planetscale/database");
65572
+ const { Client } = await import("@planetscale/database");
64286
65573
  const { drizzle } = await import("drizzle-orm/planetscale-serverless");
64287
65574
  const { migrate: migrate2 } = await import("drizzle-orm/planetscale-serverless/migrator");
64288
- const connection = connect(result);
65575
+ const connection = new Client(result);
64289
65576
  const db = drizzle(connection);
64290
65577
  const migrateFn = async (config) => {
64291
65578
  return migrate2(db, config);
@@ -64533,19 +65820,20 @@ __export(studio_exports, {
64533
65820
  prepareSQLiteSchema: () => prepareSQLiteSchema,
64534
65821
  prepareServer: () => prepareServer
64535
65822
  });
64536
- var import_crypto8, import_drizzle_orm8, import_mysql_core5, import_pg_core4, import_sqlite_core3, import_fs10, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, extractRelations, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
65823
+ var import_crypto8, import_drizzle_orm7, import_mysql_core3, import_pg_core3, import_sqlite_core3, import_fs10, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, extractRelations, init, proxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
64537
65824
  var init_studio2 = __esm({
64538
65825
  "src/serializer/studio.ts"() {
64539
65826
  "use strict";
64540
65827
  init_dist();
64541
65828
  init_esm();
64542
65829
  import_crypto8 = require("crypto");
64543
- import_drizzle_orm8 = require("drizzle-orm");
64544
- import_mysql_core5 = require("drizzle-orm/mysql-core");
64545
- import_pg_core4 = require("drizzle-orm/pg-core");
65830
+ import_drizzle_orm7 = require("drizzle-orm");
65831
+ import_mysql_core3 = require("drizzle-orm/mysql-core");
65832
+ import_pg_core3 = require("drizzle-orm/pg-core");
64546
65833
  import_sqlite_core3 = require("drizzle-orm/sqlite-core");
64547
65834
  import_fs10 = __toESM(require("fs"));
64548
65835
  init_dist2();
65836
+ init_compress();
64549
65837
  init_cors();
64550
65838
  import_node_https2 = require("node:https");
64551
65839
  init_global();
@@ -64568,12 +65856,12 @@ var init_studio2 = __esm({
64568
65856
  const i0 = require(`${it}`);
64569
65857
  const i0values = Object.entries(i0);
64570
65858
  i0values.forEach(([k, t2]) => {
64571
- if ((0, import_drizzle_orm8.is)(t2, import_pg_core4.PgTable)) {
64572
- const schema5 = (0, import_pg_core4.getTableConfig)(t2).schema || "public";
65859
+ if ((0, import_drizzle_orm7.is)(t2, import_pg_core3.PgTable)) {
65860
+ const schema5 = (0, import_pg_core3.getTableConfig)(t2).schema || "public";
64573
65861
  pgSchema2[schema5] = pgSchema2[schema5] || {};
64574
65862
  pgSchema2[schema5][k] = t2;
64575
65863
  }
64576
- if ((0, import_drizzle_orm8.is)(t2, import_drizzle_orm8.Relations)) {
65864
+ if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
64577
65865
  relations4[k] = t2;
64578
65866
  }
64579
65867
  });
@@ -64598,11 +65886,11 @@ var init_studio2 = __esm({
64598
65886
  const i0 = require(`${it}`);
64599
65887
  const i0values = Object.entries(i0);
64600
65888
  i0values.forEach(([k, t2]) => {
64601
- if ((0, import_drizzle_orm8.is)(t2, import_mysql_core5.MySqlTable)) {
64602
- const schema5 = (0, import_mysql_core5.getTableConfig)(t2).schema || "public";
65889
+ if ((0, import_drizzle_orm7.is)(t2, import_mysql_core3.MySqlTable)) {
65890
+ const schema5 = (0, import_mysql_core3.getTableConfig)(t2).schema || "public";
64603
65891
  mysqlSchema3[schema5][k] = t2;
64604
65892
  }
64605
- if ((0, import_drizzle_orm8.is)(t2, import_drizzle_orm8.Relations)) {
65893
+ if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
64606
65894
  relations4[k] = t2;
64607
65895
  }
64608
65896
  });
@@ -64627,11 +65915,11 @@ var init_studio2 = __esm({
64627
65915
  const i0 = require(`${it}`);
64628
65916
  const i0values = Object.entries(i0);
64629
65917
  i0values.forEach(([k, t2]) => {
64630
- if ((0, import_drizzle_orm8.is)(t2, import_sqlite_core3.SQLiteTable)) {
65918
+ if ((0, import_drizzle_orm7.is)(t2, import_sqlite_core3.SQLiteTable)) {
64631
65919
  const schema5 = "public";
64632
65920
  sqliteSchema2[schema5][k] = t2;
64633
65921
  }
64634
- if ((0, import_drizzle_orm8.is)(t2, import_drizzle_orm8.Relations)) {
65922
+ if ((0, import_drizzle_orm7.is)(t2, import_drizzle_orm7.Relations)) {
64635
65923
  relations4[k] = t2;
64636
65924
  }
64637
65925
  });
@@ -64644,10 +65932,10 @@ var init_studio2 = __esm({
64644
65932
  Object.entries(schema5).map(([schema6, tables]) => {
64645
65933
  Object.entries(tables).map(([, table4]) => {
64646
65934
  let tableConfig;
64647
- if ((0, import_drizzle_orm8.is)(table4, import_pg_core4.PgTable)) {
64648
- tableConfig = (0, import_pg_core4.getTableConfig)(table4);
64649
- } else if ((0, import_drizzle_orm8.is)(table4, import_mysql_core5.MySqlTable)) {
64650
- tableConfig = (0, import_mysql_core5.getTableConfig)(table4);
65935
+ if ((0, import_drizzle_orm7.is)(table4, import_pg_core3.PgTable)) {
65936
+ tableConfig = (0, import_pg_core3.getTableConfig)(table4);
65937
+ } else if ((0, import_drizzle_orm7.is)(table4, import_mysql_core3.MySqlTable)) {
65938
+ tableConfig = (0, import_mysql_core3.getTableConfig)(table4);
64651
65939
  } else {
64652
65940
  tableConfig = (0, import_sqlite_core3.getTableConfig)(table4);
64653
65941
  }
@@ -64764,7 +66052,7 @@ var init_studio2 = __esm({
64764
66052
  extractRelations = (tablesConfig) => {
64765
66053
  const relations4 = Object.values(tablesConfig.tables).map(
64766
66054
  (it) => Object.entries(it.relations).map(([name, relation]) => {
64767
- const normalized = (0, import_drizzle_orm8.normalizeRelation)(
66055
+ const normalized = (0, import_drizzle_orm7.normalizeRelation)(
64768
66056
  tablesConfig.tables,
64769
66057
  tablesConfig.tableNamesMap,
64770
66058
  relation
@@ -64775,19 +66063,19 @@ var init_studio2 = __esm({
64775
66063
  const fields = normalized.fields.map((it2) => it2.name).flat();
64776
66064
  const refColumns = normalized.references.map((it2) => it2.name).flat();
64777
66065
  let refSchema;
64778
- if ((0, import_drizzle_orm8.is)(refTable, import_pg_core4.PgTable)) {
64779
- refSchema = (0, import_pg_core4.getTableConfig)(refTable).schema;
64780
- } else if ((0, import_drizzle_orm8.is)(refTable, import_mysql_core5.MySqlTable)) {
64781
- refSchema = (0, import_mysql_core5.getTableConfig)(refTable).schema;
64782
- } else if ((0, import_drizzle_orm8.is)(refTable, import_sqlite_core3.SQLiteTable)) {
66066
+ if ((0, import_drizzle_orm7.is)(refTable, import_pg_core3.PgTable)) {
66067
+ refSchema = (0, import_pg_core3.getTableConfig)(refTable).schema;
66068
+ } else if ((0, import_drizzle_orm7.is)(refTable, import_mysql_core3.MySqlTable)) {
66069
+ refSchema = (0, import_mysql_core3.getTableConfig)(refTable).schema;
66070
+ } else if ((0, import_drizzle_orm7.is)(refTable, import_sqlite_core3.SQLiteTable)) {
64783
66071
  refSchema = void 0;
64784
66072
  } else {
64785
66073
  throw new Error("unsupported dialect");
64786
66074
  }
64787
66075
  let type;
64788
- if ((0, import_drizzle_orm8.is)(rel, import_drizzle_orm8.One)) {
66076
+ if ((0, import_drizzle_orm7.is)(rel, import_drizzle_orm7.One)) {
64789
66077
  type = "one";
64790
- } else if ((0, import_drizzle_orm8.is)(rel, import_drizzle_orm8.Many)) {
66078
+ } else if ((0, import_drizzle_orm7.is)(rel, import_drizzle_orm7.Many)) {
64791
66079
  type = "many";
64792
66080
  } else {
64793
66081
  throw new Error("unsupported relation type");
@@ -64866,11 +66154,12 @@ var init_studio2 = __esm({
64866
66154
  schemaFiles
64867
66155
  }, app) => {
64868
66156
  app = app !== void 0 ? app : new Hono2();
64869
- app.use(cors());
66157
+ app.use(compress());
64870
66158
  app.use(async (ctx, next) => {
64871
66159
  await next();
64872
66160
  ctx.header("Access-Control-Allow-Private-Network", "true");
64873
66161
  });
66162
+ app.use(cors());
64874
66163
  app.onError((err2, ctx) => {
64875
66164
  console.error(err2);
64876
66165
  return ctx.json({
@@ -64891,9 +66180,9 @@ var init_studio2 = __esm({
64891
66180
  ),
64892
66181
  ...relations4
64893
66182
  };
64894
- const relationsConfig = (0, import_drizzle_orm8.extractTablesRelationalConfig)(
66183
+ const relationsConfig = (0, import_drizzle_orm7.extractTablesRelationalConfig)(
64895
66184
  relationalSchema,
64896
- import_drizzle_orm8.createTableRelationsHelpers
66185
+ import_drizzle_orm7.createTableRelationsHelpers
64897
66186
  );
64898
66187
  app.post("/", zValidator("json", schema4), async (c) => {
64899
66188
  const body = c.req.valid("json");
@@ -65660,13 +66949,13 @@ var require_event_stream = __commonJS({
65660
66949
  es.writeArray = function(done) {
65661
66950
  if ("function" !== typeof done)
65662
66951
  throw new Error("function writeArray (done): done must be function");
65663
- var a = new Stream3(), array = [], isDone = false;
66952
+ var a = new Stream3(), array2 = [], isDone = false;
65664
66953
  a.write = function(l) {
65665
- array.push(l);
66954
+ array2.push(l);
65666
66955
  };
65667
66956
  a.end = function() {
65668
66957
  isDone = true;
65669
- done(null, array);
66958
+ done(null, array2);
65670
66959
  };
65671
66960
  a.writable = true;
65672
66961
  a.readable = false;
@@ -65674,23 +66963,23 @@ var require_event_stream = __commonJS({
65674
66963
  a.writable = a.readable = false;
65675
66964
  if (isDone)
65676
66965
  return;
65677
- done(new Error("destroyed before end"), array);
66966
+ done(new Error("destroyed before end"), array2);
65678
66967
  };
65679
66968
  return a;
65680
66969
  };
65681
- es.readArray = function(array) {
66970
+ es.readArray = function(array2) {
65682
66971
  var stream = new Stream3(), i2 = 0, paused = false, ended = false;
65683
66972
  stream.readable = true;
65684
66973
  stream.writable = false;
65685
- if (!Array.isArray(array))
66974
+ if (!Array.isArray(array2))
65686
66975
  throw new Error("event-stream.read expects an array");
65687
66976
  stream.resume = function() {
65688
66977
  if (ended)
65689
66978
  return;
65690
66979
  paused = false;
65691
- var l = array.length;
66980
+ var l = array2.length;
65692
66981
  while (i2 < l && !paused && !ended) {
65693
- stream.emit("data", array[i2++]);
66982
+ stream.emit("data", array2[i2++]);
65694
66983
  }
65695
66984
  if (i2 == l && !ended)
65696
66985
  ended = true, stream.readable = false, stream.emit("end");
@@ -69315,8 +70604,8 @@ var require_utils4 = __commonJS({
69315
70604
  "use strict";
69316
70605
  Object.defineProperty(exports2, "__esModule", { value: true });
69317
70606
  exports2.string = exports2.stream = exports2.pattern = exports2.path = exports2.fs = exports2.errno = exports2.array = void 0;
69318
- var array = require_array();
69319
- exports2.array = array;
70607
+ var array2 = require_array();
70608
+ exports2.array = array2;
69320
70609
  var errno = require_errno();
69321
70610
  exports2.errno = errno;
69322
70611
  var fs9 = require_fs2();
@@ -79966,17 +81255,11 @@ var init_pgPushUtils = __esm({
79966
81255
  }
79967
81256
  const stmnt = fromJson([statement], "postgresql");
79968
81257
  if (typeof stmnt !== "undefined") {
79969
- if (statement.type === "drop_table") {
79970
- statementsToExecute.push(
79971
- `DROP TABLE ${concatSchemaAndTableName(statement.schema, statement.tableName)} CASCADE;`
79972
- );
79973
- } else {
79974
- statementsToExecute.push(...stmnt);
79975
- }
81258
+ statementsToExecute.push(...stmnt);
79976
81259
  }
79977
81260
  }
79978
81261
  return {
79979
- statementsToExecute,
81262
+ statementsToExecute: [...new Set(statementsToExecute)],
79980
81263
  shouldAskForApprove,
79981
81264
  infoToPrint,
79982
81265
  matViewsToRemove: [...new Set(matViewsToRemove)],
@@ -81124,7 +82407,7 @@ var init_pgIntrospect = __esm({
81124
82407
  init_global();
81125
82408
  init_pgSerializer();
81126
82409
  init_views();
81127
- pgPushIntrospect = async (db, filters, schemaFilters) => {
82410
+ pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
81128
82411
  const matchers = filters.map((it) => {
81129
82412
  return new Minimatch(it);
81130
82413
  });
@@ -81153,7 +82436,7 @@ var init_pgIntrospect = __esm({
81153
82436
  );
81154
82437
  const res = await (0, import_hanji9.renderWithTask)(
81155
82438
  progress,
81156
- fromDatabase2(db, filter2, schemaFilters)
82439
+ fromDatabase2(db, filter2, schemaFilters, entities)
81157
82440
  );
81158
82441
  const schema5 = { id: originUUID, prevId: "", ...res };
81159
82442
  const { internal, ...schemaWithoutInternals } = schema5;
@@ -81163,11 +82446,11 @@ var init_pgIntrospect = __esm({
81163
82446
  });
81164
82447
 
81165
82448
  // src/introspect-sqlite.ts
81166
- var import_casing3, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTableChecks, createTablePKs, createTableFKs;
82449
+ var import_casing2, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTableChecks, createTablePKs, createTableFKs;
81167
82450
  var init_introspect_sqlite = __esm({
81168
82451
  "src/introspect-sqlite.ts"() {
81169
82452
  "use strict";
81170
- import_casing3 = require("drizzle-orm/casing");
82453
+ import_casing2 = require("drizzle-orm/casing");
81171
82454
  init_utils3();
81172
82455
  init_global();
81173
82456
  sqliteImportsList = /* @__PURE__ */ new Set([
@@ -81212,7 +82495,7 @@ var init_introspect_sqlite = __esm({
81212
82495
  return "";
81213
82496
  }
81214
82497
  if (casing2 === "camel") {
81215
- return (0, import_casing3.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
82498
+ return (0, import_casing2.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
81216
82499
  }
81217
82500
  assertUnreachable(casing2);
81218
82501
  };
@@ -81743,11 +83026,11 @@ var init_push = __esm({
81743
83026
  console.log(e2);
81744
83027
  }
81745
83028
  };
81746
- pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, force, casing2) => {
83029
+ pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, entities, force, casing2) => {
81747
83030
  const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
81748
83031
  const { pgPushIntrospect: pgPushIntrospect2 } = await Promise.resolve().then(() => (init_pgIntrospect(), pgIntrospect_exports));
81749
83032
  const db = await preparePostgresDB2(credentials2);
81750
- const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter);
83033
+ const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter, entities);
81751
83034
  const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
81752
83035
  const statements = await preparePgPush2(schemaPath, schema5, schemasFilter, casing2);
81753
83036
  try {
@@ -82342,11 +83625,11 @@ var require_pluralize = __commonJS({
82342
83625
  });
82343
83626
 
82344
83627
  // src/introspect-mysql.ts
82345
- var import_casing4, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTableChecks2, createTablePKs2, createTableFKs2;
83628
+ var import_casing3, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTableChecks2, createTablePKs2, createTableFKs2;
82346
83629
  var init_introspect_mysql = __esm({
82347
83630
  "src/introspect-mysql.ts"() {
82348
83631
  "use strict";
82349
- import_casing4 = require("drizzle-orm/casing");
83632
+ import_casing3 = require("drizzle-orm/casing");
82350
83633
  init_utils3();
82351
83634
  init_global();
82352
83635
  init_mysqlSerializer();
@@ -82435,7 +83718,7 @@ var init_introspect_mysql = __esm({
82435
83718
  return "";
82436
83719
  }
82437
83720
  if (casing2 === "camel") {
82438
- return (0, import_casing4.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
83721
+ return (0, import_casing3.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
82439
83722
  }
82440
83723
  assertUnreachable(casing2);
82441
83724
  };
@@ -83004,14 +84287,14 @@ function generateIdentityParams(identity) {
83004
84287
  }
83005
84288
  return `.generatedByDefaultAsIdentity(${paramsObj})`;
83006
84289
  }
83007
- var import_drizzle_orm9, import_relations, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableChecks3, createTableFKs3;
84290
+ var import_drizzle_orm8, import_relations, import_casing4, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTablePolicies, createTableUniques3, createTableChecks3, createTableFKs3;
83008
84291
  var init_introspect_pg = __esm({
83009
84292
  "src/introspect-pg.ts"() {
83010
84293
  "use strict";
83011
- import_drizzle_orm9 = require("drizzle-orm");
84294
+ import_drizzle_orm8 = require("drizzle-orm");
83012
84295
  import_relations = require("drizzle-orm/relations");
83013
84296
  init_utils3();
83014
- import_casing5 = require("drizzle-orm/casing");
84297
+ import_casing4 = require("drizzle-orm/casing");
83015
84298
  init_vector();
83016
84299
  init_global();
83017
84300
  init_pgSerializer();
@@ -83142,7 +84425,7 @@ var init_introspect_pg = __esm({
83142
84425
  return "";
83143
84426
  }
83144
84427
  if (casing2 === "camel") {
83145
- return (0, import_casing5.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
84428
+ return (0, import_casing4.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
83146
84429
  }
83147
84430
  assertUnreachable(casing2);
83148
84431
  };
@@ -83178,6 +84461,9 @@ var init_introspect_pg = __esm({
83178
84461
  const checkImports = Object.values(it.checkConstraints).map(
83179
84462
  (it2) => "check"
83180
84463
  );
84464
+ const policiesImports = Object.values(it.policies).map(
84465
+ (it2) => "pgPolicy"
84466
+ );
83181
84467
  if (it.schema && it.schema !== "public" && it.schema !== "") {
83182
84468
  res.pg.push("pgSchema");
83183
84469
  }
@@ -83185,6 +84471,7 @@ var init_introspect_pg = __esm({
83185
84471
  res.pg.push(...fkImpots);
83186
84472
  res.pg.push(...pkImports);
83187
84473
  res.pg.push(...uniqueImports);
84474
+ res.pg.push(...policiesImports);
83188
84475
  res.pg.push(...checkImports);
83189
84476
  const columnImports = Object.values(it.columns).map((col) => {
83190
84477
  let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
@@ -83243,6 +84530,9 @@ var init_introspect_pg = __esm({
83243
84530
  imports.pg.push("pgEnum");
83244
84531
  }
83245
84532
  });
84533
+ if (Object.keys(schema5.roles).length > 0) {
84534
+ imports.pg.push("pgRole");
84535
+ }
83246
84536
  const enumStatements = Object.values(schema5.enums).map((it) => {
83247
84537
  const enumSchema3 = schemas[it.schema];
83248
84538
  const paramName = paramNameFor(it.name, enumSchema3);
@@ -83278,9 +84568,16 @@ var init_introspect_pg = __esm({
83278
84568
  }
83279
84569
  return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}"${params ? `, { ${params.trimChar(",")} }` : ""})
83280
84570
  `;
83281
- }).join("").concat("\n");
84571
+ }).join("").concat("");
83282
84572
  const schemaStatements = Object.entries(schemas).map((it) => {
83283
84573
  return `export const ${it[1]} = pgSchema("${it[0]}");
84574
+ `;
84575
+ }).join("");
84576
+ const rolesNameToTsKey = {};
84577
+ const rolesStatements = Object.entries(schema5.roles).map((it) => {
84578
+ const fields = it[1];
84579
+ rolesNameToTsKey[fields.name] = it[0];
84580
+ return `export const ${withCasing2(it[0], casing2)} = pgRole("${fields.name}", ${!fields.createDb && !fields.createRole && fields.inherit ? "" : `${`, { ${fields.createDb ? `createDb: true,` : ""}${fields.createRole ? ` createRole: true,` : ""}${!fields.inherit ? ` inherit: false ` : ""}`.trimChar(",")}}`} );
83284
84581
  `;
83285
84582
  }).join("");
83286
84583
  const tableStatements = Object.values(schema5.tables).map((table4) => {
@@ -83299,8 +84596,8 @@ var init_introspect_pg = __esm({
83299
84596
  schema5.internal
83300
84597
  );
83301
84598
  statement += "}";
83302
- if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
83303
- statement += ",\n";
84599
+ if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.values(table4.policies).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
84600
+ statement += ", ";
83304
84601
  statement += "(table) => {\n";
83305
84602
  statement += " return {\n";
83306
84603
  statement += createTableIndexes3(table4.name, Object.values(table4.indexes), casing2);
@@ -83313,6 +84610,11 @@ var init_introspect_pg = __esm({
83313
84610
  Object.values(table4.uniqueConstraints),
83314
84611
  casing2
83315
84612
  );
84613
+ statement += createTablePolicies(
84614
+ Object.values(table4.policies),
84615
+ casing2,
84616
+ rolesNameToTsKey
84617
+ );
83316
84618
  statement += createTableChecks3(
83317
84619
  Object.values(table4.checkConstraints),
83318
84620
  casing2
@@ -83346,11 +84648,14 @@ var init_introspect_pg = __esm({
83346
84648
  return statement;
83347
84649
  }).join("\n\n");
83348
84650
  const uniquePgImports = ["pgTable", ...new Set(imports.pg)];
83349
- const importsTs = `import { ${uniquePgImports.join(", ")} } from "drizzle-orm/pg-core"
83350
- import { sql } from "drizzle-orm"
84651
+ const importsTs = `import { ${uniquePgImports.join(
84652
+ ", "
84653
+ )} } from "drizzle-orm/pg-core"
84654
+ import { sql } from "drizzle-orm"
83351
84655
 
83352
84656
  `;
83353
84657
  let decalrations = schemaStatements;
84658
+ decalrations += rolesStatements;
83354
84659
  decalrations += enumStatements;
83355
84660
  decalrations += sequencesStatements;
83356
84661
  decalrations += "\n";
@@ -83749,6 +85054,23 @@ var init_introspect_pg = __esm({
83749
85054
  }).join(", ")}]${it.name ? `, name: "${it.name}"` : ""}}`;
83750
85055
  statement += ")";
83751
85056
  statement += `,
85057
+ `;
85058
+ });
85059
+ return statement;
85060
+ };
85061
+ createTablePolicies = (policies, casing2, rolesNameToTsKey = {}) => {
85062
+ let statement = "";
85063
+ policies.forEach((it) => {
85064
+ var _a, _b, _c;
85065
+ const idxKey = withCasing2(it.name, casing2);
85066
+ const mappedItTo = (_a = it.to) == null ? void 0 : _a.map((v) => {
85067
+ return rolesNameToTsKey[v] ? withCasing2(rolesNameToTsKey[v], casing2) : `"${v}"`;
85068
+ });
85069
+ statement += ` ${idxKey}: `;
85070
+ statement += "pgPolicy(";
85071
+ statement += `"${it.name}", { `;
85072
+ statement += `as: "${(_b = it.as) == null ? void 0 : _b.toLowerCase()}", for: "${(_c = it.for) == null ? void 0 : _c.toLowerCase()}", to: [${mappedItTo == null ? void 0 : mappedItTo.join(", ")}]${it.using ? `, using: sql\`${it.using}\`` : ""}${it.withCheck ? `, withCheck: sql\`${it.withCheck}\` ` : ""}`;
85073
+ statement += ` }),
83752
85074
  `;
83753
85075
  });
83754
85076
  return statement;
@@ -83839,7 +85161,7 @@ var init_introspect = __esm({
83839
85161
  init_utils();
83840
85162
  init_views();
83841
85163
  init_migrate();
83842
- introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2) => {
85164
+ introspectPostgres = async (casing2, out, breakpoints, credentials2, tablesFilter, schemasFilter, prefix2, entities) => {
83843
85165
  const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
83844
85166
  const db = await preparePostgresDB2(credentials2);
83845
85167
  const matchers = tablesFilter.map((it) => {
@@ -83867,9 +85189,15 @@ var init_introspect = __esm({
83867
85189
  const progress = new IntrospectProgress(true);
83868
85190
  const res = await (0, import_hanji12.renderWithTask)(
83869
85191
  progress,
83870
- fromDatabase2(db, filter2, schemasFilter, (stage, count, status) => {
83871
- progress.update(stage, count, status);
83872
- })
85192
+ fromDatabase2(
85193
+ db,
85194
+ filter2,
85195
+ schemasFilter,
85196
+ entities,
85197
+ (stage, count, status) => {
85198
+ progress.update(stage, count, status);
85199
+ }
85200
+ )
83873
85201
  );
83874
85202
  const schema5 = { id: originUUID, prevId: "", ...res };
83875
85203
  const ts = schemaToTypeScript3(schema5, casing2);
@@ -83888,6 +85216,9 @@ var init_introspect = __esm({
83888
85216
  schemasResolver,
83889
85217
  enumsResolver,
83890
85218
  sequencesResolver,
85219
+ policyResolver,
85220
+ indPolicyResolver,
85221
+ roleResolver,
83891
85222
  tablesResolver,
83892
85223
  columnsResolver,
83893
85224
  viewsResolver,
@@ -84278,7 +85609,7 @@ ${fields.join("\n")}
84278
85609
  }
84279
85610
  });
84280
85611
 
84281
- // ../node_modules/.pnpm/@drizzle-team+brocli@0.10.1/node_modules/@drizzle-team/brocli/index.js
85612
+ // ../node_modules/.pnpm/@drizzle-team+brocli@0.10.2/node_modules/@drizzle-team/brocli/index.js
84282
85613
  var __create2 = Object.create;
84283
85614
  var __defProp2 = Object.defineProperty;
84284
85615
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -84782,32 +86113,32 @@ var defaultEventHandler = async (event) => {
84782
86113
  var _a;
84783
86114
  switch (event.type) {
84784
86115
  case "command_help": {
84785
- const command2 = event.command;
84786
- const commandName = getCommandNameWithParents(command2);
86116
+ const command3 = event.command;
86117
+ const commandName = getCommandNameWithParents(command3);
84787
86118
  const cliName = event.name;
84788
- const desc = command2.desc ?? command2.shortDesc;
84789
- const subs = (_a = command2.subcommands) == null ? void 0 : _a.filter((s2) => !s2.hidden);
86119
+ const desc = command3.desc ?? command3.shortDesc;
86120
+ const subs = (_a = command3.subcommands) == null ? void 0 : _a.filter((s2) => !s2.hidden);
84790
86121
  const subcommands = subs && subs.length ? subs : void 0;
84791
86122
  if (desc !== void 0) {
84792
86123
  console.log(`
84793
86124
  ${desc}`);
84794
86125
  }
84795
- const opts = Object.values(command2.options ?? {}).filter(
86126
+ const opts = Object.values(command3.options ?? {}).filter(
84796
86127
  (opt) => !opt.config.isHidden
84797
86128
  );
84798
86129
  const positionals = opts.filter((opt) => opt.config.type === "positional");
84799
86130
  const options = opts.filter((opt) => opt.config.type !== "positional");
84800
86131
  console.log("\nUsage:");
84801
- if (command2.handler) {
86132
+ if (command3.handler) {
84802
86133
  console.log(
84803
86134
  ` ${cliName ? cliName + " " : ""}${commandName}${positionals.length ? " " + positionals.map(({ config: p2 }) => getOptionTypeText(p2)).join(" ") : ""} [flags]`
84804
86135
  );
84805
86136
  } else
84806
86137
  console.log(` ${cliName ? cliName + " " : ""}${commandName} [command]`);
84807
- if (command2.aliases) {
86138
+ if (command3.aliases) {
84808
86139
  console.log(`
84809
86140
  Aliases:`);
84810
- console.log(` ${[command2.name, ...command2.aliases].join(", ")}`);
86141
+ console.log(` ${[command3.name, ...command3.aliases].join(", ")}`);
84811
86142
  }
84812
86143
  if (subcommands) {
84813
86144
  console.log("\nAvailable Commands:");
@@ -84887,8 +86218,8 @@ Use "${cliName ? cliName + " " : ""}${commandName} [command] --help" for more in
84887
86218
  const maxLength = commands.reduce((p2, e2) => e2.name.length > p2 ? e2.name.length : p2, 0);
84888
86219
  const paddedLength = maxLength + padding;
84889
86220
  const data = commands.map(
84890
- (\u0441) => ` ${\u0441.name.padEnd(paddedLength)}${(() => {
84891
- const desc2 = \u0441.shortDesc ?? \u0441.desc;
86221
+ (c) => ` ${c.name.padEnd(paddedLength)}${(() => {
86222
+ const desc2 = c.shortDesc ?? c.desc;
84892
86223
  if (!(desc2 == null ? void 0 : desc2.length))
84893
86224
  return "";
84894
86225
  const split = desc2.split("\n");
@@ -84980,8 +86311,8 @@ Type '${cName} --help' to get the help on command.`;
84980
86311
  return true;
84981
86312
  }
84982
86313
  case "missing_args_error": {
84983
- const missingOpts = event.missing;
84984
- msg = `Command '${command.name}' is missing following required options: ${missingOpts.map((opt) => {
86314
+ const { missing: missingOpts, command: command3 } = event;
86315
+ msg = `Command '${command3.name}' is missing following required options: ${missingOpts.map((opt) => {
84985
86316
  const name = opt.shift();
84986
86317
  const aliases = opt;
84987
86318
  if (aliases.length)
@@ -84991,8 +86322,8 @@ Type '${cName} --help' to get the help on command.`;
84991
86322
  break;
84992
86323
  }
84993
86324
  case "unrecognized_args_error": {
84994
- const { command: command2, unrecognized } = event;
84995
- msg = `Unrecognized options for command '${command2.name}': ${unrecognized.join(", ")}`;
86325
+ const { command: command3, unrecognized } = event;
86326
+ msg = `Unrecognized options for command '${command3.name}': ${unrecognized.join(", ")}`;
84996
86327
  break;
84997
86328
  }
84998
86329
  case "unknown_error": {
@@ -85089,21 +86420,21 @@ var assignParent = (parent, subcommands) => subcommands.forEach((e2) => {
85089
86420
  if (e2.subcommands)
85090
86421
  assignParent(e2, e2.subcommands);
85091
86422
  });
85092
- var command = (command2) => {
86423
+ var command2 = (command3) => {
85093
86424
  var _a, _b, _c;
85094
- const allNames = command2.aliases ? [command2.name, ...command2.aliases] : [command2.name];
85095
- const cmd = (0, import_clone.default)(command2);
85096
- if (command2.subcommands && command2.options && Object.values(command2.options).find((opt) => opt._.config.type === "positional")) {
86425
+ const allNames = command3.aliases ? [command3.name, ...command3.aliases] : [command3.name];
86426
+ const cmd = (0, import_clone.default)(command3);
86427
+ if (command3.subcommands && command3.options && Object.values(command3.options).find((opt) => opt._.config.type === "positional")) {
85097
86428
  throw new BroCliError(
85098
86429
  `Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`
85099
86430
  );
85100
86431
  }
85101
- if (!command2.handler && !command2.subcommands) {
86432
+ if (!command3.handler && !command3.subcommands) {
85102
86433
  throw new BroCliError(
85103
86434
  `Can't define command '${cmd.name}' - command without subcommands must have a handler present!`
85104
86435
  );
85105
86436
  }
85106
- const processedOptions = command2.options ? validateOptions(command2.options) : void 0;
86437
+ const processedOptions = command3.options ? validateOptions(command3.options) : void 0;
85107
86438
  cmd.options = processedOptions;
85108
86439
  cmd.name = cmd.name ?? ((_a = cmd.aliases) == null ? void 0 : _a.shift());
85109
86440
  if (!cmd.name)
@@ -85140,33 +86471,33 @@ var command = (command2) => {
85140
86471
  };
85141
86472
  var getCommandInner = (commands, candidates, args, cliName, cliDescription) => {
85142
86473
  const { data: arg, originalIndex: index4 } = candidates.shift();
85143
- const command2 = commands.find((c) => {
86474
+ const command3 = commands.find((c) => {
85144
86475
  const names = c.aliases ? [c.name, ...c.aliases] : [c.name];
85145
86476
  const res = names.find((name) => name === arg);
85146
86477
  return res;
85147
86478
  });
85148
- if (!command2) {
86479
+ if (!command3) {
85149
86480
  return {
85150
- command: command2,
86481
+ command: command3,
85151
86482
  args
85152
86483
  };
85153
86484
  }
85154
86485
  const newArgs = removeByIndex(args, index4);
85155
- if (!candidates.length || !command2.subcommands) {
86486
+ if (!candidates.length || !command3.subcommands) {
85156
86487
  return {
85157
- command: command2,
86488
+ command: command3,
85158
86489
  args: newArgs
85159
86490
  };
85160
86491
  }
85161
86492
  const newCandidates = candidates.map((c) => ({ data: c.data, originalIndex: c.originalIndex - 1 }));
85162
- const subcommand = getCommandInner(command2.subcommands, newCandidates, newArgs, cliName, cliDescription);
86493
+ const subcommand = getCommandInner(command3.subcommands, newCandidates, newArgs, cliName, cliDescription);
85163
86494
  if (!subcommand.command) {
85164
86495
  throw new BroCliError(void 0, {
85165
86496
  type: "error",
85166
86497
  violation: "unknown_subcommand_error",
85167
86498
  name: cliName,
85168
86499
  description: cliDescription,
85169
- command: command2,
86500
+ command: command3,
85170
86501
  offender: candidates[0].data
85171
86502
  });
85172
86503
  }
@@ -85206,8 +86537,8 @@ var getCommand = (commands, args, cliName, cliDescription) => {
85206
86537
  args: removeByIndex(args, firstCandidate.originalIndex)
85207
86538
  };
85208
86539
  }
85209
- const { command: command2, args: argsRes } = getCommandInner(commands, candidates, args, cliName, cliDescription);
85210
- if (!command2) {
86540
+ const { command: command3, args: argsRes } = getCommandInner(commands, candidates, args, cliName, cliDescription);
86541
+ if (!command3) {
85211
86542
  throw new BroCliError(void 0, {
85212
86543
  type: "error",
85213
86544
  violation: "unknown_command_error",
@@ -85218,11 +86549,11 @@ var getCommand = (commands, args, cliName, cliDescription) => {
85218
86549
  });
85219
86550
  }
85220
86551
  return {
85221
- command: command2,
86552
+ command: command3,
85222
86553
  args: argsRes
85223
86554
  };
85224
86555
  };
85225
- var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescription) => {
86556
+ var parseArg = (command3, options, positionals, arg, nextArg, cliName, cliDescription) => {
85226
86557
  let data = void 0;
85227
86558
  const argSplit = arg.split("=");
85228
86559
  const hasEq = arg.includes("=");
@@ -85249,7 +86580,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85249
86580
  name: cliName,
85250
86581
  description: cliDescription,
85251
86582
  violation: "enum_violation",
85252
- command: command2,
86583
+ command: command3,
85253
86584
  option: pos[1],
85254
86585
  offender: {
85255
86586
  dataPart: arg
@@ -85295,7 +86626,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85295
86626
  description: cliDescription,
85296
86627
  violation: "invalid_boolean_syntax",
85297
86628
  option: opt,
85298
- command: command2,
86629
+ command: command3,
85299
86630
  offender: {
85300
86631
  namePart,
85301
86632
  dataPart
@@ -85313,7 +86644,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85313
86644
  description: cliDescription,
85314
86645
  violation: "invalid_string_syntax",
85315
86646
  option: opt,
85316
- command: command2,
86647
+ command: command3,
85317
86648
  offender: {
85318
86649
  namePart,
85319
86650
  dataPart
@@ -85327,7 +86658,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85327
86658
  description: cliDescription,
85328
86659
  violation: "enum_violation",
85329
86660
  option: opt,
85330
- command: command2,
86661
+ command: command3,
85331
86662
  offender: {
85332
86663
  namePart,
85333
86664
  dataPart
@@ -85344,7 +86675,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85344
86675
  description: cliDescription,
85345
86676
  violation: "invalid_number_syntax",
85346
86677
  option: opt,
85347
- command: command2,
86678
+ command: command3,
85348
86679
  offender: {
85349
86680
  namePart,
85350
86681
  dataPart
@@ -85359,7 +86690,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85359
86690
  description: cliDescription,
85360
86691
  violation: "invalid_number_value",
85361
86692
  option: opt,
85362
- command: command2,
86693
+ command: command3,
85363
86694
  offender: {
85364
86695
  namePart,
85365
86696
  dataPart
@@ -85373,7 +86704,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85373
86704
  description: cliDescription,
85374
86705
  violation: "expected_int",
85375
86706
  option: opt,
85376
- command: command2,
86707
+ command: command3,
85377
86708
  offender: {
85378
86709
  namePart,
85379
86710
  dataPart
@@ -85387,7 +86718,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85387
86718
  description: cliDescription,
85388
86719
  violation: "below_min",
85389
86720
  option: opt,
85390
- command: command2,
86721
+ command: command3,
85391
86722
  offender: {
85392
86723
  namePart,
85393
86724
  dataPart
@@ -85401,7 +86732,7 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85401
86732
  description: cliDescription,
85402
86733
  violation: "above_max",
85403
86734
  option: opt,
85404
- command: command2,
86735
+ command: command3,
85405
86736
  offender: {
85406
86737
  namePart,
85407
86738
  dataPart
@@ -85419,8 +86750,8 @@ var parseArg = (command2, options, positionals, arg, nextArg, cliName, cliDescri
85419
86750
  option: option == null ? void 0 : option[1]
85420
86751
  };
85421
86752
  };
85422
- var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefinedOptions) => {
85423
- const options = command2.options;
86753
+ var parseOptions = (command3, args, cliName, cliDescription, omitKeysOfUndefinedOptions) => {
86754
+ const options = command3.options;
85424
86755
  const optEntries = Object.entries(options ?? {}).map(
85425
86756
  (opt) => [opt[0], opt[1].config]
85426
86757
  );
@@ -85439,7 +86770,7 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
85439
86770
  skipNext,
85440
86771
  isHelp,
85441
86772
  isVersion
85442
- } = parseArg(command2, nonPositionalEntries, positionalEntries, arg, nextArg, cliName, cliDescription);
86773
+ } = parseArg(command3, nonPositionalEntries, positionalEntries, arg, nextArg, cliName, cliDescription);
85443
86774
  if (!option)
85444
86775
  unrecognizedArgsArr.push(arg.split("=")[0]);
85445
86776
  if (skipNext)
@@ -85467,7 +86798,7 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
85467
86798
  violation: "missing_args_error",
85468
86799
  name: cliName,
85469
86800
  description: cliDescription,
85470
- command: command2,
86801
+ command: command3,
85471
86802
  missing: missingRequiredArr
85472
86803
  });
85473
86804
  }
@@ -85477,13 +86808,13 @@ var parseOptions = (command2, args, cliName, cliDescription, omitKeysOfUndefined
85477
86808
  violation: "unrecognized_args_error",
85478
86809
  name: cliName,
85479
86810
  description: cliDescription,
85480
- command: command2,
86811
+ command: command3,
85481
86812
  unrecognized: unrecognizedArgsArr
85482
86813
  });
85483
86814
  }
85484
86815
  return Object.keys(result).length ? result : void 0;
85485
86816
  };
85486
- var getCommandNameWithParents = (command2) => command2.parent ? `${getCommandNameWithParents(command2.parent)} ${command2.name}` : command2.name;
86817
+ var getCommandNameWithParents = (command3) => command3.parent ? `${getCommandNameWithParents(command3.parent)} ${command3.name}` : command3.name;
85487
86818
  var validateCommands = (commands, parent) => {
85488
86819
  const storedNames = {};
85489
86820
  for (const cmd of commands) {
@@ -85537,13 +86868,13 @@ var run = async (commands, config) => {
85537
86868
  }
85538
86869
  const helpIndex = args.findIndex((arg) => arg === "--help" || arg === "-h");
85539
86870
  if (helpIndex !== -1 && (helpIndex > 0 ? ((_a = args[helpIndex - 1]) == null ? void 0 : _a.startsWith("-")) && !args[helpIndex - 1].includes("=") ? false : true : true)) {
85540
- const command3 = getCommand(processedCmds, args, cliName, cliDescription).command;
85541
- if (typeof command3 === "object") {
85542
- return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
86871
+ const command4 = getCommand(processedCmds, args, cliName, cliDescription).command;
86872
+ if (typeof command4 === "object") {
86873
+ return command4.help !== void 0 ? await executeOrLog(command4.help) : await eventHandler({
85543
86874
  type: "command_help",
85544
86875
  description: cliDescription,
85545
86876
  name: cliName,
85546
- command: command3
86877
+ command: command4
85547
86878
  });
85548
86879
  } else {
85549
86880
  return help !== void 0 ? await executeOrLog(help) : await eventHandler({
@@ -85562,8 +86893,8 @@ var run = async (commands, config) => {
85562
86893
  description: cliDescription
85563
86894
  });
85564
86895
  }
85565
- const { command: command2, args: newArgs } = getCommand(processedCmds, args, cliName, cliDescription);
85566
- if (!command2) {
86896
+ const { command: command3, args: newArgs } = getCommand(processedCmds, args, cliName, cliDescription);
86897
+ if (!command3) {
85567
86898
  return help !== void 0 ? await executeOrLog(help) : await eventHandler({
85568
86899
  type: "global_help",
85569
86900
  description: cliDescription,
@@ -85571,7 +86902,7 @@ var run = async (commands, config) => {
85571
86902
  commands: processedCmds
85572
86903
  });
85573
86904
  }
85574
- if (command2 === "help") {
86905
+ if (command3 === "help") {
85575
86906
  let helpCommand;
85576
86907
  let newestArgs = newArgs;
85577
86908
  do {
@@ -85591,13 +86922,13 @@ var run = async (commands, config) => {
85591
86922
  commands: processedCmds
85592
86923
  });
85593
86924
  }
85594
- const optionResult = parseOptions(command2, newArgs, cliName, cliDescription, omitKeysOfUndefinedOptions);
86925
+ const optionResult = parseOptions(command3, newArgs, cliName, cliDescription, omitKeysOfUndefinedOptions);
85595
86926
  if (optionResult === "help") {
85596
- return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
86927
+ return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
85597
86928
  type: "command_help",
85598
86929
  description: cliDescription,
85599
86930
  name: cliName,
85600
- command: command2
86931
+ command: command3
85601
86932
  });
85602
86933
  }
85603
86934
  if (optionResult === "version") {
@@ -85607,19 +86938,19 @@ var run = async (commands, config) => {
85607
86938
  description: cliDescription
85608
86939
  });
85609
86940
  }
85610
- if (command2.handler) {
86941
+ if (command3.handler) {
85611
86942
  if (config == null ? void 0 : config.hook)
85612
- await config.hook("before", command2);
85613
- await command2.handler(command2.transform ? await command2.transform(optionResult) : optionResult);
86943
+ await config.hook("before", command3);
86944
+ await command3.handler(command3.transform ? await command3.transform(optionResult) : optionResult);
85614
86945
  if (config == null ? void 0 : config.hook)
85615
- await config.hook("after", command2);
86946
+ await config.hook("after", command3);
85616
86947
  return;
85617
86948
  } else {
85618
- return command2.help !== void 0 ? await executeOrLog(command2.help) : await eventHandler({
86949
+ return command3.help !== void 0 ? await executeOrLog(command3.help) : await eventHandler({
85619
86950
  type: "command_help",
85620
86951
  description: cliDescription,
85621
86952
  name: cliName,
85622
- command: command2
86953
+ command: command3
85623
86954
  });
85624
86955
  }
85625
86956
  } catch (e2) {
@@ -85916,7 +87247,7 @@ var updateUpToV7 = (json) => {
85916
87247
  return [idx[0], { columns: mappedColumns, with: {}, ...rest }];
85917
87248
  })
85918
87249
  );
85919
- return [it[0], { ...table4, indexes: mappedIndexes }];
87250
+ return [it[0], { ...table4, indexes: mappedIndexes, policies: {}, isRLSEnabled: false, checkConstraints: {} }];
85920
87251
  })
85921
87252
  );
85922
87253
  return {
@@ -85924,7 +87255,10 @@ var updateUpToV7 = (json) => {
85924
87255
  version: "7",
85925
87256
  dialect: "postgresql",
85926
87257
  sequences: {},
85927
- tables
87258
+ tables,
87259
+ policies: {},
87260
+ views: {},
87261
+ roles: {}
85928
87262
  };
85929
87263
  };
85930
87264
 
@@ -85964,7 +87298,8 @@ var updateUpToV62 = (json) => {
85964
87298
  ...schema5,
85965
87299
  version: "6",
85966
87300
  dialect: "sqlite",
85967
- tables
87301
+ tables,
87302
+ views: {}
85968
87303
  };
85969
87304
  };
85970
87305
 
@@ -87039,7 +88374,7 @@ var optionBreakpoints = boolean().desc(
87039
88374
  );
87040
88375
  var optionDriver = string().enum(...drivers).desc("Database driver");
87041
88376
  var optionCasing = string().enum("camelCase", "snake_case").desc("Casing for serialization");
87042
- var generate = command({
88377
+ var generate = command2({
87043
88378
  name: "generate",
87044
88379
  options: {
87045
88380
  config: optionConfig,
@@ -87085,7 +88420,7 @@ var generate = command({
87085
88420
  }
87086
88421
  }
87087
88422
  });
87088
- var migrate = command({
88423
+ var migrate = command2({
87089
88424
  name: "migrate",
87090
88425
  options: {
87091
88426
  config: optionConfig
@@ -87192,7 +88527,7 @@ var optionsDatabaseCredentials = {
87192
88527
  // specific cases
87193
88528
  driver: optionDriver
87194
88529
  };
87195
- var push = command({
88530
+ var push = command2({
87196
88531
  name: "push",
87197
88532
  options: {
87198
88533
  config: optionConfig,
@@ -87244,7 +88579,8 @@ var push = command({
87244
88579
  tablesFilter,
87245
88580
  schemasFilter,
87246
88581
  force,
87247
- casing: casing2
88582
+ casing: casing2,
88583
+ entities
87248
88584
  } = config;
87249
88585
  try {
87250
88586
  if (dialect4 === "mysql") {
@@ -87287,6 +88623,7 @@ var push = command({
87287
88623
  credentials2,
87288
88624
  tablesFilter,
87289
88625
  schemasFilter,
88626
+ entities,
87290
88627
  force,
87291
88628
  casing2
87292
88629
  );
@@ -87321,7 +88658,7 @@ var push = command({
87321
88658
  process.exit(0);
87322
88659
  }
87323
88660
  });
87324
- var check = command({
88661
+ var check = command2({
87325
88662
  name: "check",
87326
88663
  options: {
87327
88664
  config: optionConfig,
@@ -87339,7 +88676,7 @@ var check = command({
87339
88676
  console.log("Everything's fine \u{1F436}\u{1F525}");
87340
88677
  }
87341
88678
  });
87342
- var up = command({
88679
+ var up = command2({
87343
88680
  name: "up",
87344
88681
  options: {
87345
88682
  config: optionConfig,
@@ -87365,7 +88702,7 @@ var up = command({
87365
88702
  }
87366
88703
  }
87367
88704
  });
87368
- var pull = command({
88705
+ var pull = command2({
87369
88706
  name: "introspect",
87370
88707
  aliases: ["pull"],
87371
88708
  options: {
@@ -87414,7 +88751,8 @@ var pull = command({
87414
88751
  breakpoints,
87415
88752
  tablesFilter,
87416
88753
  schemasFilter,
87417
- prefix: prefix2
88754
+ prefix: prefix2,
88755
+ entities
87418
88756
  } = config;
87419
88757
  (0, import_fs13.mkdirSync)(out, { recursive: true });
87420
88758
  console.log(
@@ -87453,7 +88791,8 @@ var pull = command({
87453
88791
  credentials2,
87454
88792
  tablesFilter,
87455
88793
  schemasFilter,
87456
- prefix2
88794
+ prefix2,
88795
+ entities
87457
88796
  );
87458
88797
  } else if (dialect4 === "mysql") {
87459
88798
  const { introspectMysql: introspectMysql2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
@@ -87494,7 +88833,7 @@ var pull = command({
87494
88833
  process.exit(0);
87495
88834
  }
87496
88835
  });
87497
- var drop = command({
88836
+ var drop = command2({
87498
88837
  name: "drop",
87499
88838
  options: {
87500
88839
  config: optionConfig,
@@ -87511,7 +88850,7 @@ var drop = command({
87511
88850
  await dropMigration(config);
87512
88851
  }
87513
88852
  });
87514
- var studio = command({
88853
+ var studio = command2({
87515
88854
  name: "studio",
87516
88855
  options: {
87517
88856
  config: optionConfig,
@@ -87624,14 +88963,14 @@ init_utils2();
87624
88963
  var version2 = async () => {
87625
88964
  const { npmVersion } = await ormCoreVersions();
87626
88965
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
87627
- const envVersion = "0.26.2";
88966
+ const envVersion = "0.27.0";
87628
88967
  const kitVersion = envVersion ? `v${envVersion}` : "--";
87629
88968
  const versions = `drizzle-kit: ${kitVersion}
87630
88969
  ${ormVersion}`;
87631
88970
  console.log(source_default.gray(versions), "\n");
87632
88971
  };
87633
88972
  var legacyCommand = (name, newName) => {
87634
- return command({
88973
+ return command2({
87635
88974
  name,
87636
88975
  hidden: true,
87637
88976
  handler: () => {