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.mjs CHANGED
@@ -7530,30 +7530,11 @@ var init_mysqlSchema = __esm({
7530
7530
  }
7531
7531
  });
7532
7532
 
7533
- // src/extensions/vector.ts
7534
- var vectorOps;
7535
- var init_vector = __esm({
7536
- "src/extensions/vector.ts"() {
7537
- "use strict";
7538
- vectorOps = [
7539
- "vector_l2_ops",
7540
- "vector_ip_ops",
7541
- "vector_cosine_ops",
7542
- "vector_l1_ops",
7543
- "bit_hamming_ops",
7544
- "bit_jaccard_ops",
7545
- "halfvec_l2_ops",
7546
- "sparsevec_l2_ops"
7547
- ];
7548
- }
7549
- });
7550
-
7551
7533
  // src/serializer/pgSchema.ts
7552
7534
  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;
7553
7535
  var init_pgSchema = __esm({
7554
7536
  "src/serializer/pgSchema.ts"() {
7555
7537
  "use strict";
7556
- init_vector();
7557
7538
  init_global();
7558
7539
  init_lib();
7559
7540
  indexV2 = objectType({
@@ -7761,7 +7742,8 @@ var init_pgSchema = __esm({
7761
7742
  to: stringType().array().optional(),
7762
7743
  using: stringType().optional(),
7763
7744
  withCheck: stringType().optional(),
7764
- on: stringType().optional()
7745
+ on: stringType().optional(),
7746
+ schema: stringType().optional()
7765
7747
  }).strict();
7766
7748
  policySquashed = objectType({
7767
7749
  name: stringType(),
@@ -8012,7 +7994,7 @@ var init_pgSchema = __esm({
8012
7994
  squashIdx: (idx) => {
8013
7995
  index2.parse(idx);
8014
7996
  return `${idx.name};${idx.columns.map(
8015
- (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
7997
+ (c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass ? c.opclass : ""}`
8016
7998
  ).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
8017
7999
  },
8018
8000
  unsquashIdx: (input) => {
@@ -8078,11 +8060,11 @@ var init_pgSchema = __esm({
8078
8060
  squashFK: (fk4) => {
8079
8061
  return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
8080
8062
  },
8081
- squashPolicy: (policy4) => {
8082
- return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.using}--${policy4.withCheck}--${policy4.on}`;
8063
+ squashPolicy: (policy3) => {
8064
+ return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.using}--${policy3.withCheck}--${policy3.on}`;
8083
8065
  },
8084
- unsquashPolicy: (policy4) => {
8085
- const splitted = policy4.split("--");
8066
+ unsquashPolicy: (policy3) => {
8067
+ const splitted = policy3.split("--");
8086
8068
  return {
8087
8069
  name: splitted[0],
8088
8070
  as: splitted[1],
@@ -8093,8 +8075,18 @@ var init_pgSchema = __esm({
8093
8075
  on: splitted[6] !== "undefined" ? splitted[6] : void 0
8094
8076
  };
8095
8077
  },
8096
- squashPolicyPush: (policy4) => {
8097
- return `${policy4.name}--${policy4.as}--${policy4.for}--${policy4.to?.join(",")}--${policy4.on}`;
8078
+ squashPolicyPush: (policy3) => {
8079
+ return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.on}`;
8080
+ },
8081
+ unsquashPolicyPush: (policy3) => {
8082
+ const splitted = policy3.split("--");
8083
+ return {
8084
+ name: splitted[0],
8085
+ as: splitted[1],
8086
+ for: splitted[2],
8087
+ to: splitted[3].split(","),
8088
+ on: splitted[4] !== "undefined" ? splitted[4] : void 0
8089
+ };
8098
8090
  },
8099
8091
  squashPK: (pk) => {
8100
8092
  return `${pk.columns.join(",")};${pk.name}`;
@@ -8208,8 +8200,8 @@ var init_pgSchema = __esm({
8208
8200
  return PgSquasher.squashUnique(unq);
8209
8201
  }
8210
8202
  );
8211
- const squashedPolicies = mapValues(it[1].policies, (policy4) => {
8212
- return action === "push" ? PgSquasher.squashPolicyPush(policy4) : PgSquasher.squashPolicy(policy4);
8203
+ const squashedPolicies = mapValues(it[1].policies, (policy3) => {
8204
+ return action === "push" ? PgSquasher.squashPolicyPush(policy3) : PgSquasher.squashPolicy(policy3);
8213
8205
  });
8214
8206
  const squashedChecksContraints = mapValues(
8215
8207
  it[1].checkConstraints,
@@ -8597,6 +8589,9 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
8597
8589
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
8598
8590
  return { addedColumns, removedColumns };
8599
8591
  }
8592
+ function escapeSingleQuotes(str) {
8593
+ return str.replace(/'/g, "''");
8594
+ }
8600
8595
  var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
8601
8596
  var init_utils = __esm({
8602
8597
  "src/utils.ts"() {
@@ -11932,7 +11927,7 @@ function fromJson(statements, dialect4, action, json22) {
11932
11927
  }).filter((it) => it !== "");
11933
11928
  return result;
11934
11929
  }
11935
- 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;
11930
+ 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;
11936
11931
  var init_sqlgenerator = __esm({
11937
11932
  "src/sqlgenerator.ts"() {
11938
11933
  "use strict";
@@ -11940,51 +11935,56 @@ var init_sqlgenerator = __esm({
11940
11935
  init_mysqlSchema();
11941
11936
  init_pgSchema();
11942
11937
  init_sqliteSchema();
11943
- pgNativeTypes = /* @__PURE__ */ new Set([
11944
- "uuid",
11945
- "smallint",
11946
- "integer",
11947
- "bigint",
11948
- "boolean",
11949
- "text",
11950
- "varchar",
11951
- "serial",
11952
- "bigserial",
11953
- "decimal",
11954
- "numeric",
11955
- "real",
11956
- "json",
11957
- "jsonb",
11958
- "time",
11959
- "time with time zone",
11960
- "time without time zone",
11961
- "time",
11962
- "timestamp",
11963
- "timestamp with time zone",
11964
- "timestamp without time zone",
11965
- "date",
11966
- "interval",
11967
- "bigint",
11968
- "bigserial",
11969
- "double precision",
11970
- "interval year",
11971
- "interval month",
11972
- "interval day",
11973
- "interval hour",
11974
- "interval minute",
11975
- "interval second",
11976
- "interval year to month",
11977
- "interval day to hour",
11978
- "interval day to minute",
11979
- "interval day to second",
11980
- "interval hour to minute",
11981
- "interval hour to second",
11982
- "interval minute to second"
11983
- ]);
11984
- isPgNativeType = (it) => {
11985
- if (pgNativeTypes.has(it)) return true;
11986
- const toCheck = it.replace(/ /g, "");
11987
- 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);
11938
+ init_utils();
11939
+ parseType = (schemaPrefix, type) => {
11940
+ const pgNativeTypes = [
11941
+ "uuid",
11942
+ "smallint",
11943
+ "integer",
11944
+ "bigint",
11945
+ "boolean",
11946
+ "text",
11947
+ "varchar",
11948
+ "serial",
11949
+ "bigserial",
11950
+ "decimal",
11951
+ "numeric",
11952
+ "real",
11953
+ "json",
11954
+ "jsonb",
11955
+ "time",
11956
+ "time with time zone",
11957
+ "time without time zone",
11958
+ "time",
11959
+ "timestamp",
11960
+ "timestamp with time zone",
11961
+ "timestamp without time zone",
11962
+ "date",
11963
+ "interval",
11964
+ "bigint",
11965
+ "bigserial",
11966
+ "double precision",
11967
+ "interval year",
11968
+ "interval month",
11969
+ "interval day",
11970
+ "interval hour",
11971
+ "interval minute",
11972
+ "interval second",
11973
+ "interval year to month",
11974
+ "interval day to hour",
11975
+ "interval day to minute",
11976
+ "interval day to second",
11977
+ "interval hour to minute",
11978
+ "interval hour to second",
11979
+ "interval minute to second",
11980
+ "char",
11981
+ "vector",
11982
+ "geometry"
11983
+ ];
11984
+ const arrayDefinitionRegex = /\[\d*(?:\[\d*\])*\]/g;
11985
+ const arrayDefinition = (type.match(arrayDefinitionRegex) ?? []).join("");
11986
+ const withoutArrayDefinition = type.replace(arrayDefinitionRegex, "");
11987
+ return pgNativeTypes.some((it) => type.startsWith(it)) ? `${withoutArrayDefinition}${arrayDefinition}` : `${schemaPrefix}"${withoutArrayDefinition}"${arrayDefinition}`;
11988
11988
  };
11989
11989
  Convertor = class {
11990
11990
  };
@@ -12025,14 +12025,14 @@ var init_sqlgenerator = __esm({
12025
12025
  return statement.type === "create_policy" && dialect4 === "postgresql";
12026
12026
  }
12027
12027
  convert(statement) {
12028
- const policy4 = statement.data;
12028
+ const policy3 = statement.data;
12029
12029
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12030
- const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
12031
- const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
12032
- const policyToPart = policy4.to?.map(
12030
+ const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
12031
+ const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
12032
+ const policyToPart = policy3.to?.map(
12033
12033
  (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
12034
12034
  ).join(", ");
12035
- return `CREATE POLICY "${policy4.name}" ON ${tableNameWithSchema} AS ${policy4.as?.toUpperCase()} FOR ${policy4.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12035
+ return `CREATE POLICY "${policy3.name}" ON ${tableNameWithSchema} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12036
12036
  }
12037
12037
  };
12038
12038
  PgDropPolicyConvertor = class extends Convertor {
@@ -12040,9 +12040,9 @@ var init_sqlgenerator = __esm({
12040
12040
  return statement.type === "drop_policy" && dialect4 === "postgresql";
12041
12041
  }
12042
12042
  convert(statement) {
12043
- const policy4 = statement.data;
12043
+ const policy3 = statement.data;
12044
12044
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12045
- return `DROP POLICY "${policy4.name}" ON ${tableNameWithSchema} CASCADE;`;
12045
+ return `DROP POLICY "${policy3.name}" ON ${tableNameWithSchema} CASCADE;`;
12046
12046
  }
12047
12047
  };
12048
12048
  PgRenamePolicyConvertor = class extends Convertor {
@@ -12058,9 +12058,9 @@ var init_sqlgenerator = __esm({
12058
12058
  can(statement, dialect4) {
12059
12059
  return statement.type === "alter_policy" && dialect4 === "postgresql";
12060
12060
  }
12061
- convert(statement) {
12062
- const newPolicy = PgSquasher.unsquashPolicy(statement.newData);
12063
- const oldPolicy = PgSquasher.unsquashPolicy(statement.oldData);
12061
+ convert(statement, _dialect, action) {
12062
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.newData) : PgSquasher.unsquashPolicy(statement.newData);
12063
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(statement.oldData) : PgSquasher.unsquashPolicy(statement.oldData);
12064
12064
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
12065
12065
  const usingPart = newPolicy.using ? ` USING (${newPolicy.using})` : oldPolicy.using ? ` USING (${oldPolicy.using})` : "";
12066
12066
  const withCheckPart = newPolicy.withCheck ? ` WITH CHECK (${newPolicy.withCheck})` : oldPolicy.withCheck ? ` WITH CHECK (${oldPolicy.withCheck})` : "";
@@ -12072,13 +12072,13 @@ var init_sqlgenerator = __esm({
12072
12072
  return statement.type === "create_ind_policy" && dialect4 === "postgresql";
12073
12073
  }
12074
12074
  convert(statement) {
12075
- const policy4 = statement.data;
12076
- const usingPart = policy4.using ? ` USING (${policy4.using})` : "";
12077
- const withCheckPart = policy4.withCheck ? ` WITH CHECK (${policy4.withCheck})` : "";
12078
- const policyToPart = policy4.to?.map(
12075
+ const policy3 = statement.data;
12076
+ const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
12077
+ const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
12078
+ const policyToPart = policy3.to?.map(
12079
12079
  (v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
12080
12080
  ).join(", ");
12081
- return `CREATE POLICY "${policy4.name}" ON ${policy4.on} AS ${policy4.as?.toUpperCase()} FOR ${policy4.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12081
+ return `CREATE POLICY "${policy3.name}" ON ${policy3.on} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
12082
12082
  }
12083
12083
  };
12084
12084
  PgDropIndPolicyConvertor = class extends Convertor {
@@ -12086,8 +12086,8 @@ var init_sqlgenerator = __esm({
12086
12086
  return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
12087
12087
  }
12088
12088
  convert(statement) {
12089
- const policy4 = statement.data;
12090
- return `DROP POLICY "${policy4.name}" ON ${policy4.on} CASCADE;`;
12089
+ const policy3 = statement.data;
12090
+ return `DROP POLICY "${policy3.name}" ON ${policy3.on} CASCADE;`;
12091
12091
  }
12092
12092
  };
12093
12093
  PgRenameIndPolicyConvertor = class extends Convertor {
@@ -12145,7 +12145,7 @@ var init_sqlgenerator = __esm({
12145
12145
  const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
12146
12146
  const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT "${column4.uniqueName}" UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
12147
12147
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
12148
- const type = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
12148
+ const type = parseType(schemaPrefix, column4.type);
12149
12149
  const generated = column4.generated;
12150
12150
  const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated?.as}) STORED` : "";
12151
12151
  const unsquashedIdentity = column4.identity ? PgSquasher.unsquashIdentity(column4.identity) : void 0;
@@ -12702,7 +12702,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12702
12702
  const { name: name2, values, schema: schema4 } = st;
12703
12703
  const enumNameWithSchema = schema4 ? `"${schema4}"."${name2}"` : `"${name2}"`;
12704
12704
  let valuesStatement = "(";
12705
- valuesStatement += values.map((it) => `'${it}'`).join(", ");
12705
+ valuesStatement += values.map((it) => `'${escapeSingleQuotes(it)}'`).join(", ");
12706
12706
  valuesStatement += ")";
12707
12707
  let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
12708
12708
  return statement;
@@ -12780,7 +12780,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12780
12780
  can(statement, dialect4) {
12781
12781
  return statement.type === "drop_table" && dialect4 === "postgresql";
12782
12782
  }
12783
- convert(statement) {
12783
+ convert(statement, _d5, action) {
12784
12784
  const { tableName, schema: schema4, policies } = statement;
12785
12785
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
12786
12786
  const dropPolicyConvertor = new PgDropPolicyConvertor();
@@ -12788,7 +12788,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12788
12788
  return dropPolicyConvertor.convert({
12789
12789
  type: "drop_policy",
12790
12790
  tableName,
12791
- data: PgSquasher.unsquashPolicy(p),
12791
+ data: action === "push" ? PgSquasher.unsquashPolicyPush(p) : PgSquasher.unsquashPolicy(p),
12792
12792
  schema: schema4
12793
12793
  });
12794
12794
  }) ?? [];
@@ -12912,7 +12912,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
12912
12912
  const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
12913
12913
  const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
12914
12914
  const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
12915
- const fixedType = isPgNativeType(column4.type) ? column4.type : `${schemaPrefix}"${column4.type}"`;
12915
+ const fixedType = parseType(schemaPrefix, column4.type);
12916
12916
  const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
12917
12917
  const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
12918
12918
  const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
@@ -13482,8 +13482,9 @@ WITH ${withCheckOption} CHECK OPTION` : "";
13482
13482
  statement.new
13483
13483
  );
13484
13484
  const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
13485
- return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT ${statement.oldConstraintName};
13486
- ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newConstraintName} PRIMARY KEY(${newColumns.join(",")});`;
13485
+ console.log(statement.oldConstraintName, statement.newConstraintName);
13486
+ return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.oldConstraintName}";
13487
+ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newConstraintName}" PRIMARY KEY("${newColumns.join('","')}");`;
13487
13488
  }
13488
13489
  };
13489
13490
  MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
@@ -15686,30 +15687,29 @@ var init_jsonStatements = __esm({
15686
15687
  };
15687
15688
  });
15688
15689
  };
15689
- prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks, json22) => {
15690
+ prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15690
15691
  return Object.values(pks).map((it) => {
15691
- const unsquashed = PgSquasher.unsquashPK(it);
15692
15692
  return {
15693
15693
  type: "create_composite_pk",
15694
15694
  tableName,
15695
15695
  data: it,
15696
15696
  schema: schema4,
15697
- constraintName: json22.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
15697
+ constraintName: PgSquasher.unsquashPK(it).name
15698
15698
  };
15699
15699
  });
15700
15700
  };
15701
- prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks, json1) => {
15701
+ prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15702
15702
  return Object.values(pks).map((it) => {
15703
15703
  return {
15704
15704
  type: "delete_composite_pk",
15705
15705
  tableName,
15706
15706
  data: it,
15707
15707
  schema: schema4,
15708
- constraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it).name].name
15708
+ constraintName: PgSquasher.unsquashPK(it).name
15709
15709
  };
15710
15710
  });
15711
15711
  };
15712
- prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks, json1, json22) => {
15712
+ prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks) => {
15713
15713
  return Object.values(pks).map((it) => {
15714
15714
  return {
15715
15715
  type: "alter_composite_pk",
@@ -15717,8 +15717,8 @@ var init_jsonStatements = __esm({
15717
15717
  old: it.__old,
15718
15718
  new: it.__new,
15719
15719
  schema: schema4,
15720
- oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
15721
- newConstraintName: json22.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
15720
+ oldConstraintName: PgSquasher.unsquashPK(it.__old).name,
15721
+ newConstraintName: PgSquasher.unsquashPK(it.__new).name
15722
15722
  };
15723
15723
  });
15724
15724
  };
@@ -15773,18 +15773,19 @@ var init_jsonStatements = __esm({
15773
15773
  type: "create_composite_pk",
15774
15774
  tableName,
15775
15775
  data: it,
15776
- constraintName: json22.tables[tableName].compositePrimaryKeys[unsquashed.name].name
15776
+ constraintName: unsquashed.name
15777
15777
  });
15778
15778
  }
15779
15779
  return res;
15780
15780
  };
15781
15781
  prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
15782
15782
  return Object.values(pks).map((it) => {
15783
+ const unsquashed = MySqlSquasher.unsquashPK(it);
15783
15784
  return {
15784
15785
  type: "delete_composite_pk",
15785
15786
  tableName,
15786
15787
  data: it,
15787
- constraintName: json1.tables[tableName].compositePrimaryKeys[MySqlSquasher.unsquashPK(it).name].name
15788
+ constraintName: unsquashed.name
15788
15789
  };
15789
15790
  });
15790
15791
  };
@@ -16775,8 +16776,10 @@ var init_snapshotsDiffer = __esm({
16775
16776
  const { renamed, created: created2, deleted: deleted2 } = await policyResolver2({
16776
16777
  tableName: entry.name,
16777
16778
  schema: entry.schema,
16778
- deleted: entry.policies.deleted.map(PgSquasher.unsquashPolicy),
16779
- created: entry.policies.added.map(PgSquasher.unsquashPolicy)
16779
+ deleted: entry.policies.deleted.map(
16780
+ action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy
16781
+ ),
16782
+ created: entry.policies.added.map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
16780
16783
  });
16781
16784
  if (created2.length > 0) {
16782
16785
  policyCreates.push({
@@ -16813,12 +16816,12 @@ var init_snapshotsDiffer = __esm({
16813
16816
  (tableKey2, tableValue) => {
16814
16817
  const patchedPolicies = mapKeys(
16815
16818
  tableValue.policies,
16816
- (policyKey, policy4) => {
16819
+ (policyKey, policy3) => {
16817
16820
  const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
16818
16821
  const newName = columnChangeFor(policyKey, rens);
16819
- const unsquashedPolicy = PgSquasher.unsquashPolicy(policy4);
16822
+ const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy3) : PgSquasher.unsquashPolicy(policy3);
16820
16823
  unsquashedPolicy.name = newName;
16821
- policy4 = PgSquasher.squashPolicy(unsquashedPolicy);
16824
+ policy3 = PgSquasher.squashPolicy(unsquashedPolicy);
16822
16825
  return newName;
16823
16826
  }
16824
16827
  );
@@ -16830,8 +16833,12 @@ var init_snapshotsDiffer = __esm({
16830
16833
  const indPolicyCreates = [];
16831
16834
  const indPolicyDeletes = [];
16832
16835
  const { renamed: indPolicyRenames, created, deleted } = await indPolicyResolver2({
16833
- deleted: indPolicyRes.deleted.map((t) => PgSquasher.unsquashPolicy(t.values)),
16834
- created: indPolicyRes.added.map((t) => PgSquasher.unsquashPolicy(t.values))
16836
+ deleted: indPolicyRes.deleted.map(
16837
+ (t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
16838
+ ),
16839
+ created: indPolicyRes.added.map(
16840
+ (t) => action === "push" ? PgSquasher.unsquashPolicyPush(t.values) : PgSquasher.unsquashPolicy(t.values)
16841
+ )
16835
16842
  });
16836
16843
  if (created.length > 0) {
16837
16844
  indPolicyCreates.push({
@@ -16954,17 +16961,17 @@ var init_snapshotsDiffer = __esm({
16954
16961
  const jsonDeletedCheckConstraints = [];
16955
16962
  const jsonCreatedCheckConstraints = [];
16956
16963
  for (let it of alteredTables) {
16957
- let addedColumns = [];
16964
+ let addedColumns;
16958
16965
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
16959
16966
  const addedPkColumns = it.addedCompositePKs[addedPkName];
16960
- addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
16967
+ addedColumns = PgSquasher.unsquashPK(addedPkColumns);
16961
16968
  }
16962
- let deletedColumns = [];
16969
+ let deletedColumns;
16963
16970
  for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
16964
16971
  const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
16965
- deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
16972
+ deletedColumns = PgSquasher.unsquashPK(deletedPkColumns);
16966
16973
  }
16967
- const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
16974
+ const doPerformDeleteAndCreate = JSON.stringify(addedColumns ?? {}) !== JSON.stringify(deletedColumns ?? {});
16968
16975
  let addedCompositePKs = [];
16969
16976
  let deletedCompositePKs = [];
16970
16977
  let alteredCompositePKs = [];
@@ -16972,22 +16979,18 @@ var init_snapshotsDiffer = __esm({
16972
16979
  addedCompositePKs = prepareAddCompositePrimaryKeyPg(
16973
16980
  it.name,
16974
16981
  it.schema,
16975
- it.addedCompositePKs,
16976
- curFull
16982
+ it.addedCompositePKs
16977
16983
  );
16978
16984
  deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
16979
16985
  it.name,
16980
16986
  it.schema,
16981
- it.deletedCompositePKs,
16982
- prevFull
16987
+ it.deletedCompositePKs
16983
16988
  );
16984
16989
  }
16985
16990
  alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
16986
16991
  it.name,
16987
16992
  it.schema,
16988
- it.alteredCompositePKs,
16989
- prevFull,
16990
- curFull
16993
+ it.alteredCompositePKs
16991
16994
  );
16992
16995
  let addedUniqueConstraints = [];
16993
16996
  let deletedUniqueConstraints = [];
@@ -17106,9 +17109,9 @@ var init_snapshotsDiffer = __esm({
17106
17109
  );
17107
17110
  }
17108
17111
  typedResult.alteredPolicies.forEach(({ values }) => {
17109
- const policy4 = PgSquasher.unsquashPolicy(values);
17110
- const newPolicy = PgSquasher.unsquashPolicy(json22.policies[policy4.name].values);
17111
- const oldPolicy = PgSquasher.unsquashPolicy(json1.policies[policy4.name].values);
17112
+ const policy3 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
17113
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json22.policies[policy3.name].values);
17114
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy3.name].values);
17112
17115
  if (newPolicy.as !== oldPolicy.as) {
17113
17116
  jsonDropIndPoliciesStatements.push(
17114
17117
  ...prepareDropIndPolicyJsons(
@@ -17167,8 +17170,8 @@ var init_snapshotsDiffer = __esm({
17167
17170
  }
17168
17171
  alteredTables.forEach((it) => {
17169
17172
  Object.keys(it.alteredPolicies).forEach((policyName) => {
17170
- const newPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
17171
- const oldPolicy = PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
17173
+ const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__new) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__new);
17174
+ const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(it.alteredPolicies[policyName].__old) : PgSquasher.unsquashPolicy(it.alteredPolicies[policyName].__old);
17172
17175
  if (newPolicy.as !== oldPolicy.as) {
17173
17176
  jsonDropPoliciesStatements.push(
17174
17177
  ...prepareDropPolicyJsons(
@@ -17222,7 +17225,8 @@ var init_snapshotsDiffer = __esm({
17222
17225
  if (policiesInPreviousState.length > 0 && policiesInCurrentState.length === 0 && !table4.isRLSEnabled) {
17223
17226
  jsonDisableRLSStatements.push({ type: "disable_rls", tableName: table4.name, schema: table4.schema });
17224
17227
  }
17225
- if (table4.isRLSEnabled !== tableInPreviousState.isRLSEnabled) {
17228
+ const wasRlsEnabled = tableInPreviousState ? tableInPreviousState.isRLSEnabled : false;
17229
+ if (table4.isRLSEnabled !== wasRlsEnabled) {
17226
17230
  if (table4.isRLSEnabled) {
17227
17231
  jsonEnableRLSStatements.push({ type: "enable_rls", tableName: table4.name, schema: table4.schema });
17228
17232
  } else if (!table4.isRLSEnabled && policiesInCurrentState.length === 0) {
@@ -17349,7 +17353,11 @@ var init_snapshotsDiffer = __esm({
17349
17353
  });
17350
17354
  jsonCreatePoliciesStatements.push(...[].concat(
17351
17355
  ...createdTables.map(
17352
- (it) => prepareCreatePolicyJsons(it.name, it.schema, Object.values(it.policies).map(PgSquasher.unsquashPolicy))
17356
+ (it) => prepareCreatePolicyJsons(
17357
+ it.name,
17358
+ it.schema,
17359
+ Object.values(it.policies).map(action === "push" ? PgSquasher.unsquashPolicyPush : PgSquasher.unsquashPolicy)
17360
+ )
17353
17361
  )
17354
17362
  ));
17355
17363
  const createViews = [];
@@ -17564,7 +17572,7 @@ var init_snapshotsDiffer = __esm({
17564
17572
  }
17565
17573
  return true;
17566
17574
  });
17567
- const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql");
17575
+ const sqlStatements = fromJson(filteredEnumsJsonStatements, "postgresql", action);
17568
17576
  const uniqueSqlStatements = [];
17569
17577
  sqlStatements.forEach((ss) => {
17570
17578
  if (!uniqueSqlStatements.includes(ss)) {
@@ -17981,9 +17989,9 @@ var init_snapshotsDiffer = __esm({
17981
17989
  jsonStatements.push(...jsonDeletedCompositePKs);
17982
17990
  jsonStatements.push(...jsonTableAlternations);
17983
17991
  jsonStatements.push(...jsonAddedCompositePKs);
17992
+ jsonStatements.push(...jsonAddColumnsStatemets);
17984
17993
  jsonStatements.push(...jsonAddedUniqueConstraints);
17985
17994
  jsonStatements.push(...jsonDeletedUniqueConstraints);
17986
- jsonStatements.push(...jsonAddColumnsStatemets);
17987
17995
  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
17988
17996
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
17989
17997
  jsonStatements.push(...jsonCreatedCheckConstraints);
@@ -23737,7 +23745,7 @@ function vector(a, b) {
23737
23745
  return new PgVectorBuilder(name2, config);
23738
23746
  }
23739
23747
  var _a113, _b92, PgVectorBuilder, _a114, _b93, PgVector;
23740
- var init_vector2 = __esm({
23748
+ var init_vector = __esm({
23741
23749
  "../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
23742
23750
  "use strict";
23743
23751
  init_entity();
@@ -23844,7 +23852,7 @@ var init_all = __esm({
23844
23852
  init_bit();
23845
23853
  init_halfvec();
23846
23854
  init_sparsevec();
23847
- init_vector2();
23855
+ init_vector();
23848
23856
  }
23849
23857
  });
23850
23858
 
@@ -24316,7 +24324,7 @@ function jaccardDistance(column4, value) {
24316
24324
  }
24317
24325
  return sql`${column4} <%> ${value}`;
24318
24326
  }
24319
- var init_vector3 = __esm({
24327
+ var init_vector2 = __esm({
24320
24328
  "../drizzle-orm/dist/sql/functions/vector.js"() {
24321
24329
  "use strict";
24322
24330
  init_sql();
@@ -24328,7 +24336,7 @@ var init_functions = __esm({
24328
24336
  "../drizzle-orm/dist/sql/functions/index.js"() {
24329
24337
  "use strict";
24330
24338
  init_aggregate();
24331
- init_vector3();
24339
+ init_vector2();
24332
24340
  }
24333
24341
  });
24334
24342
 
@@ -24558,7 +24566,7 @@ var init_columns = __esm({
24558
24566
  init_bit();
24559
24567
  init_halfvec();
24560
24568
  init_sparsevec();
24561
- init_vector2();
24569
+ init_vector();
24562
24570
  }
24563
24571
  });
24564
24572
 
@@ -28304,6 +28312,24 @@ var init_pg_core = __esm({
28304
28312
  }
28305
28313
  });
28306
28314
 
28315
+ // src/extensions/vector.ts
28316
+ var vectorOps;
28317
+ var init_vector3 = __esm({
28318
+ "src/extensions/vector.ts"() {
28319
+ "use strict";
28320
+ vectorOps = [
28321
+ "vector_l2_ops",
28322
+ "vector_ip_ops",
28323
+ "vector_cosine_ops",
28324
+ "vector_l1_ops",
28325
+ "bit_hamming_ops",
28326
+ "bit_jaccard_ops",
28327
+ "halfvec_l2_ops",
28328
+ "sparsevec_l2_ops"
28329
+ ];
28330
+ }
28331
+ });
28332
+
28307
28333
  // src/serializer/utils.ts
28308
28334
  function getColumnCasing(column4, casing2) {
28309
28335
  if (!column4.name) return "";
@@ -28409,7 +28435,7 @@ var init_pgSerializer = __esm({
28409
28435
  init_source();
28410
28436
  init_dist();
28411
28437
  init_pg_core();
28412
- init_vector();
28438
+ init_vector3();
28413
28439
  init_outputs();
28414
28440
  init_utils();
28415
28441
  init_utils6();
@@ -28513,7 +28539,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
28513
28539
  columnToSet.default = sqlToStr(column4.default, casing2);
28514
28540
  } else {
28515
28541
  if (typeof column4.default === "string") {
28516
- columnToSet.default = `'${column4.default}'`;
28542
+ columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
28517
28543
  } else {
28518
28544
  if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
28519
28545
  columnToSet.default = `'${JSON.stringify(column4.default)}'::${sqlTypeLowered}`;
@@ -28695,17 +28721,17 @@ ${withStyle.errorWarning(
28695
28721
  with: value.config.with ?? {}
28696
28722
  };
28697
28723
  });
28698
- policies2.forEach((policy4) => {
28724
+ policies2.forEach((policy3) => {
28699
28725
  const mappedTo = [];
28700
- if (!policy4.to) {
28726
+ if (!policy3.to) {
28701
28727
  mappedTo.push("public");
28702
28728
  } else {
28703
- if (policy4.to && typeof policy4.to === "string") {
28704
- mappedTo.push(policy4.to);
28705
- } else if (policy4.to && is(policy4.to, PgRole)) {
28706
- mappedTo.push(policy4.to.name);
28707
- } else if (policy4.to && Array.isArray(policy4.to)) {
28708
- policy4.to.forEach((it) => {
28729
+ if (policy3.to && typeof policy3.to === "string") {
28730
+ mappedTo.push(policy3.to);
28731
+ } else if (policy3.to && is(policy3.to, PgRole)) {
28732
+ mappedTo.push(policy3.to.name);
28733
+ } else if (policy3.to && Array.isArray(policy3.to)) {
28734
+ policy3.to.forEach((it) => {
28709
28735
  if (typeof it === "string") {
28710
28736
  mappedTo.push(it);
28711
28737
  } else if (is(it, PgRole)) {
@@ -28714,24 +28740,24 @@ ${withStyle.errorWarning(
28714
28740
  });
28715
28741
  }
28716
28742
  }
28717
- if (policiesObject[policy4.name] !== void 0) {
28743
+ if (policiesObject[policy3.name] !== void 0) {
28718
28744
  console.log(
28719
28745
  `
28720
28746
  ${withStyle.errorWarning(
28721
28747
  `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
28722
- policy4.name
28748
+ policy3.name
28723
28749
  )} name`
28724
28750
  )}`
28725
28751
  );
28726
28752
  process.exit(1);
28727
28753
  }
28728
- policiesObject[policy4.name] = {
28729
- name: policy4.name,
28730
- as: policy4.as?.toUpperCase() ?? "PERMISSIVE",
28731
- for: policy4.for?.toUpperCase() ?? "ALL",
28754
+ policiesObject[policy3.name] = {
28755
+ name: policy3.name,
28756
+ as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
28757
+ for: policy3.for?.toUpperCase() ?? "ALL",
28732
28758
  to: mappedTo.sort(),
28733
- using: is(policy4.using, SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
28734
- withCheck: is(policy4.withCheck, SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
28759
+ using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
28760
+ withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
28735
28761
  };
28736
28762
  });
28737
28763
  checks.forEach((check) => {
@@ -28775,28 +28801,28 @@ ${withStyle.errorWarning(
28775
28801
  isRLSEnabled: enableRLS
28776
28802
  };
28777
28803
  }
28778
- for (const policy4 of policies) {
28779
- if (!policy4._linkedTable) {
28804
+ for (const policy3 of policies) {
28805
+ if (!policy3._linkedTable) {
28780
28806
  console.log(
28781
28807
  `
28782
28808
  ${withStyle.errorWarning(
28783
- `"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:`
28809
+ `"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:`
28784
28810
  )}`
28785
28811
  );
28786
28812
  continue;
28787
28813
  }
28788
- const tableConfig = getTableConfig(policy4._linkedTable);
28814
+ const tableConfig = getTableConfig(policy3._linkedTable);
28789
28815
  const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
28790
28816
  const mappedTo = [];
28791
- if (!policy4.to) {
28817
+ if (!policy3.to) {
28792
28818
  mappedTo.push("public");
28793
28819
  } else {
28794
- if (policy4.to && typeof policy4.to === "string") {
28795
- mappedTo.push(policy4.to);
28796
- } else if (policy4.to && is(policy4.to, PgRole)) {
28797
- mappedTo.push(policy4.to.name);
28798
- } else if (policy4.to && Array.isArray(policy4.to)) {
28799
- policy4.to.forEach((it) => {
28820
+ if (policy3.to && typeof policy3.to === "string") {
28821
+ mappedTo.push(policy3.to);
28822
+ } else if (policy3.to && is(policy3.to, PgRole)) {
28823
+ mappedTo.push(policy3.to.name);
28824
+ } else if (policy3.to && Array.isArray(policy3.to)) {
28825
+ policy3.to.forEach((it) => {
28800
28826
  if (typeof it === "string") {
28801
28827
  mappedTo.push(it);
28802
28828
  } else if (is(it, PgRole)) {
@@ -28805,30 +28831,31 @@ ${withStyle.errorWarning(
28805
28831
  });
28806
28832
  }
28807
28833
  }
28808
- if (result[tableKey2]?.policies[policy4.name] !== void 0 || policiesToReturn[policy4.name] !== void 0) {
28834
+ if (result[tableKey2]?.policies[policy3.name] !== void 0 || policiesToReturn[policy3.name] !== void 0) {
28809
28835
  console.log(
28810
28836
  `
28811
28837
  ${withStyle.errorWarning(
28812
28838
  `We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
28813
- policy4.name
28839
+ policy3.name
28814
28840
  )} name`
28815
28841
  )}`
28816
28842
  );
28817
28843
  process.exit(1);
28818
28844
  }
28819
28845
  const mappedPolicy = {
28820
- name: policy4.name,
28821
- as: policy4.as?.toUpperCase() ?? "PERMISSIVE",
28822
- for: policy4.for?.toUpperCase() ?? "ALL",
28846
+ name: policy3.name,
28847
+ as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
28848
+ for: policy3.for?.toUpperCase() ?? "ALL",
28823
28849
  to: mappedTo.sort(),
28824
- using: is(policy4.using, SQL) ? dialect4.sqlToQuery(policy4.using).sql : void 0,
28825
- withCheck: is(policy4.withCheck, SQL) ? dialect4.sqlToQuery(policy4.withCheck).sql : void 0
28850
+ using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
28851
+ withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
28826
28852
  };
28827
28853
  if (result[tableKey2]) {
28828
- result[tableKey2].policies[policy4.name] = mappedPolicy;
28854
+ result[tableKey2].policies[policy3.name] = mappedPolicy;
28829
28855
  } else {
28830
- policiesToReturn[policy4.name] = {
28856
+ policiesToReturn[policy3.name] = {
28831
28857
  ...mappedPolicy,
28858
+ schema: tableConfig.schema ?? "public",
28832
28859
  on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
28833
28860
  };
28834
28861
  }
@@ -29037,9 +29064,10 @@ ${withStyle.errorWarning(
29037
29064
  while (end > start && str[end - 1] === char3) --end;
29038
29065
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
29039
29066
  };
29040
- fromDatabase = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback) => {
29067
+ fromDatabase = async (db, tablesFilter = () => true, schemaFilters, entities, progressCallback, tsSchema) => {
29041
29068
  const result = {};
29042
29069
  const views = {};
29070
+ const policies = {};
29043
29071
  const internals = { tables: {} };
29044
29072
  const where = schemaFilters.map((t) => `n.nspname = '${t}'`).join(" or ");
29045
29073
  const allTables = await db.query(
@@ -29165,7 +29193,8 @@ WHERE
29165
29193
  }
29166
29194
  }
29167
29195
  }
29168
- const wherePolicies = schemaFilters.map((t) => `schemaname = '${t}'`).join(" or ");
29196
+ const schemasForLinkedPoliciesInSchema = Object.values(tsSchema?.policies ?? {}).map((it) => it.schema);
29197
+ const wherePolicies = [...schemaFilters, ...schemasForLinkedPoliciesInSchema].map((t) => `schemaname = '${t}'`).join(" or ");
29169
29198
  const policiesByTable = {};
29170
29199
  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}`};`);
29171
29200
  for (const dbPolicy of allPolicies) {
@@ -29181,6 +29210,15 @@ WHERE
29181
29210
  [dbPolicy.name]: { ...rest, to: parsedTo, withCheck: parsedWithCheck, using: parsedUsing }
29182
29211
  };
29183
29212
  }
29213
+ if (tsSchema?.policies[dbPolicy.name]) {
29214
+ policies[dbPolicy.name] = {
29215
+ ...rest,
29216
+ to: parsedTo,
29217
+ withCheck: parsedWithCheck,
29218
+ using: parsedUsing,
29219
+ on: tsSchema?.policies[dbPolicy.name].on
29220
+ };
29221
+ }
29184
29222
  }
29185
29223
  if (progressCallback) {
29186
29224
  progressCallback(
@@ -29773,7 +29811,7 @@ WHERE
29773
29811
  schemas: schemasObject,
29774
29812
  sequences: sequencesToReturn,
29775
29813
  roles: rolesToReturn,
29776
- policies: {},
29814
+ policies,
29777
29815
  views,
29778
29816
  _meta: {
29779
29817
  schemas: {},
@@ -29786,10 +29824,7 @@ WHERE
29786
29824
  defaultForColumn = (column4, internals, tableName) => {
29787
29825
  const columnName = column4.column_name;
29788
29826
  const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
29789
- if (column4.column_default === null) {
29790
- return void 0;
29791
- }
29792
- if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
29827
+ if (column4.column_default === null || column4.column_default === void 0 || column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
29793
29828
  return void 0;
29794
29829
  }
29795
29830
  if (column4.column_default.endsWith("[]")) {
@@ -30217,7 +30252,7 @@ var init_blob = __esm({
30217
30252
  return "blob";
30218
30253
  }
30219
30254
  mapFromDriverValue(value) {
30220
- return BigInt(value.toString());
30255
+ return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
30221
30256
  }
30222
30257
  mapToDriverValue(value) {
30223
30258
  return Buffer.from(value.toString());
@@ -30242,7 +30277,7 @@ var init_blob = __esm({
30242
30277
  return "blob";
30243
30278
  }
30244
30279
  mapFromDriverValue(value) {
30245
- return JSON.parse(value.toString());
30280
+ return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
30246
30281
  }
30247
30282
  mapToDriverValue(value) {
30248
30283
  return Buffer.from(JSON.stringify(value));
@@ -33468,6 +33503,7 @@ var init_sqliteSerializer = __esm({
33468
33503
  init_dist();
33469
33504
  init_sqlite_core();
33470
33505
  init_outputs();
33506
+ init_utils();
33471
33507
  init_utils6();
33472
33508
  generateSqliteSnapshot = (tables, views, casing2) => {
33473
33509
  const dialect4 = new SQLiteSyncDialect({ casing: casing2 });
@@ -33511,7 +33547,7 @@ var init_sqliteSerializer = __esm({
33511
33547
  if (is(column4.default, SQL)) {
33512
33548
  columnToSet.default = sqlToStr(column4.default, casing2);
33513
33549
  } else {
33514
- columnToSet.default = typeof column4.default === "string" ? `'${column4.default}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
33550
+ columnToSet.default = typeof column4.default === "string" ? `'${escapeSingleQuotes(column4.default)}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
33515
33551
  }
33516
33552
  }
33517
33553
  columnsObject[name2] = columnToSet;
@@ -34062,6 +34098,25 @@ WHERE
34062
34098
  }
34063
34099
  });
34064
34100
 
34101
+ // src/extensions/getTablesFilterByExtensions.ts
34102
+ var getTablesFilterByExtensions;
34103
+ var init_getTablesFilterByExtensions = __esm({
34104
+ "src/extensions/getTablesFilterByExtensions.ts"() {
34105
+ "use strict";
34106
+ getTablesFilterByExtensions = ({
34107
+ extensionsFilters,
34108
+ dialect: dialect4
34109
+ }) => {
34110
+ if (extensionsFilters) {
34111
+ if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
34112
+ return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
34113
+ }
34114
+ }
34115
+ return [];
34116
+ };
34117
+ }
34118
+ });
34119
+
34065
34120
  // ../drizzle-orm/dist/mysql-core/alias.js
34066
34121
  var init_alias4 = __esm({
34067
34122
  "../drizzle-orm/dist/mysql-core/alias.js"() {
@@ -34684,7 +34739,7 @@ var init_datetime = __esm({
34684
34739
  // ../drizzle-orm/dist/mysql-core/columns/decimal.js
34685
34740
  function decimal(a, b = {}) {
34686
34741
  const { name: name2, config } = getColumnNameAndConfig(a, b);
34687
- return new MySqlDecimalBuilder(name2, config.precision, config.scale);
34742
+ return new MySqlDecimalBuilder(name2, config);
34688
34743
  }
34689
34744
  var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
34690
34745
  var init_decimal = __esm({
@@ -34694,10 +34749,11 @@ var init_decimal = __esm({
34694
34749
  init_utils2();
34695
34750
  init_common4();
34696
34751
  MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
34697
- constructor(name2, precision, scale) {
34752
+ constructor(name2, config) {
34698
34753
  super(name2, "string", "MySqlDecimal");
34699
- this.config.precision = precision;
34700
- this.config.scale = scale;
34754
+ this.config.precision = config?.precision;
34755
+ this.config.scale = config?.scale;
34756
+ this.config.unsigned = config?.unsigned;
34701
34757
  }
34702
34758
  /** @internal */
34703
34759
  build(table4) {
@@ -34713,15 +34769,19 @@ var init_decimal = __esm({
34713
34769
  super(...arguments);
34714
34770
  __publicField(this, "precision", this.config.precision);
34715
34771
  __publicField(this, "scale", this.config.scale);
34772
+ __publicField(this, "unsigned", this.config.unsigned);
34716
34773
  }
34717
34774
  getSQLType() {
34775
+ let type = "";
34718
34776
  if (this.precision !== void 0 && this.scale !== void 0) {
34719
- return `decimal(${this.precision},${this.scale})`;
34777
+ type += `decimal(${this.precision},${this.scale})`;
34720
34778
  } else if (this.precision === void 0) {
34721
- return "decimal";
34779
+ type += "decimal";
34722
34780
  } else {
34723
- return `decimal(${this.precision})`;
34781
+ type += `decimal(${this.precision})`;
34724
34782
  }
34783
+ type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
34784
+ return this.unsigned ? `${type} unsigned` : type;
34725
34785
  }
34726
34786
  };
34727
34787
  __publicField(MySqlDecimal, _a260, "MySqlDecimal");
@@ -34745,6 +34805,7 @@ var init_double = __esm({
34745
34805
  super(name2, "number", "MySqlDouble");
34746
34806
  this.config.precision = config?.precision;
34747
34807
  this.config.scale = config?.scale;
34808
+ this.config.unsigned = config?.unsigned;
34748
34809
  }
34749
34810
  /** @internal */
34750
34811
  build(table4) {
@@ -34757,15 +34818,18 @@ var init_double = __esm({
34757
34818
  super(...arguments);
34758
34819
  __publicField(this, "precision", this.config.precision);
34759
34820
  __publicField(this, "scale", this.config.scale);
34821
+ __publicField(this, "unsigned", this.config.unsigned);
34760
34822
  }
34761
34823
  getSQLType() {
34824
+ let type = "";
34762
34825
  if (this.precision !== void 0 && this.scale !== void 0) {
34763
- return `double(${this.precision},${this.scale})`;
34826
+ type += `double(${this.precision},${this.scale})`;
34764
34827
  } else if (this.precision === void 0) {
34765
- return "double";
34828
+ type += "double";
34766
34829
  } else {
34767
- return `double(${this.precision})`;
34830
+ type += `double(${this.precision})`;
34768
34831
  }
34832
+ return this.unsigned ? `${type} unsigned` : type;
34769
34833
  }
34770
34834
  };
34771
34835
  __publicField(MySqlDouble, _a262, "MySqlDouble");
@@ -34815,18 +34879,23 @@ var init_enum2 = __esm({
34815
34879
  });
34816
34880
 
34817
34881
  // ../drizzle-orm/dist/mysql-core/columns/float.js
34818
- function float(name2) {
34819
- return new MySqlFloatBuilder(name2 ?? "");
34882
+ function float(a, b) {
34883
+ const { name: name2, config } = getColumnNameAndConfig(a, b);
34884
+ return new MySqlFloatBuilder(name2, config);
34820
34885
  }
34821
34886
  var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
34822
34887
  var init_float = __esm({
34823
34888
  "../drizzle-orm/dist/mysql-core/columns/float.js"() {
34824
34889
  "use strict";
34825
34890
  init_entity();
34891
+ init_utils2();
34826
34892
  init_common4();
34827
34893
  MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
34828
- constructor(name2) {
34894
+ constructor(name2, config) {
34829
34895
  super(name2, "number", "MySqlFloat");
34896
+ this.config.precision = config?.precision;
34897
+ this.config.scale = config?.scale;
34898
+ this.config.unsigned = config?.unsigned;
34830
34899
  }
34831
34900
  /** @internal */
34832
34901
  build(table4) {
@@ -34835,8 +34904,22 @@ var init_float = __esm({
34835
34904
  };
34836
34905
  __publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
34837
34906
  MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
34907
+ constructor() {
34908
+ super(...arguments);
34909
+ __publicField(this, "precision", this.config.precision);
34910
+ __publicField(this, "scale", this.config.scale);
34911
+ __publicField(this, "unsigned", this.config.unsigned);
34912
+ }
34838
34913
  getSQLType() {
34839
- return "float";
34914
+ let type = "";
34915
+ if (this.precision !== void 0 && this.scale !== void 0) {
34916
+ type += `float(${this.precision},${this.scale})`;
34917
+ } else if (this.precision === void 0) {
34918
+ type += "float";
34919
+ } else {
34920
+ type += `float(${this.precision})`;
34921
+ }
34922
+ return this.unsigned ? `${type} unsigned` : type;
34840
34923
  }
34841
34924
  };
34842
34925
  __publicField(MySqlFloat, _a266, "MySqlFloat");
@@ -38364,15 +38447,15 @@ function clearDefaults(defaultValue, collate) {
38364
38447
  if (defaultValue.startsWith(collate)) {
38365
38448
  resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
38366
38449
  if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
38367
- return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
38450
+ return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
38368
38451
  } else {
38369
- return `'${resultDefault}'`;
38452
+ return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
38370
38453
  }
38371
38454
  } else {
38372
38455
  return `(${resultDefault})`;
38373
38456
  }
38374
38457
  }
38375
- var generateMySqlSnapshot, fromDatabase3;
38458
+ var handleEnumType, generateMySqlSnapshot, fromDatabase3;
38376
38459
  var init_mysqlSerializer = __esm({
38377
38460
  "src/serializer/mysqlSerializer.ts"() {
38378
38461
  "use strict";
@@ -38380,7 +38463,14 @@ var init_mysqlSerializer = __esm({
38380
38463
  init_dist();
38381
38464
  init_mysql_core();
38382
38465
  init_outputs();
38466
+ init_utils();
38383
38467
  init_utils6();
38468
+ handleEnumType = (type) => {
38469
+ let str = type.split("(")[1];
38470
+ str = str.substring(0, str.length - 1);
38471
+ const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
38472
+ return `enum(${values.join(",")})`;
38473
+ };
38384
38474
  generateMySqlSnapshot = (tables, views, casing2) => {
38385
38475
  const dialect4 = new MySqlDialect({ casing: casing2 });
38386
38476
  const result = {};
@@ -38407,12 +38497,13 @@ var init_mysqlSerializer = __esm({
38407
38497
  columns.forEach((column4) => {
38408
38498
  const name2 = getColumnCasing(column4, casing2);
38409
38499
  const notNull = column4.notNull;
38410
- const sqlTypeLowered = column4.getSQLType().toLowerCase();
38500
+ const sqlType = column4.getSQLType();
38501
+ const sqlTypeLowered = sqlType.toLowerCase();
38411
38502
  const autoIncrement = typeof column4.autoIncrement === "undefined" ? false : column4.autoIncrement;
38412
38503
  const generated = column4.generated;
38413
38504
  const columnToSet = {
38414
38505
  name: name2,
38415
- type: column4.getSQLType(),
38506
+ type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
38416
38507
  primaryKey: false,
38417
38508
  // If field is autoincrement it's notNull by default
38418
38509
  // notNull: autoIncrement ? true : notNull,
@@ -38459,7 +38550,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
38459
38550
  columnToSet.default = sqlToStr(column4.default, casing2);
38460
38551
  } else {
38461
38552
  if (typeof column4.default === "string") {
38462
- columnToSet.default = `'${column4.default}'`;
38553
+ columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
38463
38554
  } else {
38464
38555
  if (sqlTypeLowered === "json") {
38465
38556
  columnToSet.default = `'${JSON.stringify(column4.default)}'`;
@@ -38828,15 +38919,15 @@ ${withStyle.errorWarning(
38828
38919
  changedType = columnType.replace("bigint unsigned", "serial");
38829
38920
  }
38830
38921
  }
38831
- if (columnType.startsWith("tinyint")) {
38832
- changedType = "tinyint";
38922
+ if (columnType.includes("decimal(10,0)")) {
38923
+ changedType = columnType.replace("decimal(10,0)", "decimal");
38833
38924
  }
38834
38925
  let onUpdate = void 0;
38835
38926
  if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
38836
38927
  onUpdate = true;
38837
38928
  }
38838
38929
  const newColumn = {
38839
- 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}'`,
38930
+ 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)}'`,
38840
38931
  autoincrement: isAutoincrement,
38841
38932
  name: columnName,
38842
38933
  type: changedType,
@@ -39351,6 +39442,7 @@ var init_utils9 = __esm({
39351
39442
  "use strict";
39352
39443
  import_hanji7 = __toESM(require_hanji());
39353
39444
  init_lib();
39445
+ init_getTablesFilterByExtensions();
39354
39446
  init_global();
39355
39447
  init_schemaValidator();
39356
39448
  init_serializer();
@@ -39859,7 +39951,7 @@ init_mjs();
39859
39951
  init_global();
39860
39952
  init_pgSerializer();
39861
39953
  init_views();
39862
- var pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
39954
+ var pgPushIntrospect = async (db, filters, schemaFilters, entities, tsSchema) => {
39863
39955
  const matchers = filters.map((it) => {
39864
39956
  return new Minimatch(it);
39865
39957
  });
@@ -39887,7 +39979,7 @@ var pgPushIntrospect = async (db, filters, schemaFilters, entities) => {
39887
39979
  );
39888
39980
  const res = await (0, import_hanji3.renderWithTask)(
39889
39981
  progress,
39890
- fromDatabase(db, filter2, schemaFilters, entities)
39982
+ fromDatabase(db, filter2, schemaFilters, entities, void 0, tsSchema)
39891
39983
  );
39892
39984
  const schema4 = { id: originUUID, prevId: "", ...res };
39893
39985
  const { internal, ...schemaWithoutInternals } = schema4;
@@ -40055,7 +40147,7 @@ var pgSuggestions = async (db, statements) => {
40055
40147
  }
40056
40148
  }
40057
40149
  }
40058
- const stmnt = fromJson([statement], "postgresql");
40150
+ const stmnt = fromJson([statement], "postgresql", "push");
40059
40151
  if (typeof stmnt !== "undefined") {
40060
40152
  statementsToExecute.push(...stmnt);
40061
40153
  }
@@ -40293,6 +40385,7 @@ var sqlitePushIntrospect = async (db, filters) => {
40293
40385
 
40294
40386
  // src/api.ts
40295
40387
  init_sqlitePushUtils();
40388
+ init_getTablesFilterByExtensions();
40296
40389
  init_global();
40297
40390
  init_migrationPreparator();
40298
40391
  init_mysqlSchema();
@@ -40346,9 +40439,12 @@ var generateMigration = async (prev, cur) => {
40346
40439
  );
40347
40440
  return sqlStatements;
40348
40441
  };
40349
- var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
40442
+ var pushSchema = async (imports, drizzleInstance, schemaFilters, tablesFilter, extensionsFilters) => {
40350
40443
  const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
40351
40444
  const { sql: sql2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
40445
+ const filters = (tablesFilter ?? []).concat(
40446
+ getTablesFilterByExtensions({ extensionsFilters, dialect: "postgresql" })
40447
+ );
40352
40448
  const db = {
40353
40449
  query: async (query, params) => {
40354
40450
  const res = await drizzleInstance.execute(sql2.raw(query));
@@ -40358,7 +40454,7 @@ var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
40358
40454
  const cur = generateDrizzleJson(imports);
40359
40455
  const { schema: prev } = await pgPushIntrospect(
40360
40456
  db,
40361
- [],
40457
+ filters,
40362
40458
  schemaFilters ?? ["public"],
40363
40459
  void 0
40364
40460
  );