drizzle-kit 0.27.1 → 0.27.2-96d338b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.js CHANGED
@@ -7525,30 +7525,11 @@ var init_mysqlSchema = __esm({
7525
7525
  }
7526
7526
  });
7527
7527
 
7528
- // src/extensions/vector.ts
7529
- var vectorOps;
7530
- var init_vector = __esm({
7531
- "src/extensions/vector.ts"() {
7532
- "use strict";
7533
- vectorOps = [
7534
- "vector_l2_ops",
7535
- "vector_ip_ops",
7536
- "vector_cosine_ops",
7537
- "vector_l1_ops",
7538
- "bit_hamming_ops",
7539
- "bit_jaccard_ops",
7540
- "halfvec_l2_ops",
7541
- "sparsevec_l2_ops"
7542
- ];
7543
- }
7544
- });
7545
-
7546
7528
  // src/serializer/pgSchema.ts
7547
7529
  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;
7548
7530
  var init_pgSchema = __esm({
7549
7531
  "src/serializer/pgSchema.ts"() {
7550
7532
  "use strict";
7551
- init_vector();
7552
7533
  init_global();
7553
7534
  init_lib();
7554
7535
  indexV2 = objectType({
@@ -7756,7 +7737,8 @@ var init_pgSchema = __esm({
7756
7737
  to: stringType().array().optional(),
7757
7738
  using: stringType().optional(),
7758
7739
  withCheck: stringType().optional(),
7759
- on: stringType().optional()
7740
+ on: stringType().optional(),
7741
+ schema: stringType().optional()
7760
7742
  }).strict();
7761
7743
  policySquashed = objectType({
7762
7744
  name: stringType(),
@@ -8007,7 +7989,7 @@ var init_pgSchema = __esm({
8007
7989
  squashIdx: (idx) => {
8008
7990
  index2.parse(idx);
8009
7991
  return `${idx.name};${idx.columns.map(
8010
- (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
7992
+ (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass ? c.opclass : ""}`
8011
7993
  ).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
8012
7994
  },
8013
7995
  unsquashIdx: (input) => {
@@ -8073,11 +8055,11 @@ var init_pgSchema = __esm({
8073
8055
  squashFK: (fk4) => {
8074
8056
  return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
8075
8057
  },
8076
- squashPolicy: (policy4) => {
8077
- return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.using}--${policy4.withCheck}--${policy4.on}`;
8058
+ squashPolicy: (policy3) => {
8059
+ return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.using}--${policy3.withCheck}--${policy3.on}`;
8078
8060
  },
8079
- unsquashPolicy: (policy4) => {
8080
- const splitted = policy4.split("--");
8061
+ unsquashPolicy: (policy3) => {
8062
+ const splitted = policy3.split("--");
8081
8063
  return {
8082
8064
  name: splitted[0],
8083
8065
  as: splitted[1],
@@ -8088,8 +8070,18 @@ var init_pgSchema = __esm({
8088
8070
  on: splitted[6] !== "undefined" ? splitted[6] : void 0
8089
8071
  };
8090
8072
  },
8091
- squashPolicyPush: (policy4) => {
8092
- return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.on}`;
8073
+ squashPolicyPush: (policy3) => {
8074
+ return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.on}`;
8075
+ },
8076
+ unsquashPolicyPush: (policy3) => {
8077
+ const splitted = policy3.split("--");
8078
+ return {
8079
+ name: splitted[0],
8080
+ as: splitted[1],
8081
+ for: splitted[2],
8082
+ to: splitted[3].split(","),
8083
+ on: splitted[4] !== "undefined" ? splitted[4] : void 0
8084
+ };
8093
8085
  },
8094
8086
  squashPK: (pk) => {
8095
8087
  return `${pk.columns.join(",")};${pk.name}`;
@@ -8203,8 +8195,8 @@ var init_pgSchema = __esm({
8203
8195
  return PgSquasher.squashUnique(unq);
8204
8196
  }
8205
8197
  );
8206
- const squashedPolicies = mapValues(it[1].policies, (policy4) => {
8207
- return action === "push" ? PgSquasher.squashPolicyPush(policy4) : PgSquasher.squashPolicy(policy4);
8198
+ const squashedPolicies = mapValues(it[1].policies, (policy3) => {
8199
+ return action === "push" ? PgSquasher.squashPolicyPush(policy3) : PgSquasher.squashPolicy(policy3);
8208
8200
  });
8209
8201
  const squashedChecksContraints = mapValues(
8210
8202
  it[1].checkConstraints,
@@ -8592,6 +8584,9 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
8592
8584
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
8593
8585
  return { addedColumns, removedColumns };
8594
8586
  }
8587
+ function escapeSingleQuotes(str) {
8588
+ return str.replace(/'/g, "''");
8589
+ }
8595
8590
  var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
8596
8591
  var init_utils = __esm({
8597
8592
  "src/utils.ts"() {
@@ -11927,7 +11922,7 @@ function fromJson(statements, dialect4, action, json22) {
11927
11922
  }).filter((it) => it !== "");
11928
11923
  return result;
11929
11924
  }
11930
- 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;
11925
+ var parseType, 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;
11931
11926
  var init_sqlgenerator = __esm({
11932
11927
  "src/sqlgenerator.ts"() {
11933
11928
  "use strict";
@@ -11935,51 +11930,56 @@ var init_sqlgenerator = __esm({
11935
11930
  init_mysqlSchema();
11936
11931
  init_pgSchema();
11937
11932
  init_sqliteSchema();
11938
- pgNativeTypes = /* @__PURE__ */ new Set([
11939
- "uuid",
11940
- "smallint",
11941
- "integer",
11942
- "bigint",
11943
- "boolean",
11944
- "text",
11945
- "varchar",
11946
- "serial",
11947
- "bigserial",
11948
- "decimal",
11949
- "numeric",
11950
- "real",
11951
- "json",
11952
- "jsonb",
11953
- "time",
11954
- "time with time zone",
11955
- "time without time zone",
11956
- "time",
11957
- "timestamp",
11958
- "timestamp with time zone",
11959
- "timestamp without time zone",
11960
- "date",
11961
- "interval",
11962
- "bigint",
11963
- "bigserial",
11964
- "double precision",
11965
- "interval year",
11966
- "interval month",
11967
- "interval day",
11968
- "interval hour",
11969
- "interval minute",
11970
- "interval second",
11971
- "interval year to month",
11972
- "interval day to hour",
11973
- "interval day to minute",
11974
- "interval day to second",
11975
- "interval hour to minute",
11976
- "interval hour to second",
11977
- "interval minute to second"
11978
- ]);
11979
- isPgNativeType = (it) => {
11980
- if (pgNativeTypes.has(it)) return true;
11981
- const toCheck = it.replace(/ /g, "");
11982
- return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(") || toCheck.startsWith("doubleprecision[") || toCheck.startsWith("intervalyear(") || toCheck.startsWith("intervalmonth(") || toCheck.startsWith("intervalday(") || toCheck.startsWith("intervalhour(") || toCheck.startsWith("intervalminute(") || toCheck.startsWith("intervalsecond(") || toCheck.startsWith("intervalyeartomonth(") || toCheck.startsWith("intervaldaytohour(") || toCheck.startsWith("intervaldaytominute(") || toCheck.startsWith("intervaldaytosecond(") || toCheck.startsWith("intervalhourtominute(") || toCheck.startsWith("intervalhourtosecond(") || toCheck.startsWith("intervalminutetosecond(") || toCheck.startsWith("vector(") || toCheck.startsWith("geometry(") || /^(\w+)(\[\d*])+$/.test(it);
11933
+ init_utils();
11934
+ parseType = (schemaPrefix, type) => {
11935
+ const pgNativeTypes = [
11936
+ "uuid",
11937
+ "smallint",
11938
+ "integer",
11939
+ "bigint",
11940
+ "boolean",
11941
+ "text",
11942
+ "varchar",
11943
+ "serial",
11944
+ "bigserial",
11945
+ "decimal",
11946
+ "numeric",
11947
+ "real",
11948
+ "json",
11949
+ "jsonb",
11950
+ "time",
11951
+ "time with time zone",
11952
+ "time without time zone",
11953
+ "time",
11954
+ "timestamp",
11955
+ "timestamp with time zone",
11956
+ "timestamp without time zone",
11957
+ "date",
11958
+ "interval",
11959
+ "bigint",
11960
+ "bigserial",
11961
+ "double precision",
11962
+ "interval year",
11963
+ "interval month",
11964
+ "interval day",
11965
+ "interval hour",
11966
+ "interval minute",
11967
+ "interval second",
11968
+ "interval year to month",
11969
+ "interval day to hour",
11970
+ "interval day to minute",
11971
+ "interval day to second",
11972
+ "interval hour to minute",
11973
+ "interval hour to second",
11974
+ "interval minute to second",
11975
+ "char",
11976
+ "vector",
11977
+ "geometry"
11978
+ ];
11979
+ const arrayDefinitionRegex = /\[\d*(?:\[\d*\])*\]/g;
11980
+ const arrayDefinition = (type.match(arrayDefinitionRegex) ?? []).join("");
11981
+ const withoutArrayDefinition = type.replace(arrayDefinitionRegex, "");
11982
+ return pgNativeTypes.some((it) => type.startsWith(it)) ? `${withoutArrayDefinition}${arrayDefinition}` : `${schemaPrefix}"${withoutArrayDefinition}"${arrayDefinition}`;
11983
11983
  };
11984
11984
  Convertor = class {
11985
11985
  };
@@ -12020,14 +12020,14 @@ var init_sqlgenerator = __esm({
12020
12020
  return statement.type === "create_policy" && dialect4 === "postgresql";
12021
12021
  }
12022
12022
  convert(statement) {
12023
- const policy4 = statement.data;
12023
+ const policy3 = statement.data;
12024
12024
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12025
- const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
12026
- const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
12027
- const policyToPart = policy4.to?.map(
12025
+ const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
12026
+ const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
12027
+ const policyToPart = policy3.to?.map(
12028
12028
  (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
12029
12029
  ).join(", ");
12030
- return `CREATE POLICY "${policy4.name}" ON ${tableNameWithSchema} AS ${policy4.as?.toUpperCase()} FOR ${policy4.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12030
+ return `CREATE POLICY "${policy3.name}" ON ${tableNameWithSchema} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12031
12031
  }
12032
12032
  };
12033
12033
  PgDropPolicyConvertor = class extends Convertor {
@@ -12035,9 +12035,9 @@ var init_sqlgenerator = __esm({
12035
12035
  return statement.type === "drop_policy" && dialect4 === "postgresql";
12036
12036
  }
12037
12037
  convert(statement) {
12038
- const policy4 = statement.data;
12038
+ const policy3 = statement.data;
12039
12039
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12040
- return `DROP POLICY "${policy4.name}" ON ${tableNameWithSchema} CASCADE;`;
12040
+ return `DROP POLICY "${policy3.name}" ON ${tableNameWithSchema} CASCADE;`;
12041
12041
  }
12042
12042
  };
12043
12043
  PgRenamePolicyConvertor = class extends Convertor {
@@ -12053,9 +12053,9 @@ var init_sqlgenerator = __esm({
12053
12053
  can(statement, dialect4) {
12054
12054
  return statement.type === "alter_policy" && dialect4 === "postgresql";
12055
12055
  }
12056
- convert(statement) {
12057
- const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
12058
- const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
12056
+ convert(statement, _dialect, action) {
12057
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
12058
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
12059
12059
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12060
12060
  const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
12061
12061
  const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
@@ -12067,13 +12067,13 @@ var init_sqlgenerator = __esm({
12067
12067
  return statement.type === "create_ind_policy" && dialect4 === "postgresql";
12068
12068
  }
12069
12069
  convert(statement) {
12070
- const policy4 = statement.data;
12071
- const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
12072
- const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
12073
- const policyToPart = policy4.to?.map(
12070
+ const policy3 = statement.data;
12071
+ const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
12072
+ const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
12073
+ const policyToPart = policy3.to?.map(
12074
12074
  (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
12075
12075
  ).join(", ");
12076
- return `CREATE POLICY "${policy4.name}" ON ${policy4.on} AS ${policy4.as?.toUpperCase()} FOR ${policy4.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12076
+ return `CREATE POLICY "${policy3.name}" ON ${policy3.on} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12077
12077
  }
12078
12078
  };
12079
12079
  PgDropIndPolicyConvertor = class extends Convertor {
@@ -12081,8 +12081,8 @@ var init_sqlgenerator = __esm({
12081
12081
  return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
12082
12082
  }
12083
12083
  convert(statement) {
12084
- const policy4 = statement.data;
12085
- return `DROP POLICY "${policy4.name}" ON ${policy4.on} CASCADE;`;
12084
+ const policy3 = statement.data;
12085
+ return `DROP POLICY "${policy3.name}" ON ${policy3.on} CASCADE;`;
12086
12086
  }
12087
12087
  };
12088
12088
  PgRenameIndPolicyConvertor = class extends Convertor {
@@ -12140,7 +12140,7 @@ var init_sqlgenerator = __esm({
12140
12140
  const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
12141
12141
  const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT "${column4.uniqueName}" UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
12142
12142
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
12143
- const type = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
12143
+ const type = parseType(schemaPrefix, column4.type);
12144
12144
  const generated = column4.generated;
12145
12145
  const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated?.as}) STORED` : "";
12146
12146
  const unsquashedIdentity = column4.identity ? PgSquasher.unsquashIdentity(column4.identity) : void 0;
@@ -12697,7 +12697,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12697
12697
  const { name: name2, values, schema: schema4 } = st;
12698
12698
  const enumNameWithSchema = schema4 ? `"${schema4}"."${name2}"` : `"${name2}"`;
12699
12699
  let valuesStatement = "(";
12700
- valuesStatement += values.map((it) => `'${it}'`).join(", ");
12700
+ valuesStatement += values.map((it) => `'${escapeSingleQuotes(it)}'`).join(", ");
12701
12701
  valuesStatement += ")";
12702
12702
  let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
12703
12703
  return statement;
@@ -12775,7 +12775,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12775
12775
  can(statement, dialect4) {
12776
12776
  return statement.type === "drop_table" && dialect4 === "postgresql";
12777
12777
  }
12778
- convert(statement) {
12778
+ convert(statement, _d5, action) {
12779
12779
  const { tableName, schema: schema4, policies } = statement;
12780
12780
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
12781
12781
  const dropPolicyConvertor = new PgDropPolicyConvertor();
@@ -12783,7 +12783,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12783
12783
  return dropPolicyConvertor.convert({
12784
12784
  type: "drop_policy",
12785
12785
  tableName,
12786
- data: PgSquasher.unsquashPolicy(p),
12786
+ data: action === "push" ? PgSquasher.unsquashPolicyPush(p) : PgSquasher.unsquashPolicy(p),
12787
12787
  schema: schema4
12788
12788
  });
12789
12789
  }) ?? [];
@@ -12907,7 +12907,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12907
12907
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
12908
12908
  const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
12909
12909
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
12910
- const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
12910
+ const fixedType = parseType(schemaPrefix, column4.type);
12911
12911
  const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
12912
12912
  const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
12913
12913
  const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
@@ -13477,8 +13477,9 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13477
13477
  statement.new
13478
13478
  );
13479
13479
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
13480
- return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT ${statement.oldConstraintName};
13481
- ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newConstraintName} PRIMARY KEY(${newColumns.join(",")});`;
13480
+ console.log(statement.oldConstraintName, statement.newConstraintName);
13481
+ return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.oldConstraintName}";
13482
+ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newConstraintName}" PRIMARY KEY("${newColumns.join('","')}");`;
13482
13483
  }
13483
13484
  };
13484
13485
  MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
@@ -15681,30 +15682,29 @@ var init_jsonStatements = __esm({
15681
15682
  };
15682
15683
  });
15683
15684
  };
15684
- prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks, json22) => {
15685
+ prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15685
15686
  return Object.values(pks).map((it) => {
15686
- const unsquashed = PgSquasher.unsquashPK(it);
15687
15687
  return {
15688
15688
  type: "create_composite_pk",
15689
15689
  tableName,
15690
15690
  data: it,
15691
15691
  schema: schema4,
15692
- constraintName: json22.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
15692
+ constraintName: PgSquasher.unsquashPK(it).name
15693
15693
  };
15694
15694
  });
15695
15695
  };
15696
- prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks, json1) => {
15696
+ prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15697
15697
  return Object.values(pks).map((it) => {
15698
15698
  return {
15699
15699
  type: "delete_composite_pk",
15700
15700
  tableName,
15701
15701
  data: it,
15702
15702
  schema: schema4,
15703
- constraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
15703
+ constraintName: PgSquasher.unsquashPK(it).name
15704
15704
  };
15705
15705
  });
15706
15706
  };
15707
- prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks, json1, json22) => {
15707
+ prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15708
15708
  return Object.values(pks).map((it) => {
15709
15709
  return {
15710
15710
  type: "alter_composite_pk",
@@ -15712,8 +15712,8 @@ var init_jsonStatements = __esm({
15712
15712
  old: it.__old,
15713
15713
  new: it.__new,
15714
15714
  schema: schema4,
15715
- oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
15716
- newConstraintName: json22.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
15715
+ oldConstraintName: PgSquasher.unsquashPK(it.__old).name,
15716
+ newConstraintName: PgSquasher.unsquashPK(it.__new).name
15717
15717
  };
15718
15718
  });
15719
15719
  };
@@ -15768,18 +15768,19 @@ var init_jsonStatements = __esm({
15768
15768
  type: "create_composite_pk",
15769
15769
  tableName,
15770
15770
  data: it,
15771
- constraintName: json22.tables[tableName].compositePrimaryKeys[unsquashed.name].name
15771
+ constraintName: unsquashed.name
15772
15772
  });
15773
15773
  }
15774
15774
  return res;
15775
15775
  };
15776
15776
  prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
15777
15777
  return Object.values(pks).map((it) => {
15778
+ const unsquashed = MySqlSquasher.unsquashPK(it);
15778
15779
  return {
15779
15780
  type: "delete_composite_pk",
15780
15781
  tableName,
15781
15782
  data: it,
15782
- constraintName: json1.tables[tableName].compositePrimaryKeys[MySqlSquasher.unsquashPK(it).name].name
15783
+ constraintName: unsquashed.name
15783
15784
  };
15784
15785
  });
15785
15786
  };
@@ -16770,8 +16771,10 @@ var init_snapshotsDiffer = __esm({
16770
16771
  const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
16771
16772
  tableName: entry.name,
16772
16773
  schema: entry.schema,
16773
- deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
16774
- created: entry.policies.added.map(PgSquasher.unsquashPolicy)
16774
+ deleted: entry.policies.deleted.map(
16775
+ action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
16776
+ ),
16777
+ created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
16775
16778
  });
16776
16779
  if (created2.length > 0) {
16777
16780
  policyCreates.push({
@@ -16808,12 +16811,12 @@ var init_snapshotsDiffer = __esm({
16808
16811
  (tableKey2, tableValue) => {
16809
16812
  const patchedPolicies = mapKeys(
16810
16813
  tableValue.policies,
16811
- (policyKey, policy4) => {
16814
+ (policyKey, policy3) => {
16812
16815
  const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
16813
16816
  const newName = columnChangeFor(policyKey, rens);
16814
- const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
16817
+ const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy3) : PgSquasher.unsquashPolicy(policy3);
16815
16818
  unsquashedPolicy.name = newName;
16816
- policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
16819
+ policy3 = PgSquasher.squashPolicy(unsquashedPolicy);
16817
16820
  return newName;
16818
16821
  }
16819
16822
  );
@@ -16825,8 +16828,12 @@ var init_snapshotsDiffer = __esm({
16825
16828
  const indPolicyCreates = [];
16826
16829
  const indPolicyDeletes = [];
16827
16830
  const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
16828
- deleted: indPolicyRes.deleted.map((t) => PgSquasher.unsquashPolicy(t.values)),
16829
- created: indPolicyRes.added.map((t) => PgSquasher.unsquashPolicy(t.values))
16831
+ deleted: indPolicyRes.deleted.map(
16832
+ (t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
16833
+ ),
16834
+ created: indPolicyRes.added.map(
16835
+ (t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
16836
+ )
16830
16837
  });
16831
16838
  if (created.length > 0) {
16832
16839
  indPolicyCreates.push({
@@ -16949,17 +16956,17 @@ var init_snapshotsDiffer = __esm({
16949
16956
  const jsonDeletedCheckConstraints = [];
16950
16957
  const jsonCreatedCheckConstraints = [];
16951
16958
  for (let it of alteredTables) {
16952
- let addedColumns = [];
16959
+ let addedColumns;
16953
16960
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
16954
16961
  const addedPkColumns = it.addedCompositePKs[addedPkName];
16955
- addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
16962
+ addedColumns = PgSquasher.unsquashPK(addedPkColumns);
16956
16963
  }
16957
- let deletedColumns = [];
16964
+ let deletedColumns;
16958
16965
  for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
16959
16966
  const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
16960
- deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
16967
+ deletedColumns = PgSquasher.unsquashPK(deletedPkColumns);
16961
16968
  }
16962
- const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
16969
+ const doPerformDeleteAndCreate = JSON.stringify(addedColumns ?? {}) !== JSON.stringify(deletedColumns ?? {});
16963
16970
  let addedCompositePKs = [];
16964
16971
  let deletedCompositePKs = [];
16965
16972
  let alteredCompositePKs = [];
@@ -16967,22 +16974,18 @@ var init_snapshotsDiffer = __esm({
16967
16974
  addedCompositePKs = prepareAddCompositePrimaryKeyPg(
16968
16975
  it.name,
16969
16976
  it.schema,
16970
- it.addedCompositePKs,
16971
- curFull
16977
+ it.addedCompositePKs
16972
16978
  );
16973
16979
  deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
16974
16980
  it.name,
16975
16981
  it.schema,
16976
- it.deletedCompositePKs,
16977
- prevFull
16982
+ it.deletedCompositePKs
16978
16983
  );
16979
16984
  }
16980
16985
  alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
16981
16986
  it.name,
16982
16987
  it.schema,
16983
- it.alteredCompositePKs,
16984
- prevFull,
16985
- curFull
16988
+ it.alteredCompositePKs
16986
16989
  );
16987
16990
  let addedUniqueConstraints = [];
16988
16991
  let deletedUniqueConstraints = [];
@@ -17101,9 +17104,9 @@ var init_snapshotsDiffer = __esm({
17101
17104
  );
17102
17105
  }
17103
17106
  typedResult.alteredPolicies.forEach(({ values }) => {
17104
- const policy4 = PgSquasher.unsquashPolicy(values);
17105
- const newPolicy = PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
17106
- const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
17107
+ const policy3 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
17108
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json22.policies[policy3.name].values);
17109
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy3.name].values);
17107
17110
  if (newPolicy.as !== oldPolicy.as) {
17108
17111
  jsonDropIndPoliciesStatements.push(
17109
17112
  ...prepareDropIndPolicyJsons(
@@ -17162,8 +17165,8 @@ var init_snapshotsDiffer = __esm({
17162
17165
  }
17163
17166
  alteredTables.forEach((it) => {
17164
17167
  Object.keys(it.alteredPolicies).forEach((policyName) => {
17165
- const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
17166
- const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
17168
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
17169
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
17167
17170
  if (newPolicy.as !== oldPolicy.as) {
17168
17171
  jsonDropPoliciesStatements.push(
17169
17172
  ...prepareDropPolicyJsons(
@@ -17217,7 +17220,8 @@ var init_snapshotsDiffer = __esm({
17217
17220
  if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
17218
17221
  jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
17219
17222
  }
17220
- if (table4.isRLSEnabled !== tableInPreviousState.isRLSEnabled) {
17223
+ const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
17224
+ if (table4.isRLSEnabled !== wasRlsEnabled) {
17221
17225
  if (table4.isRLSEnabled) {
17222
17226
  jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
17223
17227
  } else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
@@ -17344,7 +17348,11 @@ var init_snapshotsDiffer = __esm({
17344
17348
  });
17345
17349
  jsonCreatePoliciesStatements.push(...[].concat(
17346
17350
  ...createdTables.map(
17347
- (it) => prepareCreatePolicyJsons(it.name, it.schema, Object.values(it.policies).map(PgSquasher.unsquashPolicy))
17351
+ (it) => prepareCreatePolicyJsons(
17352
+ it.name,
17353
+ it.schema,
17354
+ Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
17355
+ )
17348
17356
  )
17349
17357
  ));
17350
17358
  const createViews = [];
@@ -17559,7 +17567,7 @@ var init_snapshotsDiffer = __esm({
17559
17567
  }
17560
17568
  return true;
17561
17569
  });
17562
- const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
17570
+ const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
17563
17571
  const uniqueSqlStatements = [];
17564
17572
  sqlStatements.forEach((ss) => {
17565
17573
  if (!uniqueSqlStatements.includes(ss)) {
@@ -17976,9 +17984,9 @@ var init_snapshotsDiffer = __esm({
17976
17984
  jsonStatements.push(...jsonDeletedCompositePKs);
17977
17985
  jsonStatements.push(...jsonTableAlternations);
17978
17986
  jsonStatements.push(...jsonAddedCompositePKs);
17987
+ jsonStatements.push(...jsonAddColumnsStatemets);
17979
17988
  jsonStatements.push(...jsonAddedUniqueConstraints);
17980
17989
  jsonStatements.push(...jsonDeletedUniqueConstraints);
17981
- jsonStatements.push(...jsonAddColumnsStatemets);
17982
17990
  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
17983
17991
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
17984
17992
  jsonStatements.push(...jsonCreatedCheckConstraints);
@@ -23732,7 +23740,7 @@ function vector(a, b) {
23732
23740
  return new PgVectorBuilder(name2, config);
23733
23741
  }
23734
23742
  var _a113, _b92, PgVectorBuilder, _a114, _b93, PgVector;
23735
- var init_vector2 = __esm({
23743
+ var init_vector = __esm({
23736
23744
  "../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
23737
23745
  "use strict";
23738
23746
  init_entity();
@@ -23839,7 +23847,7 @@ var init_all = __esm({
23839
23847
  init_bit();
23840
23848
  init_halfvec();
23841
23849
  init_sparsevec();
23842
- init_vector2();
23850
+ init_vector();
23843
23851
  }
23844
23852
  });
23845
23853
 
@@ -24311,7 +24319,7 @@ function jaccardDistance(column4, value) {
24311
24319
  }
24312
24320
  return sql`${column4} <%> ${value}`;
24313
24321
  }
24314
- var init_vector3 = __esm({
24322
+ var init_vector2 = __esm({
24315
24323
  "../drizzle-orm/dist/sql/functions/vector.js"() {
24316
24324
  "use strict";
24317
24325
  init_sql();
@@ -24323,7 +24331,7 @@ var init_functions = __esm({
24323
24331
  "../drizzle-orm/dist/sql/functions/index.js"() {
24324
24332
  "use strict";
24325
24333
  init_aggregate();
24326
- init_vector3();
24334
+ init_vector2();
24327
24335
  }
24328
24336
  });
24329
24337
 
@@ -24553,7 +24561,7 @@ var init_columns = __esm({
24553
24561
  init_bit();
24554
24562
  init_halfvec();
24555
24563
  init_sparsevec();
24556
- init_vector2();
24564
+ init_vector();
24557
24565
  }
24558
24566
  });
24559
24567
 
@@ -28299,6 +28307,24 @@ var init_pg_core = __esm({
28299
28307
  }
28300
28308
  });
28301
28309
 
28310
+ // src/extensions/vector.ts
28311
+ var vectorOps;
28312
+ var init_vector3 = __esm({
28313
+ "src/extensions/vector.ts"() {
28314
+ "use strict";
28315
+ vectorOps = [
28316
+ "vector_l2_ops",
28317
+ "vector_ip_ops",
28318
+ "vector_cosine_ops",
28319
+ "vector_l1_ops",
28320
+ "bit_hamming_ops",
28321
+ "bit_jaccard_ops",
28322
+ "halfvec_l2_ops",
28323
+ "sparsevec_l2_ops"
28324
+ ];
28325
+ }
28326
+ });
28327
+
28302
28328
  // src/serializer/utils.ts
28303
28329
  function getColumnCasing(column4, casing2) {
28304
28330
  if (!column4.name) return "";
@@ -28404,7 +28430,7 @@ var init_pgSerializer = __esm({
28404
28430
  init_source();
28405
28431
  init_dist();
28406
28432
  init_pg_core();
28407
- init_vector();
28433
+ init_vector3();
28408
28434
  init_outputs();
28409
28435
  init_utils();
28410
28436
  init_utils6();
@@ -28508,7 +28534,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
28508
28534
  columnToSet.default = sqlToStr(column4.default, casing2);
28509
28535
  } else {
28510
28536
  if (typeof column4.default === "string") {
28511
- columnToSet.default = `'${column4.default}'`;
28537
+ columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
28512
28538
  } else {
28513
28539
  if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
28514
28540
  columnToSet.default = `'${JSON.stringify(column4.default)}'::${sqlTypeLowered}`;
@@ -28690,17 +28716,17 @@ ${withStyle.errorWarning(
28690
28716
  with: value.config.with ?? {}
28691
28717
  };
28692
28718
  });
28693
- policies2.forEach((policy4) => {
28719
+ policies2.forEach((policy3) => {
28694
28720
  const mappedTo = [];
28695
- if (!policy4.to) {
28721
+ if (!policy3.to) {
28696
28722
  mappedTo.push("public");
28697
28723
  } else {
28698
- if (policy4.to && typeof policy4.to === "string") {
28699
- mappedTo.push(policy4.to);
28700
- } else if (policy4.to && is(policy4.to, PgRole)) {
28701
- mappedTo.push(policy4.to.name);
28702
- } else if (policy4.to && Array.isArray(policy4.to)) {
28703
- policy4.to.forEach((it) => {
28724
+ if (policy3.to && typeof policy3.to === "string") {
28725
+ mappedTo.push(policy3.to);
28726
+ } else if (policy3.to && is(policy3.to, PgRole)) {
28727
+ mappedTo.push(policy3.to.name);
28728
+ } else if (policy3.to && Array.isArray(policy3.to)) {
28729
+ policy3.to.forEach((it) => {
28704
28730
  if (typeof it === "string") {
28705
28731
  mappedTo.push(it);
28706
28732
  } else if (is(it, PgRole)) {
@@ -28709,24 +28735,24 @@ ${withStyle.errorWarning(
28709
28735
  });
28710
28736
  }
28711
28737
  }
28712
- if (policiesObject[policy4.name] !== void 0) {
28738
+ if (policiesObject[policy3.name] !== void 0) {
28713
28739
  console.log(
28714
28740
  `
28715
28741
  ${withStyle.errorWarning(
28716
28742
  `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
28717
- policy4.name
28743
+ policy3.name
28718
28744
  )} name`
28719
28745
  )}`
28720
28746
  );
28721
28747
  process.exit(1);
28722
28748
  }
28723
- policiesObject[policy4.name] = {
28724
- name: policy4.name,
28725
- as: policy4.as?.toUpperCase() ?? "PERMISSIVE",
28726
- for: policy4.for?.toUpperCase() ?? "ALL",
28749
+ policiesObject[policy3.name] = {
28750
+ name: policy3.name,
28751
+ as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
28752
+ for: policy3.for?.toUpperCase() ?? "ALL",
28727
28753
  to: mappedTo.sort(),
28728
- using: is(policy4.using, SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
28729
- withCheck: is(policy4.withCheck, SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
28754
+ using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
28755
+ withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
28730
28756
  };
28731
28757
  });
28732
28758
  checks.forEach((check) => {
@@ -28770,28 +28796,28 @@ ${withStyle.errorWarning(
28770
28796
  isRLSEnabled: enableRLS
28771
28797
  };
28772
28798
  }
28773
- for (const policy4 of policies) {
28774
- if (!policy4._linkedTable) {
28799
+ for (const policy3 of policies) {
28800
+ if (!policy3._linkedTable) {
28775
28801
  console.log(
28776
28802
  `
28777
28803
  ${withStyle.errorWarning(
28778
- `"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:`
28804
+ `"Policy ${policy3.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:`
28779
28805
  )}`
28780
28806
  );
28781
28807
  continue;
28782
28808
  }
28783
- const tableConfig = getTableConfig(policy4._linkedTable);
28809
+ const tableConfig = getTableConfig(policy3._linkedTable);
28784
28810
  const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
28785
28811
  const mappedTo = [];
28786
- if (!policy4.to) {
28812
+ if (!policy3.to) {
28787
28813
  mappedTo.push("public");
28788
28814
  } else {
28789
- if (policy4.to && typeof policy4.to === "string") {
28790
- mappedTo.push(policy4.to);
28791
- } else if (policy4.to && is(policy4.to, PgRole)) {
28792
- mappedTo.push(policy4.to.name);
28793
- } else if (policy4.to && Array.isArray(policy4.to)) {
28794
- policy4.to.forEach((it) => {
28815
+ if (policy3.to && typeof policy3.to === "string") {
28816
+ mappedTo.push(policy3.to);
28817
+ } else if (policy3.to && is(policy3.to, PgRole)) {
28818
+ mappedTo.push(policy3.to.name);
28819
+ } else if (policy3.to && Array.isArray(policy3.to)) {
28820
+ policy3.to.forEach((it) => {
28795
28821
  if (typeof it === "string") {
28796
28822
  mappedTo.push(it);
28797
28823
  } else if (is(it, PgRole)) {
@@ -28800,30 +28826,31 @@ ${withStyle.errorWarning(
28800
28826
  });
28801
28827
  }
28802
28828
  }
28803
- if (result[tableKey2]?.policies[policy4.name] !== void 0 || policiesToReturn[policy4.name] !== void 0) {
28829
+ if (result[tableKey2]?.policies[policy3.name] !== void 0 || policiesToReturn[policy3.name] !== void 0) {
28804
28830
  console.log(
28805
28831
  `
28806
28832
  ${withStyle.errorWarning(
28807
28833
  `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
28808
- policy4.name
28834
+ policy3.name
28809
28835
  )} name`
28810
28836
  )}`
28811
28837
  );
28812
28838
  process.exit(1);
28813
28839
  }
28814
28840
  const mappedPolicy = {
28815
- name: policy4.name,
28816
- as: policy4.as?.toUpperCase() ?? "PERMISSIVE",
28817
- for: policy4.for?.toUpperCase() ?? "ALL",
28841
+ name: policy3.name,
28842
+ as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
28843
+ for: policy3.for?.toUpperCase() ?? "ALL",
28818
28844
  to: mappedTo.sort(),
28819
- using: is(policy4.using, SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
28820
- withCheck: is(policy4.withCheck, SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
28845
+ using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
28846
+ withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
28821
28847
  };
28822
28848
  if (result[tableKey2]) {
28823
- result[tableKey2].policies[policy4.name] = mappedPolicy;
28849
+ result[tableKey2].policies[policy3.name] = mappedPolicy;
28824
28850
  } else {
28825
- policiesToReturn[policy4.name] = {
28851
+ policiesToReturn[policy3.name] = {
28826
28852
  ...mappedPolicy,
28853
+ schema: tableConfig.schema ?? "public",
28827
28854
  on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
28828
28855
  };
28829
28856
  }
@@ -29032,9 +29059,10 @@ ${withStyle.errorWarning(
29032
29059
  while (end > start && str[end - 1] === char3) --end;
29033
29060
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
29034
29061
  };
29035
- fromDatabase = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback) => {
29062
+ fromDatabase = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback, tsSchema) => {
29036
29063
  const result = {};
29037
29064
  const views = {};
29065
+ const policies = {};
29038
29066
  const internals = { tables: {} };
29039
29067
  const where = schemaFilters.map((t) => `n.nspname = '${t}'`).join(" or ");
29040
29068
  const allTables = await db.query(
@@ -29160,7 +29188,8 @@ WHERE
29160
29188
  }
29161
29189
  }
29162
29190
  }
29163
- const wherePolicies = schemaFilters.map((t) => `schemaname = '${t}'`).join(" or ");
29191
+ const schemasForLinkedPoliciesInSchema = Object.values(tsSchema?.policies ?? {}).map((it) => it.schema);
29192
+ const wherePolicies = [...schemaFilters, ...schemasForLinkedPoliciesInSchema].map((t) => `schemaname = '${t}'`).join(" or ");
29164
29193
  const policiesByTable = {};
29165
29194
  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}`};`);
29166
29195
  for (const dbPolicy of allPolicies) {
@@ -29176,6 +29205,15 @@ WHERE
29176
29205
  [dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
29177
29206
  };
29178
29207
  }
29208
+ if (tsSchema?.policies[dbPolicy.name]) {
29209
+ policies[dbPolicy.name] = {
29210
+ ...rest,
29211
+ to: parsedTo,
29212
+ withCheck: parsedWithCheck,
29213
+ using: parsedUsing,
29214
+ on: tsSchema?.policies[dbPolicy.name].on
29215
+ };
29216
+ }
29179
29217
  }
29180
29218
  if (progressCallback) {
29181
29219
  progressCallback(
@@ -29768,7 +29806,7 @@ WHERE
29768
29806
  schemas: schemasObject,
29769
29807
  sequences: sequencesToReturn,
29770
29808
  roles: rolesToReturn,
29771
- policies: {},
29809
+ policies,
29772
29810
  views,
29773
29811
  _meta: {
29774
29812
  schemas: {},
@@ -29781,10 +29819,7 @@ WHERE
29781
29819
  defaultForColumn = (column4, internals, tableName) => {
29782
29820
  const columnName = column4.column_name;
29783
29821
  const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
29784
- if (column4.column_default === null) {
29785
- return void 0;
29786
- }
29787
- if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
29822
+ if (column4.column_default === null || column4.column_default === void 0 || column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
29788
29823
  return void 0;
29789
29824
  }
29790
29825
  if (column4.column_default.endsWith("[]")) {
@@ -30212,7 +30247,7 @@ var init_blob = __esm({
30212
30247
  return "blob";
30213
30248
  }
30214
30249
  mapFromDriverValue(value) {
30215
- return BigInt(value.toString());
30250
+ return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
30216
30251
  }
30217
30252
  mapToDriverValue(value) {
30218
30253
  return Buffer.from(value.toString());
@@ -30237,7 +30272,7 @@ var init_blob = __esm({
30237
30272
  return "blob";
30238
30273
  }
30239
30274
  mapFromDriverValue(value) {
30240
- return JSON.parse(value.toString());
30275
+ return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
30241
30276
  }
30242
30277
  mapToDriverValue(value) {
30243
30278
  return Buffer.from(JSON.stringify(value));
@@ -33463,6 +33498,7 @@ var init_sqliteSerializer = __esm({
33463
33498
  init_dist();
33464
33499
  init_sqlite_core();
33465
33500
  init_outputs();
33501
+ init_utils();
33466
33502
  init_utils6();
33467
33503
  generateSqliteSnapshot = (tables, views, casing2) => {
33468
33504
  const dialect4 = new SQLiteSyncDialect({ casing: casing2 });
@@ -33506,7 +33542,7 @@ var init_sqliteSerializer = __esm({
33506
33542
  if (is(column4.default, SQL)) {
33507
33543
  columnToSet.default = sqlToStr(column4.default, casing2);
33508
33544
  } else {
33509
- columnToSet.default = typeof column4.default === "string" ? `'${column4.default}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
33545
+ columnToSet.default = typeof column4.default === "string" ? `'${escapeSingleQuotes(column4.default)}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
33510
33546
  }
33511
33547
  }
33512
33548
  columnsObject[name2] = columnToSet;
@@ -34057,6 +34093,25 @@ WHERE
34057
34093
  }
34058
34094
  });
34059
34095
 
34096
+ // src/extensions/getTablesFilterByExtensions.ts
34097
+ var getTablesFilterByExtensions;
34098
+ var init_getTablesFilterByExtensions = __esm({
34099
+ "src/extensions/getTablesFilterByExtensions.ts"() {
34100
+ "use strict";
34101
+ getTablesFilterByExtensions = ({
34102
+ extensionsFilters,
34103
+ dialect: dialect4
34104
+ }) => {
34105
+ if (extensionsFilters) {
34106
+ if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
34107
+ return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
34108
+ }
34109
+ }
34110
+ return [];
34111
+ };
34112
+ }
34113
+ });
34114
+
34060
34115
  // ../drizzle-orm/dist/mysql-core/alias.js
34061
34116
  var init_alias4 = __esm({
34062
34117
  "../drizzle-orm/dist/mysql-core/alias.js"() {
@@ -34679,7 +34734,7 @@ var init_datetime = __esm({
34679
34734
  // ../drizzle-orm/dist/mysql-core/columns/decimal.js
34680
34735
  function decimal(a, b = {}) {
34681
34736
  const { name: name2, config } = getColumnNameAndConfig(a, b);
34682
- return new MySqlDecimalBuilder(name2, config.precision, config.scale);
34737
+ return new MySqlDecimalBuilder(name2, config);
34683
34738
  }
34684
34739
  var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
34685
34740
  var init_decimal = __esm({
@@ -34689,10 +34744,11 @@ var init_decimal = __esm({
34689
34744
  init_utils2();
34690
34745
  init_common4();
34691
34746
  MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
34692
- constructor(name2, precision, scale) {
34747
+ constructor(name2, config) {
34693
34748
  super(name2, "string", "MySqlDecimal");
34694
- this.config.precision = precision;
34695
- this.config.scale = scale;
34749
+ this.config.precision = config?.precision;
34750
+ this.config.scale = config?.scale;
34751
+ this.config.unsigned = config?.unsigned;
34696
34752
  }
34697
34753
  /** @internal */
34698
34754
  build(table4) {
@@ -34708,15 +34764,19 @@ var init_decimal = __esm({
34708
34764
  super(...arguments);
34709
34765
  __publicField(this, "precision", this.config.precision);
34710
34766
  __publicField(this, "scale", this.config.scale);
34767
+ __publicField(this, "unsigned", this.config.unsigned);
34711
34768
  }
34712
34769
  getSQLType() {
34770
+ let type = "";
34713
34771
  if (this.precision !== void 0 && this.scale !== void 0) {
34714
- return `decimal(${this.precision},${this.scale})`;
34772
+ type += `decimal(${this.precision},${this.scale})`;
34715
34773
  } else if (this.precision === void 0) {
34716
- return "decimal";
34774
+ type += "decimal";
34717
34775
  } else {
34718
- return `decimal(${this.precision})`;
34776
+ type += `decimal(${this.precision})`;
34719
34777
  }
34778
+ type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
34779
+ return this.unsigned ? `${type} unsigned` : type;
34720
34780
  }
34721
34781
  };
34722
34782
  __publicField(MySqlDecimal, _a260, "MySqlDecimal");
@@ -34740,6 +34800,7 @@ var init_double = __esm({
34740
34800
  super(name2, "number", "MySqlDouble");
34741
34801
  this.config.precision = config?.precision;
34742
34802
  this.config.scale = config?.scale;
34803
+ this.config.unsigned = config?.unsigned;
34743
34804
  }
34744
34805
  /** @internal */
34745
34806
  build(table4) {
@@ -34752,15 +34813,18 @@ var init_double = __esm({
34752
34813
  super(...arguments);
34753
34814
  __publicField(this, "precision", this.config.precision);
34754
34815
  __publicField(this, "scale", this.config.scale);
34816
+ __publicField(this, "unsigned", this.config.unsigned);
34755
34817
  }
34756
34818
  getSQLType() {
34819
+ let type = "";
34757
34820
  if (this.precision !== void 0 && this.scale !== void 0) {
34758
- return `double(${this.precision},${this.scale})`;
34821
+ type += `double(${this.precision},${this.scale})`;
34759
34822
  } else if (this.precision === void 0) {
34760
- return "double";
34823
+ type += "double";
34761
34824
  } else {
34762
- return `double(${this.precision})`;
34825
+ type += `double(${this.precision})`;
34763
34826
  }
34827
+ return this.unsigned ? `${type} unsigned` : type;
34764
34828
  }
34765
34829
  };
34766
34830
  __publicField(MySqlDouble, _a262, "MySqlDouble");
@@ -34810,18 +34874,23 @@ var init_enum2 = __esm({
34810
34874
  });
34811
34875
 
34812
34876
  // ../drizzle-orm/dist/mysql-core/columns/float.js
34813
- function float(name2) {
34814
- return new MySqlFloatBuilder(name2 ?? "");
34877
+ function float(a, b) {
34878
+ const { name: name2, config } = getColumnNameAndConfig(a, b);
34879
+ return new MySqlFloatBuilder(name2, config);
34815
34880
  }
34816
34881
  var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
34817
34882
  var init_float = __esm({
34818
34883
  "../drizzle-orm/dist/mysql-core/columns/float.js"() {
34819
34884
  "use strict";
34820
34885
  init_entity();
34886
+ init_utils2();
34821
34887
  init_common4();
34822
34888
  MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
34823
- constructor(name2) {
34889
+ constructor(name2, config) {
34824
34890
  super(name2, "number", "MySqlFloat");
34891
+ this.config.precision = config?.precision;
34892
+ this.config.scale = config?.scale;
34893
+ this.config.unsigned = config?.unsigned;
34825
34894
  }
34826
34895
  /** @internal */
34827
34896
  build(table4) {
@@ -34830,8 +34899,22 @@ var init_float = __esm({
34830
34899
  };
34831
34900
  __publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
34832
34901
  MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
34902
+ constructor() {
34903
+ super(...arguments);
34904
+ __publicField(this, "precision", this.config.precision);
34905
+ __publicField(this, "scale", this.config.scale);
34906
+ __publicField(this, "unsigned", this.config.unsigned);
34907
+ }
34833
34908
  getSQLType() {
34834
- return "float";
34909
+ let type = "";
34910
+ if (this.precision !== void 0 && this.scale !== void 0) {
34911
+ type += `float(${this.precision},${this.scale})`;
34912
+ } else if (this.precision === void 0) {
34913
+ type += "float";
34914
+ } else {
34915
+ type += `float(${this.precision})`;
34916
+ }
34917
+ return this.unsigned ? `${type} unsigned` : type;
34835
34918
  }
34836
34919
  };
34837
34920
  __publicField(MySqlFloat, _a266, "MySqlFloat");
@@ -38359,15 +38442,15 @@ function clearDefaults(defaultValue, collate) {
38359
38442
  if (defaultValue.startsWith(collate)) {
38360
38443
  resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
38361
38444
  if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
38362
- return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
38445
+ return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
38363
38446
  } else {
38364
- return `'${resultDefault}'`;
38447
+ return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
38365
38448
  }
38366
38449
  } else {
38367
38450
  return `(${resultDefault})`;
38368
38451
  }
38369
38452
  }
38370
- var generateMySqlSnapshot, fromDatabase3;
38453
+ var handleEnumType, generateMySqlSnapshot, fromDatabase3;
38371
38454
  var init_mysqlSerializer = __esm({
38372
38455
  "src/serializer/mysqlSerializer.ts"() {
38373
38456
  "use strict";
@@ -38375,7 +38458,14 @@ var init_mysqlSerializer = __esm({
38375
38458
  init_dist();
38376
38459
  init_mysql_core();
38377
38460
  init_outputs();
38461
+ init_utils();
38378
38462
  init_utils6();
38463
+ handleEnumType = (type) => {
38464
+ let str = type.split("(")[1];
38465
+ str = str.substring(0, str.length - 1);
38466
+ const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
38467
+ return `enum(${values.join(",")})`;
38468
+ };
38379
38469
  generateMySqlSnapshot = (tables, views, casing2) => {
38380
38470
  const dialect4 = new MySqlDialect({ casing: casing2 });
38381
38471
  const result = {};
@@ -38402,12 +38492,13 @@ var init_mysqlSerializer = __esm({
38402
38492
  columns.forEach((column4) => {
38403
38493
  const name2 = getColumnCasing(column4, casing2);
38404
38494
  const notNull = column4.notNull;
38405
- const sqlTypeLowered = column4.getSQLType().toLowerCase();
38495
+ const sqlType = column4.getSQLType();
38496
+ const sqlTypeLowered = sqlType.toLowerCase();
38406
38497
  const autoIncrement = typeof column4.autoIncrement === "undefined" ? false : column4.autoIncrement;
38407
38498
  const generated = column4.generated;
38408
38499
  const columnToSet = {
38409
38500
  name: name2,
38410
- type: column4.getSQLType(),
38501
+ type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
38411
38502
  primaryKey: false,
38412
38503
  // If field is autoincrement it's notNull by default
38413
38504
  // notNull: autoIncrement ? true : notNull,
@@ -38454,7 +38545,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
38454
38545
  columnToSet.default = sqlToStr(column4.default, casing2);
38455
38546
  } else {
38456
38547
  if (typeof column4.default === "string") {
38457
- columnToSet.default = `'${column4.default}'`;
38548
+ columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
38458
38549
  } else {
38459
38550
  if (sqlTypeLowered === "json") {
38460
38551
  columnToSet.default = `'${JSON.stringify(column4.default)}'`;
@@ -38823,15 +38914,15 @@ ${withStyle.errorWarning(
38823
38914
  changedType = columnType.replace("bigint unsigned", "serial");
38824
38915
  }
38825
38916
  }
38826
- if (columnType.startsWith("tinyint")) {
38827
- changedType = "tinyint";
38917
+ if (columnType.includes("decimal(10,0)")) {
38918
+ changedType = columnType.replace("decimal(10,0)", "decimal");
38828
38919
  }
38829
38920
  let onUpdate = void 0;
38830
38921
  if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
38831
38922
  onUpdate = true;
38832
38923
  }
38833
38924
  const newColumn = {
38834
- default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
38925
+ default: columnDefault === null || columnDefault === void 0 ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${escapeSingleQuotes(columnDefault)}'`,
38835
38926
  autoincrement: isAutoincrement,
38836
38927
  name: columnName,
38837
38928
  type: changedType,
@@ -39346,6 +39437,7 @@ var init_utils9 = __esm({
39346
39437
  "use strict";
39347
39438
  import_hanji7 = __toESM(require_hanji());
39348
39439
  init_lib();
39440
+ init_getTablesFilterByExtensions();
39349
39441
  init_global();
39350
39442
  init_schemaValidator();
39351
39443
  init_serializer();
@@ -39868,7 +39960,7 @@ init_mjs();
39868
39960
  init_global();
39869
39961
  init_pgSerializer();
39870
39962
  init_views();
39871
- var pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
39963
+ var pgPushIntrospect = async (db, filters, schemaFilters, entities, tsSchema) => {
39872
39964
  const matchers = filters.map((it) => {
39873
39965
  return new Minimatch(it);
39874
39966
  });
@@ -39896,7 +39988,7 @@ var pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
39896
39988
  );
39897
39989
  const res = await (0, import_hanji3.renderWithTask)(
39898
39990
  progress,
39899
- fromDatabase(db, filter2, schemaFilters, entities)
39991
+ fromDatabase(db, filter2, schemaFilters, entities, void 0, tsSchema)
39900
39992
  );
39901
39993
  const schema4 = { id: originUUID, prevId: "", ...res };
39902
39994
  const { internal, ...schemaWithoutInternals } = schema4;
@@ -40064,7 +40156,7 @@ var pgSuggestions = async (db, statements) => {
40064
40156
  }
40065
40157
  }
40066
40158
  }
40067
- const stmnt = fromJson([statement], "postgresql");
40159
+ const stmnt = fromJson([statement], "postgresql", "push");
40068
40160
  if (typeof stmnt !== "undefined") {
40069
40161
  statementsToExecute.push(...stmnt);
40070
40162
  }
@@ -40302,6 +40394,7 @@ var sqlitePushIntrospect = async (db, filters) => {
40302
40394
 
40303
40395
  // src/api.ts
40304
40396
  init_sqlitePushUtils();
40397
+ init_getTablesFilterByExtensions();
40305
40398
  init_global();
40306
40399
  init_migrationPreparator();
40307
40400
  init_mysqlSchema();
@@ -40355,9 +40448,12 @@ var generateMigration = async (prev, cur) => {
40355
40448
  );
40356
40449
  return sqlStatements;
40357
40450
  };
40358
- var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
40451
+ var pushSchema = async (imports, drizzleInstance, schemaFilters, tablesFilter, extensionsFilters) => {
40359
40452
  const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
40360
40453
  const { sql: sql2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
40454
+ const filters = (tablesFilter ?? []).concat(
40455
+ getTablesFilterByExtensions({ extensionsFilters, dialect: "postgresql" })
40456
+ );
40361
40457
  const db = {
40362
40458
  query: async (query, params) => {
40363
40459
  const res = await drizzleInstance.execute(sql2.raw(query));
@@ -40367,7 +40463,7 @@ var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
40367
40463
  const cur = generateDrizzleJson(imports);
40368
40464
  const { schema: prev } = await pgPushIntrospect(
40369
40465
  db,
40370
- [],
40466
+ filters,
40371
40467
  schemaFilters ?? ["public"],
40372
40468
  void 0
40373
40469
  );