drizzle-kit 0.27.2 → 0.28.0-2cb427f
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/README.md +7 -7
- package/api.d.mts +3 -2
- package/api.d.ts +3 -2
- package/api.js +269 -203
- package/api.mjs +269 -203
- package/bin.cjs +47621 -47561
- package/index-BfiZoTqG.d.mts +293 -0
- package/index-BfiZoTqG.d.ts +293 -0
- package/index.d.mts +2 -287
- package/index.d.ts +2 -287
- package/package.json +4 -1
- package/utils.js +11 -0
- package/utils.mjs +9 -0
- package/common-DYjgLS6u.d.mts +0 -8
- package/common-DYjgLS6u.d.ts +0 -8
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({
|
@@ -8008,7 +7989,7 @@ var init_pgSchema = __esm({
|
|
8008
7989
|
squashIdx: (idx) => {
|
8009
7990
|
index2.parse(idx);
|
8010
7991
|
return `${idx.name};${idx.columns.map(
|
8011
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass
|
7992
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass ? c.opclass : ""}`
|
8012
7993
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
8013
7994
|
},
|
8014
7995
|
unsquashIdx: (input) => {
|
@@ -8074,11 +8055,11 @@ var init_pgSchema = __esm({
|
|
8074
8055
|
squashFK: (fk4) => {
|
8075
8056
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
8076
8057
|
},
|
8077
|
-
squashPolicy: (
|
8078
|
-
return `${
|
8058
|
+
squashPolicy: (policy3) => {
|
8059
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.using}--${policy3.withCheck}--${policy3.on}`;
|
8079
8060
|
},
|
8080
|
-
unsquashPolicy: (
|
8081
|
-
const splitted =
|
8061
|
+
unsquashPolicy: (policy3) => {
|
8062
|
+
const splitted = policy3.split("--");
|
8082
8063
|
return {
|
8083
8064
|
name: splitted[0],
|
8084
8065
|
as: splitted[1],
|
@@ -8089,11 +8070,11 @@ var init_pgSchema = __esm({
|
|
8089
8070
|
on: splitted[6] !== "undefined" ? splitted[6] : void 0
|
8090
8071
|
};
|
8091
8072
|
},
|
8092
|
-
squashPolicyPush: (
|
8093
|
-
return `${
|
8073
|
+
squashPolicyPush: (policy3) => {
|
8074
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.on}`;
|
8094
8075
|
},
|
8095
|
-
unsquashPolicyPush: (
|
8096
|
-
const splitted =
|
8076
|
+
unsquashPolicyPush: (policy3) => {
|
8077
|
+
const splitted = policy3.split("--");
|
8097
8078
|
return {
|
8098
8079
|
name: splitted[0],
|
8099
8080
|
as: splitted[1],
|
@@ -8214,8 +8195,8 @@ var init_pgSchema = __esm({
|
|
8214
8195
|
return PgSquasher.squashUnique(unq);
|
8215
8196
|
}
|
8216
8197
|
);
|
8217
|
-
const squashedPolicies = mapValues(it[1].policies, (
|
8218
|
-
return action === "push" ? PgSquasher.squashPolicyPush(
|
8198
|
+
const squashedPolicies = mapValues(it[1].policies, (policy3) => {
|
8199
|
+
return action === "push" ? PgSquasher.squashPolicyPush(policy3) : PgSquasher.squashPolicy(policy3);
|
8219
8200
|
});
|
8220
8201
|
const squashedChecksContraints = mapValues(
|
8221
8202
|
it[1].checkConstraints,
|
@@ -8603,6 +8584,9 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
|
|
8603
8584
|
const removedColumns = columnNames1.filter((it) => !set2.has(it));
|
8604
8585
|
return { addedColumns, removedColumns };
|
8605
8586
|
}
|
8587
|
+
function escapeSingleQuotes(str) {
|
8588
|
+
return str.replace(/'/g, "''");
|
8589
|
+
}
|
8606
8590
|
var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
8607
8591
|
var init_utils = __esm({
|
8608
8592
|
"src/utils.ts"() {
|
@@ -11938,7 +11922,7 @@ function fromJson(statements, dialect4, action, json22) {
|
|
11938
11922
|
}).filter((it) => it !== "");
|
11939
11923
|
return result;
|
11940
11924
|
}
|
11941
|
-
var
|
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;
|
11942
11926
|
var init_sqlgenerator = __esm({
|
11943
11927
|
"src/sqlgenerator.ts"() {
|
11944
11928
|
"use strict";
|
@@ -11946,51 +11930,56 @@ var init_sqlgenerator = __esm({
|
|
11946
11930
|
init_mysqlSchema();
|
11947
11931
|
init_pgSchema();
|
11948
11932
|
init_sqliteSchema();
|
11949
|
-
|
11950
|
-
|
11951
|
-
|
11952
|
-
|
11953
|
-
|
11954
|
-
|
11955
|
-
|
11956
|
-
|
11957
|
-
|
11958
|
-
|
11959
|
-
|
11960
|
-
|
11961
|
-
|
11962
|
-
|
11963
|
-
|
11964
|
-
|
11965
|
-
|
11966
|
-
|
11967
|
-
|
11968
|
-
|
11969
|
-
|
11970
|
-
|
11971
|
-
|
11972
|
-
|
11973
|
-
|
11974
|
-
|
11975
|
-
|
11976
|
-
|
11977
|
-
|
11978
|
-
|
11979
|
-
|
11980
|
-
|
11981
|
-
|
11982
|
-
|
11983
|
-
|
11984
|
-
|
11985
|
-
|
11986
|
-
|
11987
|
-
|
11988
|
-
|
11989
|
-
|
11990
|
-
|
11991
|
-
|
11992
|
-
|
11993
|
-
|
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}`;
|
11994
11983
|
};
|
11995
11984
|
Convertor = class {
|
11996
11985
|
};
|
@@ -12031,14 +12020,14 @@ var init_sqlgenerator = __esm({
|
|
12031
12020
|
return statement.type === "create_policy" && dialect4 === "postgresql";
|
12032
12021
|
}
|
12033
12022
|
convert(statement) {
|
12034
|
-
const
|
12023
|
+
const policy3 = statement.data;
|
12035
12024
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12036
|
-
const usingPart =
|
12037
|
-
const withCheckPart =
|
12038
|
-
const policyToPart =
|
12025
|
+
const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
|
12026
|
+
const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
|
12027
|
+
const policyToPart = policy3.to?.map(
|
12039
12028
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
12040
12029
|
).join(", ");
|
12041
|
-
return `CREATE POLICY "${
|
12030
|
+
return `CREATE POLICY "${policy3.name}" ON ${tableNameWithSchema} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
12042
12031
|
}
|
12043
12032
|
};
|
12044
12033
|
PgDropPolicyConvertor = class extends Convertor {
|
@@ -12046,9 +12035,9 @@ var init_sqlgenerator = __esm({
|
|
12046
12035
|
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
12047
12036
|
}
|
12048
12037
|
convert(statement) {
|
12049
|
-
const
|
12038
|
+
const policy3 = statement.data;
|
12050
12039
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12051
|
-
return `DROP POLICY "${
|
12040
|
+
return `DROP POLICY "${policy3.name}" ON ${tableNameWithSchema} CASCADE;`;
|
12052
12041
|
}
|
12053
12042
|
};
|
12054
12043
|
PgRenamePolicyConvertor = class extends Convertor {
|
@@ -12078,13 +12067,13 @@ var init_sqlgenerator = __esm({
|
|
12078
12067
|
return statement.type === "create_ind_policy" && dialect4 === "postgresql";
|
12079
12068
|
}
|
12080
12069
|
convert(statement) {
|
12081
|
-
const
|
12082
|
-
const usingPart =
|
12083
|
-
const withCheckPart =
|
12084
|
-
const policyToPart =
|
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(
|
12085
12074
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
12086
12075
|
).join(", ");
|
12087
|
-
return `CREATE POLICY "${
|
12076
|
+
return `CREATE POLICY "${policy3.name}" ON ${policy3.on} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
12088
12077
|
}
|
12089
12078
|
};
|
12090
12079
|
PgDropIndPolicyConvertor = class extends Convertor {
|
@@ -12092,8 +12081,8 @@ var init_sqlgenerator = __esm({
|
|
12092
12081
|
return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
|
12093
12082
|
}
|
12094
12083
|
convert(statement) {
|
12095
|
-
const
|
12096
|
-
return `DROP POLICY "${
|
12084
|
+
const policy3 = statement.data;
|
12085
|
+
return `DROP POLICY "${policy3.name}" ON ${policy3.on} CASCADE;`;
|
12097
12086
|
}
|
12098
12087
|
};
|
12099
12088
|
PgRenameIndPolicyConvertor = class extends Convertor {
|
@@ -12151,7 +12140,7 @@ var init_sqlgenerator = __esm({
|
|
12151
12140
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
12152
12141
|
const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT "${column4.uniqueName}" UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
12153
12142
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
12154
|
-
const type =
|
12143
|
+
const type = parseType(schemaPrefix, column4.type);
|
12155
12144
|
const generated = column4.generated;
|
12156
12145
|
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated?.as}) STORED` : "";
|
12157
12146
|
const unsquashedIdentity = column4.identity ? PgSquasher.unsquashIdentity(column4.identity) : void 0;
|
@@ -12708,7 +12697,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12708
12697
|
const { name: name2, values, schema: schema4 } = st;
|
12709
12698
|
const enumNameWithSchema = schema4 ? `"${schema4}"."${name2}"` : `"${name2}"`;
|
12710
12699
|
let valuesStatement = "(";
|
12711
|
-
valuesStatement += values.map((it) => `'${it}'`).join(", ");
|
12700
|
+
valuesStatement += values.map((it) => `'${escapeSingleQuotes(it)}'`).join(", ");
|
12712
12701
|
valuesStatement += ")";
|
12713
12702
|
let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
|
12714
12703
|
return statement;
|
@@ -12918,7 +12907,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12918
12907
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
12919
12908
|
const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
|
12920
12909
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
12921
|
-
const fixedType =
|
12910
|
+
const fixedType = parseType(schemaPrefix, column4.type);
|
12922
12911
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
12923
12912
|
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
12924
12913
|
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
@@ -13488,8 +13477,9 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
13488
13477
|
statement.new
|
13489
13478
|
);
|
13490
13479
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
13491
|
-
|
13492
|
-
|
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('","')}");`;
|
13493
13483
|
}
|
13494
13484
|
};
|
13495
13485
|
MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
@@ -15692,30 +15682,29 @@ var init_jsonStatements = __esm({
|
|
15692
15682
|
};
|
15693
15683
|
});
|
15694
15684
|
};
|
15695
|
-
prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks
|
15685
|
+
prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15696
15686
|
return Object.values(pks).map((it) => {
|
15697
|
-
const unsquashed = PgSquasher.unsquashPK(it);
|
15698
15687
|
return {
|
15699
15688
|
type: "create_composite_pk",
|
15700
15689
|
tableName,
|
15701
15690
|
data: it,
|
15702
15691
|
schema: schema4,
|
15703
|
-
constraintName:
|
15692
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
15704
15693
|
};
|
15705
15694
|
});
|
15706
15695
|
};
|
15707
|
-
prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks
|
15696
|
+
prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15708
15697
|
return Object.values(pks).map((it) => {
|
15709
15698
|
return {
|
15710
15699
|
type: "delete_composite_pk",
|
15711
15700
|
tableName,
|
15712
15701
|
data: it,
|
15713
15702
|
schema: schema4,
|
15714
|
-
constraintName:
|
15703
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
15715
15704
|
};
|
15716
15705
|
});
|
15717
15706
|
};
|
15718
|
-
prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks
|
15707
|
+
prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15719
15708
|
return Object.values(pks).map((it) => {
|
15720
15709
|
return {
|
15721
15710
|
type: "alter_composite_pk",
|
@@ -15723,8 +15712,8 @@ var init_jsonStatements = __esm({
|
|
15723
15712
|
old: it.__old,
|
15724
15713
|
new: it.__new,
|
15725
15714
|
schema: schema4,
|
15726
|
-
oldConstraintName:
|
15727
|
-
newConstraintName:
|
15715
|
+
oldConstraintName: PgSquasher.unsquashPK(it.__old).name,
|
15716
|
+
newConstraintName: PgSquasher.unsquashPK(it.__new).name
|
15728
15717
|
};
|
15729
15718
|
});
|
15730
15719
|
};
|
@@ -15779,18 +15768,19 @@ var init_jsonStatements = __esm({
|
|
15779
15768
|
type: "create_composite_pk",
|
15780
15769
|
tableName,
|
15781
15770
|
data: it,
|
15782
|
-
constraintName:
|
15771
|
+
constraintName: unsquashed.name
|
15783
15772
|
});
|
15784
15773
|
}
|
15785
15774
|
return res;
|
15786
15775
|
};
|
15787
15776
|
prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
|
15788
15777
|
return Object.values(pks).map((it) => {
|
15778
|
+
const unsquashed = MySqlSquasher.unsquashPK(it);
|
15789
15779
|
return {
|
15790
15780
|
type: "delete_composite_pk",
|
15791
15781
|
tableName,
|
15792
15782
|
data: it,
|
15793
|
-
constraintName:
|
15783
|
+
constraintName: unsquashed.name
|
15794
15784
|
};
|
15795
15785
|
});
|
15796
15786
|
};
|
@@ -16821,12 +16811,12 @@ var init_snapshotsDiffer = __esm({
|
|
16821
16811
|
(tableKey2, tableValue) => {
|
16822
16812
|
const patchedPolicies = mapKeys(
|
16823
16813
|
tableValue.policies,
|
16824
|
-
(policyKey,
|
16814
|
+
(policyKey, policy3) => {
|
16825
16815
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
16826
16816
|
const newName = columnChangeFor(policyKey, rens);
|
16827
|
-
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(
|
16817
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy3) : PgSquasher.unsquashPolicy(policy3);
|
16828
16818
|
unsquashedPolicy.name = newName;
|
16829
|
-
|
16819
|
+
policy3 = PgSquasher.squashPolicy(unsquashedPolicy);
|
16830
16820
|
return newName;
|
16831
16821
|
}
|
16832
16822
|
);
|
@@ -16966,17 +16956,17 @@ var init_snapshotsDiffer = __esm({
|
|
16966
16956
|
const jsonDeletedCheckConstraints = [];
|
16967
16957
|
const jsonCreatedCheckConstraints = [];
|
16968
16958
|
for (let it of alteredTables) {
|
16969
|
-
let addedColumns
|
16959
|
+
let addedColumns;
|
16970
16960
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
16971
16961
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
16972
|
-
addedColumns =
|
16962
|
+
addedColumns = PgSquasher.unsquashPK(addedPkColumns);
|
16973
16963
|
}
|
16974
|
-
let deletedColumns
|
16964
|
+
let deletedColumns;
|
16975
16965
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
16976
16966
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
16977
|
-
deletedColumns =
|
16967
|
+
deletedColumns = PgSquasher.unsquashPK(deletedPkColumns);
|
16978
16968
|
}
|
16979
|
-
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
16969
|
+
const doPerformDeleteAndCreate = JSON.stringify(addedColumns ?? {}) !== JSON.stringify(deletedColumns ?? {});
|
16980
16970
|
let addedCompositePKs = [];
|
16981
16971
|
let deletedCompositePKs = [];
|
16982
16972
|
let alteredCompositePKs = [];
|
@@ -16984,22 +16974,18 @@ var init_snapshotsDiffer = __esm({
|
|
16984
16974
|
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
16985
16975
|
it.name,
|
16986
16976
|
it.schema,
|
16987
|
-
it.addedCompositePKs
|
16988
|
-
curFull
|
16977
|
+
it.addedCompositePKs
|
16989
16978
|
);
|
16990
16979
|
deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
|
16991
16980
|
it.name,
|
16992
16981
|
it.schema,
|
16993
|
-
it.deletedCompositePKs
|
16994
|
-
prevFull
|
16982
|
+
it.deletedCompositePKs
|
16995
16983
|
);
|
16996
16984
|
}
|
16997
16985
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
|
16998
16986
|
it.name,
|
16999
16987
|
it.schema,
|
17000
|
-
it.alteredCompositePKs
|
17001
|
-
prevFull,
|
17002
|
-
curFull
|
16988
|
+
it.alteredCompositePKs
|
17003
16989
|
);
|
17004
16990
|
let addedUniqueConstraints = [];
|
17005
16991
|
let deletedUniqueConstraints = [];
|
@@ -17118,9 +17104,9 @@ var init_snapshotsDiffer = __esm({
|
|
17118
17104
|
);
|
17119
17105
|
}
|
17120
17106
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
17121
|
-
const
|
17122
|
-
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[
|
17123
|
-
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[
|
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);
|
17124
17110
|
if (newPolicy.as !== oldPolicy.as) {
|
17125
17111
|
jsonDropIndPoliciesStatements.push(
|
17126
17112
|
...prepareDropIndPolicyJsons(
|
@@ -17998,9 +17984,9 @@ var init_snapshotsDiffer = __esm({
|
|
17998
17984
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17999
17985
|
jsonStatements.push(...jsonTableAlternations);
|
18000
17986
|
jsonStatements.push(...jsonAddedCompositePKs);
|
17987
|
+
jsonStatements.push(...jsonAddColumnsStatemets);
|
18001
17988
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
18002
17989
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
18003
|
-
jsonStatements.push(...jsonAddColumnsStatemets);
|
18004
17990
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
18005
17991
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
18006
17992
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
@@ -21135,7 +21121,7 @@ var version;
|
|
21135
21121
|
var init_version = __esm({
|
21136
21122
|
"../drizzle-orm/dist/version.js"() {
|
21137
21123
|
"use strict";
|
21138
|
-
version = "0.36.
|
21124
|
+
version = "0.36.1";
|
21139
21125
|
}
|
21140
21126
|
});
|
21141
21127
|
|
@@ -21421,7 +21407,11 @@ var init_sql = __esm({
|
|
21421
21407
|
if (_config.invokeSource === "indexes") {
|
21422
21408
|
return { sql: escapeName(columnName), params: [] };
|
21423
21409
|
}
|
21424
|
-
|
21410
|
+
const schemaName = chunk.table[Table2.Symbol.Schema];
|
21411
|
+
return {
|
21412
|
+
sql: chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table2.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table2.Symbol.Name]) + "." + escapeName(columnName),
|
21413
|
+
params: []
|
21414
|
+
};
|
21425
21415
|
}
|
21426
21416
|
if (is(chunk, View3)) {
|
21427
21417
|
const schemaName = chunk[ViewBaseConfig].schema;
|
@@ -23754,7 +23744,7 @@ function vector(a, b) {
|
|
23754
23744
|
return new PgVectorBuilder(name2, config);
|
23755
23745
|
}
|
23756
23746
|
var _a113, _b92, PgVectorBuilder, _a114, _b93, PgVector;
|
23757
|
-
var
|
23747
|
+
var init_vector = __esm({
|
23758
23748
|
"../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
|
23759
23749
|
"use strict";
|
23760
23750
|
init_entity();
|
@@ -23861,7 +23851,7 @@ var init_all = __esm({
|
|
23861
23851
|
init_bit();
|
23862
23852
|
init_halfvec();
|
23863
23853
|
init_sparsevec();
|
23864
|
-
|
23854
|
+
init_vector();
|
23865
23855
|
}
|
23866
23856
|
});
|
23867
23857
|
|
@@ -24333,7 +24323,7 @@ function jaccardDistance(column4, value) {
|
|
24333
24323
|
}
|
24334
24324
|
return sql`${column4} <%> ${value}`;
|
24335
24325
|
}
|
24336
|
-
var
|
24326
|
+
var init_vector2 = __esm({
|
24337
24327
|
"../drizzle-orm/dist/sql/functions/vector.js"() {
|
24338
24328
|
"use strict";
|
24339
24329
|
init_sql();
|
@@ -24345,7 +24335,7 @@ var init_functions = __esm({
|
|
24345
24335
|
"../drizzle-orm/dist/sql/functions/index.js"() {
|
24346
24336
|
"use strict";
|
24347
24337
|
init_aggregate();
|
24348
|
-
|
24338
|
+
init_vector2();
|
24349
24339
|
}
|
24350
24340
|
});
|
24351
24341
|
|
@@ -24575,7 +24565,7 @@ var init_columns = __esm({
|
|
24575
24565
|
init_bit();
|
24576
24566
|
init_halfvec();
|
24577
24567
|
init_sparsevec();
|
24578
|
-
|
24568
|
+
init_vector();
|
24579
24569
|
}
|
24580
24570
|
});
|
24581
24571
|
|
@@ -28321,6 +28311,24 @@ var init_pg_core = __esm({
|
|
28321
28311
|
}
|
28322
28312
|
});
|
28323
28313
|
|
28314
|
+
// src/extensions/vector.ts
|
28315
|
+
var vectorOps;
|
28316
|
+
var init_vector3 = __esm({
|
28317
|
+
"src/extensions/vector.ts"() {
|
28318
|
+
"use strict";
|
28319
|
+
vectorOps = [
|
28320
|
+
"vector_l2_ops",
|
28321
|
+
"vector_ip_ops",
|
28322
|
+
"vector_cosine_ops",
|
28323
|
+
"vector_l1_ops",
|
28324
|
+
"bit_hamming_ops",
|
28325
|
+
"bit_jaccard_ops",
|
28326
|
+
"halfvec_l2_ops",
|
28327
|
+
"sparsevec_l2_ops"
|
28328
|
+
];
|
28329
|
+
}
|
28330
|
+
});
|
28331
|
+
|
28324
28332
|
// src/serializer/utils.ts
|
28325
28333
|
function getColumnCasing(column4, casing2) {
|
28326
28334
|
if (!column4.name) return "";
|
@@ -28426,7 +28434,7 @@ var init_pgSerializer = __esm({
|
|
28426
28434
|
init_source();
|
28427
28435
|
init_dist();
|
28428
28436
|
init_pg_core();
|
28429
|
-
|
28437
|
+
init_vector3();
|
28430
28438
|
init_outputs();
|
28431
28439
|
init_utils();
|
28432
28440
|
init_utils6();
|
@@ -28530,7 +28538,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
28530
28538
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
28531
28539
|
} else {
|
28532
28540
|
if (typeof column4.default === "string") {
|
28533
|
-
columnToSet.default = `'${column4.default}'`;
|
28541
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
28534
28542
|
} else {
|
28535
28543
|
if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
|
28536
28544
|
columnToSet.default = `'${JSON.stringify(column4.default)}'::${sqlTypeLowered}`;
|
@@ -28712,17 +28720,17 @@ ${withStyle.errorWarning(
|
|
28712
28720
|
with: value.config.with ?? {}
|
28713
28721
|
};
|
28714
28722
|
});
|
28715
|
-
policies2.forEach((
|
28723
|
+
policies2.forEach((policy3) => {
|
28716
28724
|
const mappedTo = [];
|
28717
|
-
if (!
|
28725
|
+
if (!policy3.to) {
|
28718
28726
|
mappedTo.push("public");
|
28719
28727
|
} else {
|
28720
|
-
if (
|
28721
|
-
mappedTo.push(
|
28722
|
-
} else if (
|
28723
|
-
mappedTo.push(
|
28724
|
-
} else if (
|
28725
|
-
|
28728
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28729
|
+
mappedTo.push(policy3.to);
|
28730
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28731
|
+
mappedTo.push(policy3.to.name);
|
28732
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28733
|
+
policy3.to.forEach((it) => {
|
28726
28734
|
if (typeof it === "string") {
|
28727
28735
|
mappedTo.push(it);
|
28728
28736
|
} else if (is(it, PgRole)) {
|
@@ -28731,24 +28739,24 @@ ${withStyle.errorWarning(
|
|
28731
28739
|
});
|
28732
28740
|
}
|
28733
28741
|
}
|
28734
|
-
if (policiesObject[
|
28742
|
+
if (policiesObject[policy3.name] !== void 0) {
|
28735
28743
|
console.log(
|
28736
28744
|
`
|
28737
28745
|
${withStyle.errorWarning(
|
28738
28746
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
28739
|
-
|
28747
|
+
policy3.name
|
28740
28748
|
)} name`
|
28741
28749
|
)}`
|
28742
28750
|
);
|
28743
28751
|
process.exit(1);
|
28744
28752
|
}
|
28745
|
-
policiesObject[
|
28746
|
-
name:
|
28747
|
-
as:
|
28748
|
-
for:
|
28753
|
+
policiesObject[policy3.name] = {
|
28754
|
+
name: policy3.name,
|
28755
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28756
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28749
28757
|
to: mappedTo.sort(),
|
28750
|
-
using: is(
|
28751
|
-
withCheck: is(
|
28758
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28759
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28752
28760
|
};
|
28753
28761
|
});
|
28754
28762
|
checks.forEach((check) => {
|
@@ -28792,28 +28800,28 @@ ${withStyle.errorWarning(
|
|
28792
28800
|
isRLSEnabled: enableRLS
|
28793
28801
|
};
|
28794
28802
|
}
|
28795
|
-
for (const
|
28796
|
-
if (!
|
28803
|
+
for (const policy3 of policies) {
|
28804
|
+
if (!policy3._linkedTable) {
|
28797
28805
|
console.log(
|
28798
28806
|
`
|
28799
28807
|
${withStyle.errorWarning(
|
28800
|
-
`"Policy ${
|
28808
|
+
`"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:`
|
28801
28809
|
)}`
|
28802
28810
|
);
|
28803
28811
|
continue;
|
28804
28812
|
}
|
28805
|
-
const tableConfig = getTableConfig(
|
28813
|
+
const tableConfig = getTableConfig(policy3._linkedTable);
|
28806
28814
|
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
28807
28815
|
const mappedTo = [];
|
28808
|
-
if (!
|
28816
|
+
if (!policy3.to) {
|
28809
28817
|
mappedTo.push("public");
|
28810
28818
|
} else {
|
28811
|
-
if (
|
28812
|
-
mappedTo.push(
|
28813
|
-
} else if (
|
28814
|
-
mappedTo.push(
|
28815
|
-
} else if (
|
28816
|
-
|
28819
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28820
|
+
mappedTo.push(policy3.to);
|
28821
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28822
|
+
mappedTo.push(policy3.to.name);
|
28823
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28824
|
+
policy3.to.forEach((it) => {
|
28817
28825
|
if (typeof it === "string") {
|
28818
28826
|
mappedTo.push(it);
|
28819
28827
|
} else if (is(it, PgRole)) {
|
@@ -28822,29 +28830,29 @@ ${withStyle.errorWarning(
|
|
28822
28830
|
});
|
28823
28831
|
}
|
28824
28832
|
}
|
28825
|
-
if (result[tableKey2]?.policies[
|
28833
|
+
if (result[tableKey2]?.policies[policy3.name] !== void 0 || policiesToReturn[policy3.name] !== void 0) {
|
28826
28834
|
console.log(
|
28827
28835
|
`
|
28828
28836
|
${withStyle.errorWarning(
|
28829
28837
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
28830
|
-
|
28838
|
+
policy3.name
|
28831
28839
|
)} name`
|
28832
28840
|
)}`
|
28833
28841
|
);
|
28834
28842
|
process.exit(1);
|
28835
28843
|
}
|
28836
28844
|
const mappedPolicy = {
|
28837
|
-
name:
|
28838
|
-
as:
|
28839
|
-
for:
|
28845
|
+
name: policy3.name,
|
28846
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28847
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28840
28848
|
to: mappedTo.sort(),
|
28841
|
-
using: is(
|
28842
|
-
withCheck: is(
|
28849
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28850
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28843
28851
|
};
|
28844
28852
|
if (result[tableKey2]) {
|
28845
|
-
result[tableKey2].policies[
|
28853
|
+
result[tableKey2].policies[policy3.name] = mappedPolicy;
|
28846
28854
|
} else {
|
28847
|
-
policiesToReturn[
|
28855
|
+
policiesToReturn[policy3.name] = {
|
28848
28856
|
...mappedPolicy,
|
28849
28857
|
schema: tableConfig.schema ?? "public",
|
28850
28858
|
on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
|
@@ -29815,10 +29823,7 @@ WHERE
|
|
29815
29823
|
defaultForColumn = (column4, internals, tableName) => {
|
29816
29824
|
const columnName = column4.column_name;
|
29817
29825
|
const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
|
29818
|
-
if (column4.column_default === null) {
|
29819
|
-
return void 0;
|
29820
|
-
}
|
29821
|
-
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
29826
|
+
if (column4.column_default === null || column4.column_default === void 0 || column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
29822
29827
|
return void 0;
|
29823
29828
|
}
|
29824
29829
|
if (column4.column_default.endsWith("[]")) {
|
@@ -30246,7 +30251,7 @@ var init_blob = __esm({
|
|
30246
30251
|
return "blob";
|
30247
30252
|
}
|
30248
30253
|
mapFromDriverValue(value) {
|
30249
|
-
return BigInt(value.toString());
|
30254
|
+
return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30250
30255
|
}
|
30251
30256
|
mapToDriverValue(value) {
|
30252
30257
|
return Buffer.from(value.toString());
|
@@ -30271,7 +30276,7 @@ var init_blob = __esm({
|
|
30271
30276
|
return "blob";
|
30272
30277
|
}
|
30273
30278
|
mapFromDriverValue(value) {
|
30274
|
-
return JSON.parse(value.toString());
|
30279
|
+
return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30275
30280
|
}
|
30276
30281
|
mapToDriverValue(value) {
|
30277
30282
|
return Buffer.from(JSON.stringify(value));
|
@@ -33497,6 +33502,7 @@ var init_sqliteSerializer = __esm({
|
|
33497
33502
|
init_dist();
|
33498
33503
|
init_sqlite_core();
|
33499
33504
|
init_outputs();
|
33505
|
+
init_utils();
|
33500
33506
|
init_utils6();
|
33501
33507
|
generateSqliteSnapshot = (tables, views, casing2) => {
|
33502
33508
|
const dialect4 = new SQLiteSyncDialect({ casing: casing2 });
|
@@ -33540,7 +33546,7 @@ var init_sqliteSerializer = __esm({
|
|
33540
33546
|
if (is(column4.default, SQL)) {
|
33541
33547
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
33542
33548
|
} else {
|
33543
|
-
columnToSet.default = typeof column4.default === "string" ? `'${column4.default}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33549
|
+
columnToSet.default = typeof column4.default === "string" ? `'${escapeSingleQuotes(column4.default)}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33544
33550
|
}
|
33545
33551
|
}
|
33546
33552
|
columnsObject[name2] = columnToSet;
|
@@ -34091,6 +34097,25 @@ WHERE
|
|
34091
34097
|
}
|
34092
34098
|
});
|
34093
34099
|
|
34100
|
+
// src/extensions/getTablesFilterByExtensions.ts
|
34101
|
+
var getTablesFilterByExtensions;
|
34102
|
+
var init_getTablesFilterByExtensions = __esm({
|
34103
|
+
"src/extensions/getTablesFilterByExtensions.ts"() {
|
34104
|
+
"use strict";
|
34105
|
+
getTablesFilterByExtensions = ({
|
34106
|
+
extensionsFilters,
|
34107
|
+
dialect: dialect4
|
34108
|
+
}) => {
|
34109
|
+
if (extensionsFilters) {
|
34110
|
+
if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
|
34111
|
+
return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
|
34112
|
+
}
|
34113
|
+
}
|
34114
|
+
return [];
|
34115
|
+
};
|
34116
|
+
}
|
34117
|
+
});
|
34118
|
+
|
34094
34119
|
// ../drizzle-orm/dist/mysql-core/alias.js
|
34095
34120
|
var init_alias4 = __esm({
|
34096
34121
|
"../drizzle-orm/dist/mysql-core/alias.js"() {
|
@@ -34713,7 +34738,7 @@ var init_datetime = __esm({
|
|
34713
34738
|
// ../drizzle-orm/dist/mysql-core/columns/decimal.js
|
34714
34739
|
function decimal(a, b = {}) {
|
34715
34740
|
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34716
|
-
return new MySqlDecimalBuilder(name2, config
|
34741
|
+
return new MySqlDecimalBuilder(name2, config);
|
34717
34742
|
}
|
34718
34743
|
var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
|
34719
34744
|
var init_decimal = __esm({
|
@@ -34723,10 +34748,11 @@ var init_decimal = __esm({
|
|
34723
34748
|
init_utils2();
|
34724
34749
|
init_common4();
|
34725
34750
|
MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
|
34726
|
-
constructor(name2,
|
34751
|
+
constructor(name2, config) {
|
34727
34752
|
super(name2, "string", "MySqlDecimal");
|
34728
|
-
this.config.precision = precision;
|
34729
|
-
this.config.scale = scale;
|
34753
|
+
this.config.precision = config?.precision;
|
34754
|
+
this.config.scale = config?.scale;
|
34755
|
+
this.config.unsigned = config?.unsigned;
|
34730
34756
|
}
|
34731
34757
|
/** @internal */
|
34732
34758
|
build(table4) {
|
@@ -34742,15 +34768,19 @@ var init_decimal = __esm({
|
|
34742
34768
|
super(...arguments);
|
34743
34769
|
__publicField(this, "precision", this.config.precision);
|
34744
34770
|
__publicField(this, "scale", this.config.scale);
|
34771
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34745
34772
|
}
|
34746
34773
|
getSQLType() {
|
34774
|
+
let type = "";
|
34747
34775
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34748
|
-
|
34776
|
+
type += `decimal(${this.precision},${this.scale})`;
|
34749
34777
|
} else if (this.precision === void 0) {
|
34750
|
-
|
34778
|
+
type += "decimal";
|
34751
34779
|
} else {
|
34752
|
-
|
34780
|
+
type += `decimal(${this.precision})`;
|
34753
34781
|
}
|
34782
|
+
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
34783
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34754
34784
|
}
|
34755
34785
|
};
|
34756
34786
|
__publicField(MySqlDecimal, _a260, "MySqlDecimal");
|
@@ -34774,6 +34804,7 @@ var init_double = __esm({
|
|
34774
34804
|
super(name2, "number", "MySqlDouble");
|
34775
34805
|
this.config.precision = config?.precision;
|
34776
34806
|
this.config.scale = config?.scale;
|
34807
|
+
this.config.unsigned = config?.unsigned;
|
34777
34808
|
}
|
34778
34809
|
/** @internal */
|
34779
34810
|
build(table4) {
|
@@ -34786,15 +34817,18 @@ var init_double = __esm({
|
|
34786
34817
|
super(...arguments);
|
34787
34818
|
__publicField(this, "precision", this.config.precision);
|
34788
34819
|
__publicField(this, "scale", this.config.scale);
|
34820
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34789
34821
|
}
|
34790
34822
|
getSQLType() {
|
34823
|
+
let type = "";
|
34791
34824
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34792
|
-
|
34825
|
+
type += `double(${this.precision},${this.scale})`;
|
34793
34826
|
} else if (this.precision === void 0) {
|
34794
|
-
|
34827
|
+
type += "double";
|
34795
34828
|
} else {
|
34796
|
-
|
34829
|
+
type += `double(${this.precision})`;
|
34797
34830
|
}
|
34831
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34798
34832
|
}
|
34799
34833
|
};
|
34800
34834
|
__publicField(MySqlDouble, _a262, "MySqlDouble");
|
@@ -34844,18 +34878,23 @@ var init_enum2 = __esm({
|
|
34844
34878
|
});
|
34845
34879
|
|
34846
34880
|
// ../drizzle-orm/dist/mysql-core/columns/float.js
|
34847
|
-
function float(
|
34848
|
-
|
34881
|
+
function float(a, b) {
|
34882
|
+
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34883
|
+
return new MySqlFloatBuilder(name2, config);
|
34849
34884
|
}
|
34850
34885
|
var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
|
34851
34886
|
var init_float = __esm({
|
34852
34887
|
"../drizzle-orm/dist/mysql-core/columns/float.js"() {
|
34853
34888
|
"use strict";
|
34854
34889
|
init_entity();
|
34890
|
+
init_utils2();
|
34855
34891
|
init_common4();
|
34856
34892
|
MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
|
34857
|
-
constructor(name2) {
|
34893
|
+
constructor(name2, config) {
|
34858
34894
|
super(name2, "number", "MySqlFloat");
|
34895
|
+
this.config.precision = config?.precision;
|
34896
|
+
this.config.scale = config?.scale;
|
34897
|
+
this.config.unsigned = config?.unsigned;
|
34859
34898
|
}
|
34860
34899
|
/** @internal */
|
34861
34900
|
build(table4) {
|
@@ -34864,8 +34903,22 @@ var init_float = __esm({
|
|
34864
34903
|
};
|
34865
34904
|
__publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
|
34866
34905
|
MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
|
34906
|
+
constructor() {
|
34907
|
+
super(...arguments);
|
34908
|
+
__publicField(this, "precision", this.config.precision);
|
34909
|
+
__publicField(this, "scale", this.config.scale);
|
34910
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34911
|
+
}
|
34867
34912
|
getSQLType() {
|
34868
|
-
|
34913
|
+
let type = "";
|
34914
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
34915
|
+
type += `float(${this.precision},${this.scale})`;
|
34916
|
+
} else if (this.precision === void 0) {
|
34917
|
+
type += "float";
|
34918
|
+
} else {
|
34919
|
+
type += `float(${this.precision})`;
|
34920
|
+
}
|
34921
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34869
34922
|
}
|
34870
34923
|
};
|
34871
34924
|
__publicField(MySqlFloat, _a266, "MySqlFloat");
|
@@ -35686,7 +35739,7 @@ var init_insert3 = __esm({
|
|
35686
35739
|
/**
|
35687
35740
|
* Adds an `on duplicate key update` clause to the query.
|
35688
35741
|
*
|
35689
|
-
* Calling this method will update
|
35742
|
+
* Calling this method will update the row if any unique index conflicts. MySQL will automatically determine the conflict target based on the primary key and unique indexes.
|
35690
35743
|
*
|
35691
35744
|
* See docs: {@link https://orm.drizzle.team/docs/insert#on-duplicate-key-update}
|
35692
35745
|
*
|
@@ -35721,7 +35774,7 @@ var init_insert3 = __esm({
|
|
35721
35774
|
returning.push({ field: value, path: [key] });
|
35722
35775
|
}
|
35723
35776
|
}
|
35724
|
-
this.config.returning =
|
35777
|
+
this.config.returning = returning;
|
35725
35778
|
return this;
|
35726
35779
|
}
|
35727
35780
|
/** @internal */
|
@@ -38393,15 +38446,15 @@ function clearDefaults(defaultValue, collate) {
|
|
38393
38446
|
if (defaultValue.startsWith(collate)) {
|
38394
38447
|
resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
|
38395
38448
|
if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
|
38396
|
-
return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
|
38449
|
+
return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
|
38397
38450
|
} else {
|
38398
|
-
return `'${resultDefault}'`;
|
38451
|
+
return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
|
38399
38452
|
}
|
38400
38453
|
} else {
|
38401
38454
|
return `(${resultDefault})`;
|
38402
38455
|
}
|
38403
38456
|
}
|
38404
|
-
var generateMySqlSnapshot, fromDatabase3;
|
38457
|
+
var handleEnumType, generateMySqlSnapshot, fromDatabase3;
|
38405
38458
|
var init_mysqlSerializer = __esm({
|
38406
38459
|
"src/serializer/mysqlSerializer.ts"() {
|
38407
38460
|
"use strict";
|
@@ -38409,7 +38462,14 @@ var init_mysqlSerializer = __esm({
|
|
38409
38462
|
init_dist();
|
38410
38463
|
init_mysql_core();
|
38411
38464
|
init_outputs();
|
38465
|
+
init_utils();
|
38412
38466
|
init_utils6();
|
38467
|
+
handleEnumType = (type) => {
|
38468
|
+
let str = type.split("(")[1];
|
38469
|
+
str = str.substring(0, str.length - 1);
|
38470
|
+
const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
|
38471
|
+
return `enum(${values.join(",")})`;
|
38472
|
+
};
|
38413
38473
|
generateMySqlSnapshot = (tables, views, casing2) => {
|
38414
38474
|
const dialect4 = new MySqlDialect({ casing: casing2 });
|
38415
38475
|
const result = {};
|
@@ -38436,12 +38496,13 @@ var init_mysqlSerializer = __esm({
|
|
38436
38496
|
columns.forEach((column4) => {
|
38437
38497
|
const name2 = getColumnCasing(column4, casing2);
|
38438
38498
|
const notNull = column4.notNull;
|
38439
|
-
const
|
38499
|
+
const sqlType = column4.getSQLType();
|
38500
|
+
const sqlTypeLowered = sqlType.toLowerCase();
|
38440
38501
|
const autoIncrement = typeof column4.autoIncrement === "undefined" ? false : column4.autoIncrement;
|
38441
38502
|
const generated = column4.generated;
|
38442
38503
|
const columnToSet = {
|
38443
38504
|
name: name2,
|
38444
|
-
type:
|
38505
|
+
type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
|
38445
38506
|
primaryKey: false,
|
38446
38507
|
// If field is autoincrement it's notNull by default
|
38447
38508
|
// notNull: autoIncrement ? true : notNull,
|
@@ -38488,7 +38549,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
38488
38549
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
38489
38550
|
} else {
|
38490
38551
|
if (typeof column4.default === "string") {
|
38491
|
-
columnToSet.default = `'${column4.default}'`;
|
38552
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
38492
38553
|
} else {
|
38493
38554
|
if (sqlTypeLowered === "json") {
|
38494
38555
|
columnToSet.default = `'${JSON.stringify(column4.default)}'`;
|
@@ -38857,15 +38918,15 @@ ${withStyle.errorWarning(
|
|
38857
38918
|
changedType = columnType.replace("bigint unsigned", "serial");
|
38858
38919
|
}
|
38859
38920
|
}
|
38860
|
-
if (columnType.
|
38861
|
-
changedType = "
|
38921
|
+
if (columnType.includes("decimal(10,0)")) {
|
38922
|
+
changedType = columnType.replace("decimal(10,0)", "decimal");
|
38862
38923
|
}
|
38863
38924
|
let onUpdate = void 0;
|
38864
38925
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
38865
38926
|
onUpdate = true;
|
38866
38927
|
}
|
38867
38928
|
const newColumn = {
|
38868
|
-
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}'`,
|
38929
|
+
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)}'`,
|
38869
38930
|
autoincrement: isAutoincrement,
|
38870
38931
|
name: columnName,
|
38871
38932
|
type: changedType,
|
@@ -39380,6 +39441,7 @@ var init_utils9 = __esm({
|
|
39380
39441
|
"use strict";
|
39381
39442
|
import_hanji7 = __toESM(require_hanji());
|
39382
39443
|
init_lib();
|
39444
|
+
init_getTablesFilterByExtensions();
|
39383
39445
|
init_global();
|
39384
39446
|
init_schemaValidator();
|
39385
39447
|
init_serializer();
|
@@ -40336,6 +40398,7 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
40336
40398
|
|
40337
40399
|
// src/api.ts
|
40338
40400
|
init_sqlitePushUtils();
|
40401
|
+
init_getTablesFilterByExtensions();
|
40339
40402
|
init_global();
|
40340
40403
|
init_migrationPreparator();
|
40341
40404
|
init_mysqlSchema();
|
@@ -40389,9 +40452,12 @@ var generateMigration = async (prev, cur) => {
|
|
40389
40452
|
);
|
40390
40453
|
return sqlStatements;
|
40391
40454
|
};
|
40392
|
-
var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
40455
|
+
var pushSchema = async (imports, drizzleInstance, schemaFilters, tablesFilter, extensionsFilters) => {
|
40393
40456
|
const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
40394
40457
|
const { sql: sql2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
40458
|
+
const filters = (tablesFilter ?? []).concat(
|
40459
|
+
getTablesFilterByExtensions({ extensionsFilters, dialect: "postgresql" })
|
40460
|
+
);
|
40395
40461
|
const db = {
|
40396
40462
|
query: async (query, params) => {
|
40397
40463
|
const res = await drizzleInstance.execute(sql2.raw(query));
|
@@ -40401,7 +40467,7 @@ var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
|
40401
40467
|
const cur = generateDrizzleJson(imports);
|
40402
40468
|
const { schema: prev } = await pgPushIntrospect(
|
40403
40469
|
db,
|
40404
|
-
|
40470
|
+
filters,
|
40405
40471
|
schemaFilters ?? ["public"],
|
40406
40472
|
void 0
|
40407
40473
|
);
|