drizzle-kit 0.27.2 → 0.28.0-842fab3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -7
- package/api.d.mts +3 -2
- package/api.d.ts +3 -2
- package/api.js +267 -202
- package/api.mjs +267 -202
- 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,10 @@ var init_sql = __esm({
|
|
21421
21407
|
if (_config.invokeSource === "indexes") {
|
21422
21408
|
return { sql: escapeName(columnName), params: [] };
|
21423
21409
|
}
|
21424
|
-
return {
|
21410
|
+
return {
|
21411
|
+
sql: chunk.table[IsAlias] || chunk.table[Table2.Symbol.Schema] === void 0 ? escapeName(chunk.table[Table2.Symbol.Name]) + "." + escapeName(columnName) : escapeName(chunk.table[Table2.Symbol.Schema]) + "." + escapeName(chunk.table[Table2.Symbol.Name]) + "." + escapeName(columnName),
|
21412
|
+
params: []
|
21413
|
+
};
|
21425
21414
|
}
|
21426
21415
|
if (is(chunk, View3)) {
|
21427
21416
|
const schemaName = chunk[ViewBaseConfig].schema;
|
@@ -23754,7 +23743,7 @@ function vector(a, b) {
|
|
23754
23743
|
return new PgVectorBuilder(name2, config);
|
23755
23744
|
}
|
23756
23745
|
var _a113, _b92, PgVectorBuilder, _a114, _b93, PgVector;
|
23757
|
-
var
|
23746
|
+
var init_vector = __esm({
|
23758
23747
|
"../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
|
23759
23748
|
"use strict";
|
23760
23749
|
init_entity();
|
@@ -23861,7 +23850,7 @@ var init_all = __esm({
|
|
23861
23850
|
init_bit();
|
23862
23851
|
init_halfvec();
|
23863
23852
|
init_sparsevec();
|
23864
|
-
|
23853
|
+
init_vector();
|
23865
23854
|
}
|
23866
23855
|
});
|
23867
23856
|
|
@@ -24333,7 +24322,7 @@ function jaccardDistance(column4, value) {
|
|
24333
24322
|
}
|
24334
24323
|
return sql`${column4} <%> ${value}`;
|
24335
24324
|
}
|
24336
|
-
var
|
24325
|
+
var init_vector2 = __esm({
|
24337
24326
|
"../drizzle-orm/dist/sql/functions/vector.js"() {
|
24338
24327
|
"use strict";
|
24339
24328
|
init_sql();
|
@@ -24345,7 +24334,7 @@ var init_functions = __esm({
|
|
24345
24334
|
"../drizzle-orm/dist/sql/functions/index.js"() {
|
24346
24335
|
"use strict";
|
24347
24336
|
init_aggregate();
|
24348
|
-
|
24337
|
+
init_vector2();
|
24349
24338
|
}
|
24350
24339
|
});
|
24351
24340
|
|
@@ -24575,7 +24564,7 @@ var init_columns = __esm({
|
|
24575
24564
|
init_bit();
|
24576
24565
|
init_halfvec();
|
24577
24566
|
init_sparsevec();
|
24578
|
-
|
24567
|
+
init_vector();
|
24579
24568
|
}
|
24580
24569
|
});
|
24581
24570
|
|
@@ -28321,6 +28310,24 @@ var init_pg_core = __esm({
|
|
28321
28310
|
}
|
28322
28311
|
});
|
28323
28312
|
|
28313
|
+
// src/extensions/vector.ts
|
28314
|
+
var vectorOps;
|
28315
|
+
var init_vector3 = __esm({
|
28316
|
+
"src/extensions/vector.ts"() {
|
28317
|
+
"use strict";
|
28318
|
+
vectorOps = [
|
28319
|
+
"vector_l2_ops",
|
28320
|
+
"vector_ip_ops",
|
28321
|
+
"vector_cosine_ops",
|
28322
|
+
"vector_l1_ops",
|
28323
|
+
"bit_hamming_ops",
|
28324
|
+
"bit_jaccard_ops",
|
28325
|
+
"halfvec_l2_ops",
|
28326
|
+
"sparsevec_l2_ops"
|
28327
|
+
];
|
28328
|
+
}
|
28329
|
+
});
|
28330
|
+
|
28324
28331
|
// src/serializer/utils.ts
|
28325
28332
|
function getColumnCasing(column4, casing2) {
|
28326
28333
|
if (!column4.name) return "";
|
@@ -28426,7 +28433,7 @@ var init_pgSerializer = __esm({
|
|
28426
28433
|
init_source();
|
28427
28434
|
init_dist();
|
28428
28435
|
init_pg_core();
|
28429
|
-
|
28436
|
+
init_vector3();
|
28430
28437
|
init_outputs();
|
28431
28438
|
init_utils();
|
28432
28439
|
init_utils6();
|
@@ -28530,7 +28537,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
28530
28537
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
28531
28538
|
} else {
|
28532
28539
|
if (typeof column4.default === "string") {
|
28533
|
-
columnToSet.default = `'${column4.default}'`;
|
28540
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
28534
28541
|
} else {
|
28535
28542
|
if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
|
28536
28543
|
columnToSet.default = `'${JSON.stringify(column4.default)}'::${sqlTypeLowered}`;
|
@@ -28712,17 +28719,17 @@ ${withStyle.errorWarning(
|
|
28712
28719
|
with: value.config.with ?? {}
|
28713
28720
|
};
|
28714
28721
|
});
|
28715
|
-
policies2.forEach((
|
28722
|
+
policies2.forEach((policy3) => {
|
28716
28723
|
const mappedTo = [];
|
28717
|
-
if (!
|
28724
|
+
if (!policy3.to) {
|
28718
28725
|
mappedTo.push("public");
|
28719
28726
|
} else {
|
28720
|
-
if (
|
28721
|
-
mappedTo.push(
|
28722
|
-
} else if (
|
28723
|
-
mappedTo.push(
|
28724
|
-
} else if (
|
28725
|
-
|
28727
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28728
|
+
mappedTo.push(policy3.to);
|
28729
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28730
|
+
mappedTo.push(policy3.to.name);
|
28731
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28732
|
+
policy3.to.forEach((it) => {
|
28726
28733
|
if (typeof it === "string") {
|
28727
28734
|
mappedTo.push(it);
|
28728
28735
|
} else if (is(it, PgRole)) {
|
@@ -28731,24 +28738,24 @@ ${withStyle.errorWarning(
|
|
28731
28738
|
});
|
28732
28739
|
}
|
28733
28740
|
}
|
28734
|
-
if (policiesObject[
|
28741
|
+
if (policiesObject[policy3.name] !== void 0) {
|
28735
28742
|
console.log(
|
28736
28743
|
`
|
28737
28744
|
${withStyle.errorWarning(
|
28738
28745
|
`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
|
-
|
28746
|
+
policy3.name
|
28740
28747
|
)} name`
|
28741
28748
|
)}`
|
28742
28749
|
);
|
28743
28750
|
process.exit(1);
|
28744
28751
|
}
|
28745
|
-
policiesObject[
|
28746
|
-
name:
|
28747
|
-
as:
|
28748
|
-
for:
|
28752
|
+
policiesObject[policy3.name] = {
|
28753
|
+
name: policy3.name,
|
28754
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28755
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28749
28756
|
to: mappedTo.sort(),
|
28750
|
-
using: is(
|
28751
|
-
withCheck: is(
|
28757
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28758
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28752
28759
|
};
|
28753
28760
|
});
|
28754
28761
|
checks.forEach((check) => {
|
@@ -28792,28 +28799,28 @@ ${withStyle.errorWarning(
|
|
28792
28799
|
isRLSEnabled: enableRLS
|
28793
28800
|
};
|
28794
28801
|
}
|
28795
|
-
for (const
|
28796
|
-
if (!
|
28802
|
+
for (const policy3 of policies) {
|
28803
|
+
if (!policy3._linkedTable) {
|
28797
28804
|
console.log(
|
28798
28805
|
`
|
28799
28806
|
${withStyle.errorWarning(
|
28800
|
-
`"Policy ${
|
28807
|
+
`"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
28808
|
)}`
|
28802
28809
|
);
|
28803
28810
|
continue;
|
28804
28811
|
}
|
28805
|
-
const tableConfig = getTableConfig(
|
28812
|
+
const tableConfig = getTableConfig(policy3._linkedTable);
|
28806
28813
|
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
28807
28814
|
const mappedTo = [];
|
28808
|
-
if (!
|
28815
|
+
if (!policy3.to) {
|
28809
28816
|
mappedTo.push("public");
|
28810
28817
|
} else {
|
28811
|
-
if (
|
28812
|
-
mappedTo.push(
|
28813
|
-
} else if (
|
28814
|
-
mappedTo.push(
|
28815
|
-
} else if (
|
28816
|
-
|
28818
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28819
|
+
mappedTo.push(policy3.to);
|
28820
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28821
|
+
mappedTo.push(policy3.to.name);
|
28822
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28823
|
+
policy3.to.forEach((it) => {
|
28817
28824
|
if (typeof it === "string") {
|
28818
28825
|
mappedTo.push(it);
|
28819
28826
|
} else if (is(it, PgRole)) {
|
@@ -28822,29 +28829,29 @@ ${withStyle.errorWarning(
|
|
28822
28829
|
});
|
28823
28830
|
}
|
28824
28831
|
}
|
28825
|
-
if (result[tableKey2]?.policies[
|
28832
|
+
if (result[tableKey2]?.policies[policy3.name] !== void 0 || policiesToReturn[policy3.name] !== void 0) {
|
28826
28833
|
console.log(
|
28827
28834
|
`
|
28828
28835
|
${withStyle.errorWarning(
|
28829
28836
|
`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
|
-
|
28837
|
+
policy3.name
|
28831
28838
|
)} name`
|
28832
28839
|
)}`
|
28833
28840
|
);
|
28834
28841
|
process.exit(1);
|
28835
28842
|
}
|
28836
28843
|
const mappedPolicy = {
|
28837
|
-
name:
|
28838
|
-
as:
|
28839
|
-
for:
|
28844
|
+
name: policy3.name,
|
28845
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28846
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28840
28847
|
to: mappedTo.sort(),
|
28841
|
-
using: is(
|
28842
|
-
withCheck: is(
|
28848
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28849
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28843
28850
|
};
|
28844
28851
|
if (result[tableKey2]) {
|
28845
|
-
result[tableKey2].policies[
|
28852
|
+
result[tableKey2].policies[policy3.name] = mappedPolicy;
|
28846
28853
|
} else {
|
28847
|
-
policiesToReturn[
|
28854
|
+
policiesToReturn[policy3.name] = {
|
28848
28855
|
...mappedPolicy,
|
28849
28856
|
schema: tableConfig.schema ?? "public",
|
28850
28857
|
on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
|
@@ -29815,10 +29822,7 @@ WHERE
|
|
29815
29822
|
defaultForColumn = (column4, internals, tableName) => {
|
29816
29823
|
const columnName = column4.column_name;
|
29817
29824
|
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") {
|
29825
|
+
if (column4.column_default === null || column4.column_default === void 0 || column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
29822
29826
|
return void 0;
|
29823
29827
|
}
|
29824
29828
|
if (column4.column_default.endsWith("[]")) {
|
@@ -30246,7 +30250,7 @@ var init_blob = __esm({
|
|
30246
30250
|
return "blob";
|
30247
30251
|
}
|
30248
30252
|
mapFromDriverValue(value) {
|
30249
|
-
return BigInt(value.toString());
|
30253
|
+
return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30250
30254
|
}
|
30251
30255
|
mapToDriverValue(value) {
|
30252
30256
|
return Buffer.from(value.toString());
|
@@ -30271,7 +30275,7 @@ var init_blob = __esm({
|
|
30271
30275
|
return "blob";
|
30272
30276
|
}
|
30273
30277
|
mapFromDriverValue(value) {
|
30274
|
-
return JSON.parse(value.toString());
|
30278
|
+
return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30275
30279
|
}
|
30276
30280
|
mapToDriverValue(value) {
|
30277
30281
|
return Buffer.from(JSON.stringify(value));
|
@@ -33497,6 +33501,7 @@ var init_sqliteSerializer = __esm({
|
|
33497
33501
|
init_dist();
|
33498
33502
|
init_sqlite_core();
|
33499
33503
|
init_outputs();
|
33504
|
+
init_utils();
|
33500
33505
|
init_utils6();
|
33501
33506
|
generateSqliteSnapshot = (tables, views, casing2) => {
|
33502
33507
|
const dialect4 = new SQLiteSyncDialect({ casing: casing2 });
|
@@ -33540,7 +33545,7 @@ var init_sqliteSerializer = __esm({
|
|
33540
33545
|
if (is(column4.default, SQL)) {
|
33541
33546
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
33542
33547
|
} else {
|
33543
|
-
columnToSet.default = typeof column4.default === "string" ? `'${column4.default}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33548
|
+
columnToSet.default = typeof column4.default === "string" ? `'${escapeSingleQuotes(column4.default)}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33544
33549
|
}
|
33545
33550
|
}
|
33546
33551
|
columnsObject[name2] = columnToSet;
|
@@ -34091,6 +34096,25 @@ WHERE
|
|
34091
34096
|
}
|
34092
34097
|
});
|
34093
34098
|
|
34099
|
+
// src/extensions/getTablesFilterByExtensions.ts
|
34100
|
+
var getTablesFilterByExtensions;
|
34101
|
+
var init_getTablesFilterByExtensions = __esm({
|
34102
|
+
"src/extensions/getTablesFilterByExtensions.ts"() {
|
34103
|
+
"use strict";
|
34104
|
+
getTablesFilterByExtensions = ({
|
34105
|
+
extensionsFilters,
|
34106
|
+
dialect: dialect4
|
34107
|
+
}) => {
|
34108
|
+
if (extensionsFilters) {
|
34109
|
+
if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
|
34110
|
+
return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
|
34111
|
+
}
|
34112
|
+
}
|
34113
|
+
return [];
|
34114
|
+
};
|
34115
|
+
}
|
34116
|
+
});
|
34117
|
+
|
34094
34118
|
// ../drizzle-orm/dist/mysql-core/alias.js
|
34095
34119
|
var init_alias4 = __esm({
|
34096
34120
|
"../drizzle-orm/dist/mysql-core/alias.js"() {
|
@@ -34713,7 +34737,7 @@ var init_datetime = __esm({
|
|
34713
34737
|
// ../drizzle-orm/dist/mysql-core/columns/decimal.js
|
34714
34738
|
function decimal(a, b = {}) {
|
34715
34739
|
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34716
|
-
return new MySqlDecimalBuilder(name2, config
|
34740
|
+
return new MySqlDecimalBuilder(name2, config);
|
34717
34741
|
}
|
34718
34742
|
var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
|
34719
34743
|
var init_decimal = __esm({
|
@@ -34723,10 +34747,11 @@ var init_decimal = __esm({
|
|
34723
34747
|
init_utils2();
|
34724
34748
|
init_common4();
|
34725
34749
|
MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
|
34726
|
-
constructor(name2,
|
34750
|
+
constructor(name2, config) {
|
34727
34751
|
super(name2, "string", "MySqlDecimal");
|
34728
|
-
this.config.precision = precision;
|
34729
|
-
this.config.scale = scale;
|
34752
|
+
this.config.precision = config?.precision;
|
34753
|
+
this.config.scale = config?.scale;
|
34754
|
+
this.config.unsigned = config?.unsigned;
|
34730
34755
|
}
|
34731
34756
|
/** @internal */
|
34732
34757
|
build(table4) {
|
@@ -34742,15 +34767,19 @@ var init_decimal = __esm({
|
|
34742
34767
|
super(...arguments);
|
34743
34768
|
__publicField(this, "precision", this.config.precision);
|
34744
34769
|
__publicField(this, "scale", this.config.scale);
|
34770
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34745
34771
|
}
|
34746
34772
|
getSQLType() {
|
34773
|
+
let type = "";
|
34747
34774
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34748
|
-
|
34775
|
+
type += `decimal(${this.precision},${this.scale})`;
|
34749
34776
|
} else if (this.precision === void 0) {
|
34750
|
-
|
34777
|
+
type += "decimal";
|
34751
34778
|
} else {
|
34752
|
-
|
34779
|
+
type += `decimal(${this.precision})`;
|
34753
34780
|
}
|
34781
|
+
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
34782
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34754
34783
|
}
|
34755
34784
|
};
|
34756
34785
|
__publicField(MySqlDecimal, _a260, "MySqlDecimal");
|
@@ -34774,6 +34803,7 @@ var init_double = __esm({
|
|
34774
34803
|
super(name2, "number", "MySqlDouble");
|
34775
34804
|
this.config.precision = config?.precision;
|
34776
34805
|
this.config.scale = config?.scale;
|
34806
|
+
this.config.unsigned = config?.unsigned;
|
34777
34807
|
}
|
34778
34808
|
/** @internal */
|
34779
34809
|
build(table4) {
|
@@ -34786,15 +34816,18 @@ var init_double = __esm({
|
|
34786
34816
|
super(...arguments);
|
34787
34817
|
__publicField(this, "precision", this.config.precision);
|
34788
34818
|
__publicField(this, "scale", this.config.scale);
|
34819
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34789
34820
|
}
|
34790
34821
|
getSQLType() {
|
34822
|
+
let type = "";
|
34791
34823
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34792
|
-
|
34824
|
+
type += `double(${this.precision},${this.scale})`;
|
34793
34825
|
} else if (this.precision === void 0) {
|
34794
|
-
|
34826
|
+
type += "double";
|
34795
34827
|
} else {
|
34796
|
-
|
34828
|
+
type += `double(${this.precision})`;
|
34797
34829
|
}
|
34830
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34798
34831
|
}
|
34799
34832
|
};
|
34800
34833
|
__publicField(MySqlDouble, _a262, "MySqlDouble");
|
@@ -34844,18 +34877,23 @@ var init_enum2 = __esm({
|
|
34844
34877
|
});
|
34845
34878
|
|
34846
34879
|
// ../drizzle-orm/dist/mysql-core/columns/float.js
|
34847
|
-
function float(
|
34848
|
-
|
34880
|
+
function float(a, b) {
|
34881
|
+
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34882
|
+
return new MySqlFloatBuilder(name2, config);
|
34849
34883
|
}
|
34850
34884
|
var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
|
34851
34885
|
var init_float = __esm({
|
34852
34886
|
"../drizzle-orm/dist/mysql-core/columns/float.js"() {
|
34853
34887
|
"use strict";
|
34854
34888
|
init_entity();
|
34889
|
+
init_utils2();
|
34855
34890
|
init_common4();
|
34856
34891
|
MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
|
34857
|
-
constructor(name2) {
|
34892
|
+
constructor(name2, config) {
|
34858
34893
|
super(name2, "number", "MySqlFloat");
|
34894
|
+
this.config.precision = config?.precision;
|
34895
|
+
this.config.scale = config?.scale;
|
34896
|
+
this.config.unsigned = config?.unsigned;
|
34859
34897
|
}
|
34860
34898
|
/** @internal */
|
34861
34899
|
build(table4) {
|
@@ -34864,8 +34902,22 @@ var init_float = __esm({
|
|
34864
34902
|
};
|
34865
34903
|
__publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
|
34866
34904
|
MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
|
34905
|
+
constructor() {
|
34906
|
+
super(...arguments);
|
34907
|
+
__publicField(this, "precision", this.config.precision);
|
34908
|
+
__publicField(this, "scale", this.config.scale);
|
34909
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34910
|
+
}
|
34867
34911
|
getSQLType() {
|
34868
|
-
|
34912
|
+
let type = "";
|
34913
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
34914
|
+
type += `float(${this.precision},${this.scale})`;
|
34915
|
+
} else if (this.precision === void 0) {
|
34916
|
+
type += "float";
|
34917
|
+
} else {
|
34918
|
+
type += `float(${this.precision})`;
|
34919
|
+
}
|
34920
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34869
34921
|
}
|
34870
34922
|
};
|
34871
34923
|
__publicField(MySqlFloat, _a266, "MySqlFloat");
|
@@ -35721,7 +35773,7 @@ var init_insert3 = __esm({
|
|
35721
35773
|
returning.push({ field: value, path: [key] });
|
35722
35774
|
}
|
35723
35775
|
}
|
35724
|
-
this.config.returning =
|
35776
|
+
this.config.returning = returning;
|
35725
35777
|
return this;
|
35726
35778
|
}
|
35727
35779
|
/** @internal */
|
@@ -38393,15 +38445,15 @@ function clearDefaults(defaultValue, collate) {
|
|
38393
38445
|
if (defaultValue.startsWith(collate)) {
|
38394
38446
|
resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
|
38395
38447
|
if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
|
38396
|
-
return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
|
38448
|
+
return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
|
38397
38449
|
} else {
|
38398
|
-
return `'${resultDefault}'`;
|
38450
|
+
return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
|
38399
38451
|
}
|
38400
38452
|
} else {
|
38401
38453
|
return `(${resultDefault})`;
|
38402
38454
|
}
|
38403
38455
|
}
|
38404
|
-
var generateMySqlSnapshot, fromDatabase3;
|
38456
|
+
var handleEnumType, generateMySqlSnapshot, fromDatabase3;
|
38405
38457
|
var init_mysqlSerializer = __esm({
|
38406
38458
|
"src/serializer/mysqlSerializer.ts"() {
|
38407
38459
|
"use strict";
|
@@ -38409,7 +38461,14 @@ var init_mysqlSerializer = __esm({
|
|
38409
38461
|
init_dist();
|
38410
38462
|
init_mysql_core();
|
38411
38463
|
init_outputs();
|
38464
|
+
init_utils();
|
38412
38465
|
init_utils6();
|
38466
|
+
handleEnumType = (type) => {
|
38467
|
+
let str = type.split("(")[1];
|
38468
|
+
str = str.substring(0, str.length - 1);
|
38469
|
+
const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
|
38470
|
+
return `enum(${values.join(",")})`;
|
38471
|
+
};
|
38413
38472
|
generateMySqlSnapshot = (tables, views, casing2) => {
|
38414
38473
|
const dialect4 = new MySqlDialect({ casing: casing2 });
|
38415
38474
|
const result = {};
|
@@ -38436,12 +38495,13 @@ var init_mysqlSerializer = __esm({
|
|
38436
38495
|
columns.forEach((column4) => {
|
38437
38496
|
const name2 = getColumnCasing(column4, casing2);
|
38438
38497
|
const notNull = column4.notNull;
|
38439
|
-
const
|
38498
|
+
const sqlType = column4.getSQLType();
|
38499
|
+
const sqlTypeLowered = sqlType.toLowerCase();
|
38440
38500
|
const autoIncrement = typeof column4.autoIncrement === "undefined" ? false : column4.autoIncrement;
|
38441
38501
|
const generated = column4.generated;
|
38442
38502
|
const columnToSet = {
|
38443
38503
|
name: name2,
|
38444
|
-
type:
|
38504
|
+
type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
|
38445
38505
|
primaryKey: false,
|
38446
38506
|
// If field is autoincrement it's notNull by default
|
38447
38507
|
// notNull: autoIncrement ? true : notNull,
|
@@ -38488,7 +38548,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
38488
38548
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
38489
38549
|
} else {
|
38490
38550
|
if (typeof column4.default === "string") {
|
38491
|
-
columnToSet.default = `'${column4.default}'`;
|
38551
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
38492
38552
|
} else {
|
38493
38553
|
if (sqlTypeLowered === "json") {
|
38494
38554
|
columnToSet.default = `'${JSON.stringify(column4.default)}'`;
|
@@ -38857,15 +38917,15 @@ ${withStyle.errorWarning(
|
|
38857
38917
|
changedType = columnType.replace("bigint unsigned", "serial");
|
38858
38918
|
}
|
38859
38919
|
}
|
38860
|
-
if (columnType.
|
38861
|
-
changedType = "
|
38920
|
+
if (columnType.includes("decimal(10,0)")) {
|
38921
|
+
changedType = columnType.replace("decimal(10,0)", "decimal");
|
38862
38922
|
}
|
38863
38923
|
let onUpdate = void 0;
|
38864
38924
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
38865
38925
|
onUpdate = true;
|
38866
38926
|
}
|
38867
38927
|
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}'`,
|
38928
|
+
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
38929
|
autoincrement: isAutoincrement,
|
38870
38930
|
name: columnName,
|
38871
38931
|
type: changedType,
|
@@ -39380,6 +39440,7 @@ var init_utils9 = __esm({
|
|
39380
39440
|
"use strict";
|
39381
39441
|
import_hanji7 = __toESM(require_hanji());
|
39382
39442
|
init_lib();
|
39443
|
+
init_getTablesFilterByExtensions();
|
39383
39444
|
init_global();
|
39384
39445
|
init_schemaValidator();
|
39385
39446
|
init_serializer();
|
@@ -40336,6 +40397,7 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
40336
40397
|
|
40337
40398
|
// src/api.ts
|
40338
40399
|
init_sqlitePushUtils();
|
40400
|
+
init_getTablesFilterByExtensions();
|
40339
40401
|
init_global();
|
40340
40402
|
init_migrationPreparator();
|
40341
40403
|
init_mysqlSchema();
|
@@ -40389,9 +40451,12 @@ var generateMigration = async (prev, cur) => {
|
|
40389
40451
|
);
|
40390
40452
|
return sqlStatements;
|
40391
40453
|
};
|
40392
|
-
var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
40454
|
+
var pushSchema = async (imports, drizzleInstance, schemaFilters, tablesFilter, extensionsFilters) => {
|
40393
40455
|
const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
40394
40456
|
const { sql: sql2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
40457
|
+
const filters = (tablesFilter ?? []).concat(
|
40458
|
+
getTablesFilterByExtensions({ extensionsFilters, dialect: "postgresql" })
|
40459
|
+
);
|
40395
40460
|
const db = {
|
40396
40461
|
query: async (query, params) => {
|
40397
40462
|
const res = await drizzleInstance.execute(sql2.raw(query));
|
@@ -40401,7 +40466,7 @@ var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
|
40401
40466
|
const cur = generateDrizzleJson(imports);
|
40402
40467
|
const { schema: prev } = await pgPushIntrospect(
|
40403
40468
|
db,
|
40404
|
-
|
40469
|
+
filters,
|
40405
40470
|
schemaFilters ?? ["public"],
|
40406
40471
|
void 0
|
40407
40472
|
);
|