drizzle-kit 0.27.2 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +3 -2
- package/api.d.ts +3 -2
- package/api.js +262 -200
- package/api.mjs +262 -200
- package/bin.cjs +47741 -47681
- 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.mjs
CHANGED
@@ -7530,30 +7530,11 @@ var init_mysqlSchema = __esm({
|
|
7530
7530
|
}
|
7531
7531
|
});
|
7532
7532
|
|
7533
|
-
// src/extensions/vector.ts
|
7534
|
-
var vectorOps;
|
7535
|
-
var init_vector = __esm({
|
7536
|
-
"src/extensions/vector.ts"() {
|
7537
|
-
"use strict";
|
7538
|
-
vectorOps = [
|
7539
|
-
"vector_l2_ops",
|
7540
|
-
"vector_ip_ops",
|
7541
|
-
"vector_cosine_ops",
|
7542
|
-
"vector_l1_ops",
|
7543
|
-
"bit_hamming_ops",
|
7544
|
-
"bit_jaccard_ops",
|
7545
|
-
"halfvec_l2_ops",
|
7546
|
-
"sparsevec_l2_ops"
|
7547
|
-
];
|
7548
|
-
}
|
7549
|
-
});
|
7550
|
-
|
7551
7533
|
// src/serializer/pgSchema.ts
|
7552
7534
|
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, roleSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, policy, policySquashed, viewWithOption, matViewWithOption, mergedViewWithOption, view2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
7553
7535
|
var init_pgSchema = __esm({
|
7554
7536
|
"src/serializer/pgSchema.ts"() {
|
7555
7537
|
"use strict";
|
7556
|
-
init_vector();
|
7557
7538
|
init_global();
|
7558
7539
|
init_lib();
|
7559
7540
|
indexV2 = objectType({
|
@@ -8013,7 +7994,7 @@ var init_pgSchema = __esm({
|
|
8013
7994
|
squashIdx: (idx) => {
|
8014
7995
|
index2.parse(idx);
|
8015
7996
|
return `${idx.name};${idx.columns.map(
|
8016
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass
|
7997
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass ? c.opclass : ""}`
|
8017
7998
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
8018
7999
|
},
|
8019
8000
|
unsquashIdx: (input) => {
|
@@ -8079,11 +8060,11 @@ var init_pgSchema = __esm({
|
|
8079
8060
|
squashFK: (fk4) => {
|
8080
8061
|
return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
|
8081
8062
|
},
|
8082
|
-
squashPolicy: (
|
8083
|
-
return `${
|
8063
|
+
squashPolicy: (policy3) => {
|
8064
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.using}--${policy3.withCheck}--${policy3.on}`;
|
8084
8065
|
},
|
8085
|
-
unsquashPolicy: (
|
8086
|
-
const splitted =
|
8066
|
+
unsquashPolicy: (policy3) => {
|
8067
|
+
const splitted = policy3.split("--");
|
8087
8068
|
return {
|
8088
8069
|
name: splitted[0],
|
8089
8070
|
as: splitted[1],
|
@@ -8094,11 +8075,11 @@ var init_pgSchema = __esm({
|
|
8094
8075
|
on: splitted[6] !== "undefined" ? splitted[6] : void 0
|
8095
8076
|
};
|
8096
8077
|
},
|
8097
|
-
squashPolicyPush: (
|
8098
|
-
return `${
|
8078
|
+
squashPolicyPush: (policy3) => {
|
8079
|
+
return `${policy3.name}--${policy3.as}--${policy3.for}--${policy3.to?.join(",")}--${policy3.on}`;
|
8099
8080
|
},
|
8100
|
-
unsquashPolicyPush: (
|
8101
|
-
const splitted =
|
8081
|
+
unsquashPolicyPush: (policy3) => {
|
8082
|
+
const splitted = policy3.split("--");
|
8102
8083
|
return {
|
8103
8084
|
name: splitted[0],
|
8104
8085
|
as: splitted[1],
|
@@ -8219,8 +8200,8 @@ var init_pgSchema = __esm({
|
|
8219
8200
|
return PgSquasher.squashUnique(unq);
|
8220
8201
|
}
|
8221
8202
|
);
|
8222
|
-
const squashedPolicies = mapValues(it[1].policies, (
|
8223
|
-
return action === "push" ? PgSquasher.squashPolicyPush(
|
8203
|
+
const squashedPolicies = mapValues(it[1].policies, (policy3) => {
|
8204
|
+
return action === "push" ? PgSquasher.squashPolicyPush(policy3) : PgSquasher.squashPolicy(policy3);
|
8224
8205
|
});
|
8225
8206
|
const squashedChecksContraints = mapValues(
|
8226
8207
|
it[1].checkConstraints,
|
@@ -8608,6 +8589,9 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
|
|
8608
8589
|
const removedColumns = columnNames1.filter((it) => !set2.has(it));
|
8609
8590
|
return { addedColumns, removedColumns };
|
8610
8591
|
}
|
8592
|
+
function escapeSingleQuotes(str) {
|
8593
|
+
return str.replace(/'/g, "''");
|
8594
|
+
}
|
8611
8595
|
var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
8612
8596
|
var init_utils = __esm({
|
8613
8597
|
"src/utils.ts"() {
|
@@ -11943,7 +11927,7 @@ function fromJson(statements, dialect4, action, json22) {
|
|
11943
11927
|
}).filter((it) => it !== "");
|
11944
11928
|
return result;
|
11945
11929
|
}
|
11946
|
-
var
|
11930
|
+
var parseType, Convertor, PgCreateRoleConvertor, PgDropRoleConvertor, PgRenameRoleConvertor, PgAlterRoleConvertor, PgCreatePolicyConvertor, PgDropPolicyConvertor, PgRenamePolicyConvertor, PgAlterPolicyConvertor, PgCreateIndPolicyConvertor, PgDropIndPolicyConvertor, PgRenameIndPolicyConvertor, PgAlterIndPolicyConvertor, PgEnableRlsConvertor, PgDisableRlsConvertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgCreateViewConvertor, MySqlCreateViewConvertor, SqliteCreateViewConvertor, PgDropViewConvertor, MySqlDropViewConvertor, SqliteDropViewConvertor, MySqlAlterViewConvertor, PgRenameViewConvertor, MySqlRenameViewConvertor, PgAlterViewSchemaConvertor, PgAlterViewAddWithOptionConvertor, PgAlterViewDropWithOptionConvertor, PgAlterViewAlterTablespaceConvertor, PgAlterViewAlterUsingConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
11947
11931
|
var init_sqlgenerator = __esm({
|
11948
11932
|
"src/sqlgenerator.ts"() {
|
11949
11933
|
"use strict";
|
@@ -11951,51 +11935,56 @@ var init_sqlgenerator = __esm({
|
|
11951
11935
|
init_mysqlSchema();
|
11952
11936
|
init_pgSchema();
|
11953
11937
|
init_sqliteSchema();
|
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
|
-
|
11994
|
-
|
11995
|
-
|
11996
|
-
|
11997
|
-
|
11998
|
-
|
11938
|
+
init_utils();
|
11939
|
+
parseType = (schemaPrefix, type) => {
|
11940
|
+
const pgNativeTypes = [
|
11941
|
+
"uuid",
|
11942
|
+
"smallint",
|
11943
|
+
"integer",
|
11944
|
+
"bigint",
|
11945
|
+
"boolean",
|
11946
|
+
"text",
|
11947
|
+
"varchar",
|
11948
|
+
"serial",
|
11949
|
+
"bigserial",
|
11950
|
+
"decimal",
|
11951
|
+
"numeric",
|
11952
|
+
"real",
|
11953
|
+
"json",
|
11954
|
+
"jsonb",
|
11955
|
+
"time",
|
11956
|
+
"time with time zone",
|
11957
|
+
"time without time zone",
|
11958
|
+
"time",
|
11959
|
+
"timestamp",
|
11960
|
+
"timestamp with time zone",
|
11961
|
+
"timestamp without time zone",
|
11962
|
+
"date",
|
11963
|
+
"interval",
|
11964
|
+
"bigint",
|
11965
|
+
"bigserial",
|
11966
|
+
"double precision",
|
11967
|
+
"interval year",
|
11968
|
+
"interval month",
|
11969
|
+
"interval day",
|
11970
|
+
"interval hour",
|
11971
|
+
"interval minute",
|
11972
|
+
"interval second",
|
11973
|
+
"interval year to month",
|
11974
|
+
"interval day to hour",
|
11975
|
+
"interval day to minute",
|
11976
|
+
"interval day to second",
|
11977
|
+
"interval hour to minute",
|
11978
|
+
"interval hour to second",
|
11979
|
+
"interval minute to second",
|
11980
|
+
"char",
|
11981
|
+
"vector",
|
11982
|
+
"geometry"
|
11983
|
+
];
|
11984
|
+
const arrayDefinitionRegex = /\[\d*(?:\[\d*\])*\]/g;
|
11985
|
+
const arrayDefinition = (type.match(arrayDefinitionRegex) ?? []).join("");
|
11986
|
+
const withoutArrayDefinition = type.replace(arrayDefinitionRegex, "");
|
11987
|
+
return pgNativeTypes.some((it) => type.startsWith(it)) ? `${withoutArrayDefinition}${arrayDefinition}` : `${schemaPrefix}"${withoutArrayDefinition}"${arrayDefinition}`;
|
11999
11988
|
};
|
12000
11989
|
Convertor = class {
|
12001
11990
|
};
|
@@ -12036,14 +12025,14 @@ var init_sqlgenerator = __esm({
|
|
12036
12025
|
return statement.type === "create_policy" && dialect4 === "postgresql";
|
12037
12026
|
}
|
12038
12027
|
convert(statement) {
|
12039
|
-
const
|
12028
|
+
const policy3 = statement.data;
|
12040
12029
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12041
|
-
const usingPart =
|
12042
|
-
const withCheckPart =
|
12043
|
-
const policyToPart =
|
12030
|
+
const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
|
12031
|
+
const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
|
12032
|
+
const policyToPart = policy3.to?.map(
|
12044
12033
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
12045
12034
|
).join(", ");
|
12046
|
-
return `CREATE POLICY "${
|
12035
|
+
return `CREATE POLICY "${policy3.name}" ON ${tableNameWithSchema} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
12047
12036
|
}
|
12048
12037
|
};
|
12049
12038
|
PgDropPolicyConvertor = class extends Convertor {
|
@@ -12051,9 +12040,9 @@ var init_sqlgenerator = __esm({
|
|
12051
12040
|
return statement.type === "drop_policy" && dialect4 === "postgresql";
|
12052
12041
|
}
|
12053
12042
|
convert(statement) {
|
12054
|
-
const
|
12043
|
+
const policy3 = statement.data;
|
12055
12044
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12056
|
-
return `DROP POLICY "${
|
12045
|
+
return `DROP POLICY "${policy3.name}" ON ${tableNameWithSchema} CASCADE;`;
|
12057
12046
|
}
|
12058
12047
|
};
|
12059
12048
|
PgRenamePolicyConvertor = class extends Convertor {
|
@@ -12083,13 +12072,13 @@ var init_sqlgenerator = __esm({
|
|
12083
12072
|
return statement.type === "create_ind_policy" && dialect4 === "postgresql";
|
12084
12073
|
}
|
12085
12074
|
convert(statement) {
|
12086
|
-
const
|
12087
|
-
const usingPart =
|
12088
|
-
const withCheckPart =
|
12089
|
-
const policyToPart =
|
12075
|
+
const policy3 = statement.data;
|
12076
|
+
const usingPart = policy3.using ? ` USING (${policy3.using})` : "";
|
12077
|
+
const withCheckPart = policy3.withCheck ? ` WITH CHECK (${policy3.withCheck})` : "";
|
12078
|
+
const policyToPart = policy3.to?.map(
|
12090
12079
|
(v) => ["current_user", "current_role", "session_user", "public"].includes(v) ? v : `"${v}"`
|
12091
12080
|
).join(", ");
|
12092
|
-
return `CREATE POLICY "${
|
12081
|
+
return `CREATE POLICY "${policy3.name}" ON ${policy3.on} AS ${policy3.as?.toUpperCase()} FOR ${policy3.for?.toUpperCase()} TO ${policyToPart}${usingPart}${withCheckPart};`;
|
12093
12082
|
}
|
12094
12083
|
};
|
12095
12084
|
PgDropIndPolicyConvertor = class extends Convertor {
|
@@ -12097,8 +12086,8 @@ var init_sqlgenerator = __esm({
|
|
12097
12086
|
return statement.type === "drop_ind_policy" && dialect4 === "postgresql";
|
12098
12087
|
}
|
12099
12088
|
convert(statement) {
|
12100
|
-
const
|
12101
|
-
return `DROP POLICY "${
|
12089
|
+
const policy3 = statement.data;
|
12090
|
+
return `DROP POLICY "${policy3.name}" ON ${policy3.on} CASCADE;`;
|
12102
12091
|
}
|
12103
12092
|
};
|
12104
12093
|
PgRenameIndPolicyConvertor = class extends Convertor {
|
@@ -12156,7 +12145,7 @@ var init_sqlgenerator = __esm({
|
|
12156
12145
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
12157
12146
|
const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT "${column4.uniqueName}" UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
12158
12147
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
12159
|
-
const type =
|
12148
|
+
const type = parseType(schemaPrefix, column4.type);
|
12160
12149
|
const generated = column4.generated;
|
12161
12150
|
const generatedStatement = generated ? ` GENERATED ALWAYS AS (${generated?.as}) STORED` : "";
|
12162
12151
|
const unsquashedIdentity = column4.identity ? PgSquasher.unsquashIdentity(column4.identity) : void 0;
|
@@ -12713,7 +12702,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12713
12702
|
const { name: name2, values, schema: schema4 } = st;
|
12714
12703
|
const enumNameWithSchema = schema4 ? `"${schema4}"."${name2}"` : `"${name2}"`;
|
12715
12704
|
let valuesStatement = "(";
|
12716
|
-
valuesStatement += values.map((it) => `'${it}'`).join(", ");
|
12705
|
+
valuesStatement += values.map((it) => `'${escapeSingleQuotes(it)}'`).join(", ");
|
12717
12706
|
valuesStatement += ")";
|
12718
12707
|
let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
|
12719
12708
|
return statement;
|
@@ -12923,7 +12912,7 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
12923
12912
|
const tableNameWithSchema = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
12924
12913
|
const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
|
12925
12914
|
const schemaPrefix = column4.typeSchema && column4.typeSchema !== "public" ? `"${column4.typeSchema}".` : "";
|
12926
|
-
const fixedType =
|
12915
|
+
const fixedType = parseType(schemaPrefix, column4.type);
|
12927
12916
|
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
12928
12917
|
const unsquashedIdentity = identity ? PgSquasher.unsquashIdentity(identity) : void 0;
|
12929
12918
|
const identityWithSchema = schema4 ? `"${schema4}"."${unsquashedIdentity?.name}"` : `"${unsquashedIdentity?.name}"`;
|
@@ -13493,8 +13482,9 @@ WITH ${withCheckOption} CHECK OPTION` : "";
|
|
13493
13482
|
statement.new
|
13494
13483
|
);
|
13495
13484
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
13496
|
-
|
13497
|
-
|
13485
|
+
console.log(statement.oldConstraintName, statement.newConstraintName);
|
13486
|
+
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.oldConstraintName}";
|
13487
|
+
${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${statement.newConstraintName}" PRIMARY KEY("${newColumns.join('","')}");`;
|
13498
13488
|
}
|
13499
13489
|
};
|
13500
13490
|
MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
@@ -15697,30 +15687,29 @@ var init_jsonStatements = __esm({
|
|
15697
15687
|
};
|
15698
15688
|
});
|
15699
15689
|
};
|
15700
|
-
prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks
|
15690
|
+
prepareAddCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15701
15691
|
return Object.values(pks).map((it) => {
|
15702
|
-
const unsquashed = PgSquasher.unsquashPK(it);
|
15703
15692
|
return {
|
15704
15693
|
type: "create_composite_pk",
|
15705
15694
|
tableName,
|
15706
15695
|
data: it,
|
15707
15696
|
schema: schema4,
|
15708
|
-
constraintName:
|
15697
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
15709
15698
|
};
|
15710
15699
|
});
|
15711
15700
|
};
|
15712
|
-
prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks
|
15701
|
+
prepareDeleteCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15713
15702
|
return Object.values(pks).map((it) => {
|
15714
15703
|
return {
|
15715
15704
|
type: "delete_composite_pk",
|
15716
15705
|
tableName,
|
15717
15706
|
data: it,
|
15718
15707
|
schema: schema4,
|
15719
|
-
constraintName:
|
15708
|
+
constraintName: PgSquasher.unsquashPK(it).name
|
15720
15709
|
};
|
15721
15710
|
});
|
15722
15711
|
};
|
15723
|
-
prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks
|
15712
|
+
prepareAlterCompositePrimaryKeyPg = (tableName, schema4, pks) => {
|
15724
15713
|
return Object.values(pks).map((it) => {
|
15725
15714
|
return {
|
15726
15715
|
type: "alter_composite_pk",
|
@@ -15728,8 +15717,8 @@ var init_jsonStatements = __esm({
|
|
15728
15717
|
old: it.__old,
|
15729
15718
|
new: it.__new,
|
15730
15719
|
schema: schema4,
|
15731
|
-
oldConstraintName:
|
15732
|
-
newConstraintName:
|
15720
|
+
oldConstraintName: PgSquasher.unsquashPK(it.__old).name,
|
15721
|
+
newConstraintName: PgSquasher.unsquashPK(it.__new).name
|
15733
15722
|
};
|
15734
15723
|
});
|
15735
15724
|
};
|
@@ -15784,18 +15773,19 @@ var init_jsonStatements = __esm({
|
|
15784
15773
|
type: "create_composite_pk",
|
15785
15774
|
tableName,
|
15786
15775
|
data: it,
|
15787
|
-
constraintName:
|
15776
|
+
constraintName: unsquashed.name
|
15788
15777
|
});
|
15789
15778
|
}
|
15790
15779
|
return res;
|
15791
15780
|
};
|
15792
15781
|
prepareDeleteCompositePrimaryKeyMySql = (tableName, pks, json1) => {
|
15793
15782
|
return Object.values(pks).map((it) => {
|
15783
|
+
const unsquashed = MySqlSquasher.unsquashPK(it);
|
15794
15784
|
return {
|
15795
15785
|
type: "delete_composite_pk",
|
15796
15786
|
tableName,
|
15797
15787
|
data: it,
|
15798
|
-
constraintName:
|
15788
|
+
constraintName: unsquashed.name
|
15799
15789
|
};
|
15800
15790
|
});
|
15801
15791
|
};
|
@@ -16826,12 +16816,12 @@ var init_snapshotsDiffer = __esm({
|
|
16826
16816
|
(tableKey2, tableValue) => {
|
16827
16817
|
const patchedPolicies = mapKeys(
|
16828
16818
|
tableValue.policies,
|
16829
|
-
(policyKey,
|
16819
|
+
(policyKey, policy3) => {
|
16830
16820
|
const rens = policyRenamesDict[`${tableValue.schema || "public"}.${tableValue.name}`] || [];
|
16831
16821
|
const newName = columnChangeFor(policyKey, rens);
|
16832
|
-
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(
|
16822
|
+
const unsquashedPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(policy3) : PgSquasher.unsquashPolicy(policy3);
|
16833
16823
|
unsquashedPolicy.name = newName;
|
16834
|
-
|
16824
|
+
policy3 = PgSquasher.squashPolicy(unsquashedPolicy);
|
16835
16825
|
return newName;
|
16836
16826
|
}
|
16837
16827
|
);
|
@@ -16971,17 +16961,17 @@ var init_snapshotsDiffer = __esm({
|
|
16971
16961
|
const jsonDeletedCheckConstraints = [];
|
16972
16962
|
const jsonCreatedCheckConstraints = [];
|
16973
16963
|
for (let it of alteredTables) {
|
16974
|
-
let addedColumns
|
16964
|
+
let addedColumns;
|
16975
16965
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
16976
16966
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
16977
|
-
addedColumns =
|
16967
|
+
addedColumns = PgSquasher.unsquashPK(addedPkColumns);
|
16978
16968
|
}
|
16979
|
-
let deletedColumns
|
16969
|
+
let deletedColumns;
|
16980
16970
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
16981
16971
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
16982
|
-
deletedColumns =
|
16972
|
+
deletedColumns = PgSquasher.unsquashPK(deletedPkColumns);
|
16983
16973
|
}
|
16984
|
-
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
16974
|
+
const doPerformDeleteAndCreate = JSON.stringify(addedColumns ?? {}) !== JSON.stringify(deletedColumns ?? {});
|
16985
16975
|
let addedCompositePKs = [];
|
16986
16976
|
let deletedCompositePKs = [];
|
16987
16977
|
let alteredCompositePKs = [];
|
@@ -16989,22 +16979,18 @@ var init_snapshotsDiffer = __esm({
|
|
16989
16979
|
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
16990
16980
|
it.name,
|
16991
16981
|
it.schema,
|
16992
|
-
it.addedCompositePKs
|
16993
|
-
curFull
|
16982
|
+
it.addedCompositePKs
|
16994
16983
|
);
|
16995
16984
|
deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
|
16996
16985
|
it.name,
|
16997
16986
|
it.schema,
|
16998
|
-
it.deletedCompositePKs
|
16999
|
-
prevFull
|
16987
|
+
it.deletedCompositePKs
|
17000
16988
|
);
|
17001
16989
|
}
|
17002
16990
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
|
17003
16991
|
it.name,
|
17004
16992
|
it.schema,
|
17005
|
-
it.alteredCompositePKs
|
17006
|
-
prevFull,
|
17007
|
-
curFull
|
16993
|
+
it.alteredCompositePKs
|
17008
16994
|
);
|
17009
16995
|
let addedUniqueConstraints = [];
|
17010
16996
|
let deletedUniqueConstraints = [];
|
@@ -17123,9 +17109,9 @@ var init_snapshotsDiffer = __esm({
|
|
17123
17109
|
);
|
17124
17110
|
}
|
17125
17111
|
typedResult.alteredPolicies.forEach(({ values }) => {
|
17126
|
-
const
|
17127
|
-
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[
|
17128
|
-
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[
|
17112
|
+
const policy3 = action === "push" ? PgSquasher.unsquashPolicyPush(values) : PgSquasher.unsquashPolicy(values);
|
17113
|
+
const newPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json22.policies[policy3.name].values);
|
17114
|
+
const oldPolicy = action === "push" ? PgSquasher.unsquashPolicyPush(json22.policies[policy3.name].values) : PgSquasher.unsquashPolicy(json1.policies[policy3.name].values);
|
17129
17115
|
if (newPolicy.as !== oldPolicy.as) {
|
17130
17116
|
jsonDropIndPoliciesStatements.push(
|
17131
17117
|
...prepareDropIndPolicyJsons(
|
@@ -18003,9 +17989,9 @@ var init_snapshotsDiffer = __esm({
|
|
18003
17989
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
18004
17990
|
jsonStatements.push(...jsonTableAlternations);
|
18005
17991
|
jsonStatements.push(...jsonAddedCompositePKs);
|
17992
|
+
jsonStatements.push(...jsonAddColumnsStatemets);
|
18006
17993
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
18007
17994
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
18008
|
-
jsonStatements.push(...jsonAddColumnsStatemets);
|
18009
17995
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
18010
17996
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
18011
17997
|
jsonStatements.push(...jsonCreatedCheckConstraints);
|
@@ -21140,7 +21126,7 @@ var version;
|
|
21140
21126
|
var init_version = __esm({
|
21141
21127
|
"../drizzle-orm/dist/version.js"() {
|
21142
21128
|
"use strict";
|
21143
|
-
version = "0.36.
|
21129
|
+
version = "0.36.1";
|
21144
21130
|
}
|
21145
21131
|
});
|
21146
21132
|
|
@@ -23759,7 +23745,7 @@ function vector(a, b) {
|
|
23759
23745
|
return new PgVectorBuilder(name2, config);
|
23760
23746
|
}
|
23761
23747
|
var _a113, _b92, PgVectorBuilder, _a114, _b93, PgVector;
|
23762
|
-
var
|
23748
|
+
var init_vector = __esm({
|
23763
23749
|
"../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
|
23764
23750
|
"use strict";
|
23765
23751
|
init_entity();
|
@@ -23866,7 +23852,7 @@ var init_all = __esm({
|
|
23866
23852
|
init_bit();
|
23867
23853
|
init_halfvec();
|
23868
23854
|
init_sparsevec();
|
23869
|
-
|
23855
|
+
init_vector();
|
23870
23856
|
}
|
23871
23857
|
});
|
23872
23858
|
|
@@ -24338,7 +24324,7 @@ function jaccardDistance(column4, value) {
|
|
24338
24324
|
}
|
24339
24325
|
return sql`${column4} <%> ${value}`;
|
24340
24326
|
}
|
24341
|
-
var
|
24327
|
+
var init_vector2 = __esm({
|
24342
24328
|
"../drizzle-orm/dist/sql/functions/vector.js"() {
|
24343
24329
|
"use strict";
|
24344
24330
|
init_sql();
|
@@ -24350,7 +24336,7 @@ var init_functions = __esm({
|
|
24350
24336
|
"../drizzle-orm/dist/sql/functions/index.js"() {
|
24351
24337
|
"use strict";
|
24352
24338
|
init_aggregate();
|
24353
|
-
|
24339
|
+
init_vector2();
|
24354
24340
|
}
|
24355
24341
|
});
|
24356
24342
|
|
@@ -24580,7 +24566,7 @@ var init_columns = __esm({
|
|
24580
24566
|
init_bit();
|
24581
24567
|
init_halfvec();
|
24582
24568
|
init_sparsevec();
|
24583
|
-
|
24569
|
+
init_vector();
|
24584
24570
|
}
|
24585
24571
|
});
|
24586
24572
|
|
@@ -28326,6 +28312,24 @@ var init_pg_core = __esm({
|
|
28326
28312
|
}
|
28327
28313
|
});
|
28328
28314
|
|
28315
|
+
// src/extensions/vector.ts
|
28316
|
+
var vectorOps;
|
28317
|
+
var init_vector3 = __esm({
|
28318
|
+
"src/extensions/vector.ts"() {
|
28319
|
+
"use strict";
|
28320
|
+
vectorOps = [
|
28321
|
+
"vector_l2_ops",
|
28322
|
+
"vector_ip_ops",
|
28323
|
+
"vector_cosine_ops",
|
28324
|
+
"vector_l1_ops",
|
28325
|
+
"bit_hamming_ops",
|
28326
|
+
"bit_jaccard_ops",
|
28327
|
+
"halfvec_l2_ops",
|
28328
|
+
"sparsevec_l2_ops"
|
28329
|
+
];
|
28330
|
+
}
|
28331
|
+
});
|
28332
|
+
|
28329
28333
|
// src/serializer/utils.ts
|
28330
28334
|
function getColumnCasing(column4, casing2) {
|
28331
28335
|
if (!column4.name) return "";
|
@@ -28431,7 +28435,7 @@ var init_pgSerializer = __esm({
|
|
28431
28435
|
init_source();
|
28432
28436
|
init_dist();
|
28433
28437
|
init_pg_core();
|
28434
|
-
|
28438
|
+
init_vector3();
|
28435
28439
|
init_outputs();
|
28436
28440
|
init_utils();
|
28437
28441
|
init_utils6();
|
@@ -28535,7 +28539,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
28535
28539
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
28536
28540
|
} else {
|
28537
28541
|
if (typeof column4.default === "string") {
|
28538
|
-
columnToSet.default = `'${column4.default}'`;
|
28542
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
28539
28543
|
} else {
|
28540
28544
|
if (sqlTypeLowered === "jsonb" || sqlTypeLowered === "json") {
|
28541
28545
|
columnToSet.default = `'${JSON.stringify(column4.default)}'::${sqlTypeLowered}`;
|
@@ -28717,17 +28721,17 @@ ${withStyle.errorWarning(
|
|
28717
28721
|
with: value.config.with ?? {}
|
28718
28722
|
};
|
28719
28723
|
});
|
28720
|
-
policies2.forEach((
|
28724
|
+
policies2.forEach((policy3) => {
|
28721
28725
|
const mappedTo = [];
|
28722
|
-
if (!
|
28726
|
+
if (!policy3.to) {
|
28723
28727
|
mappedTo.push("public");
|
28724
28728
|
} else {
|
28725
|
-
if (
|
28726
|
-
mappedTo.push(
|
28727
|
-
} else if (
|
28728
|
-
mappedTo.push(
|
28729
|
-
} else if (
|
28730
|
-
|
28729
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28730
|
+
mappedTo.push(policy3.to);
|
28731
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28732
|
+
mappedTo.push(policy3.to.name);
|
28733
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28734
|
+
policy3.to.forEach((it) => {
|
28731
28735
|
if (typeof it === "string") {
|
28732
28736
|
mappedTo.push(it);
|
28733
28737
|
} else if (is(it, PgRole)) {
|
@@ -28736,24 +28740,24 @@ ${withStyle.errorWarning(
|
|
28736
28740
|
});
|
28737
28741
|
}
|
28738
28742
|
}
|
28739
|
-
if (policiesObject[
|
28743
|
+
if (policiesObject[policy3.name] !== void 0) {
|
28740
28744
|
console.log(
|
28741
28745
|
`
|
28742
28746
|
${withStyle.errorWarning(
|
28743
28747
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
28744
|
-
|
28748
|
+
policy3.name
|
28745
28749
|
)} name`
|
28746
28750
|
)}`
|
28747
28751
|
);
|
28748
28752
|
process.exit(1);
|
28749
28753
|
}
|
28750
|
-
policiesObject[
|
28751
|
-
name:
|
28752
|
-
as:
|
28753
|
-
for:
|
28754
|
+
policiesObject[policy3.name] = {
|
28755
|
+
name: policy3.name,
|
28756
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28757
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28754
28758
|
to: mappedTo.sort(),
|
28755
|
-
using: is(
|
28756
|
-
withCheck: is(
|
28759
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28760
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28757
28761
|
};
|
28758
28762
|
});
|
28759
28763
|
checks.forEach((check) => {
|
@@ -28797,28 +28801,28 @@ ${withStyle.errorWarning(
|
|
28797
28801
|
isRLSEnabled: enableRLS
|
28798
28802
|
};
|
28799
28803
|
}
|
28800
|
-
for (const
|
28801
|
-
if (!
|
28804
|
+
for (const policy3 of policies) {
|
28805
|
+
if (!policy3._linkedTable) {
|
28802
28806
|
console.log(
|
28803
28807
|
`
|
28804
28808
|
${withStyle.errorWarning(
|
28805
|
-
`"Policy ${
|
28809
|
+
`"Policy ${policy3.name} was skipped because it was not linked to any table. You should either include the policy in a table or use .link() on the policy to link it to any table you have. For more information, please check:`
|
28806
28810
|
)}`
|
28807
28811
|
);
|
28808
28812
|
continue;
|
28809
28813
|
}
|
28810
|
-
const tableConfig = getTableConfig(
|
28814
|
+
const tableConfig = getTableConfig(policy3._linkedTable);
|
28811
28815
|
const tableKey2 = `${tableConfig.schema ?? "public"}.${tableConfig.name}`;
|
28812
28816
|
const mappedTo = [];
|
28813
|
-
if (!
|
28817
|
+
if (!policy3.to) {
|
28814
28818
|
mappedTo.push("public");
|
28815
28819
|
} else {
|
28816
|
-
if (
|
28817
|
-
mappedTo.push(
|
28818
|
-
} else if (
|
28819
|
-
mappedTo.push(
|
28820
|
-
} else if (
|
28821
|
-
|
28820
|
+
if (policy3.to && typeof policy3.to === "string") {
|
28821
|
+
mappedTo.push(policy3.to);
|
28822
|
+
} else if (policy3.to && is(policy3.to, PgRole)) {
|
28823
|
+
mappedTo.push(policy3.to.name);
|
28824
|
+
} else if (policy3.to && Array.isArray(policy3.to)) {
|
28825
|
+
policy3.to.forEach((it) => {
|
28822
28826
|
if (typeof it === "string") {
|
28823
28827
|
mappedTo.push(it);
|
28824
28828
|
} else if (is(it, PgRole)) {
|
@@ -28827,29 +28831,29 @@ ${withStyle.errorWarning(
|
|
28827
28831
|
});
|
28828
28832
|
}
|
28829
28833
|
}
|
28830
|
-
if (result[tableKey2]?.policies[
|
28834
|
+
if (result[tableKey2]?.policies[policy3.name] !== void 0 || policiesToReturn[policy3.name] !== void 0) {
|
28831
28835
|
console.log(
|
28832
28836
|
`
|
28833
28837
|
${withStyle.errorWarning(
|
28834
28838
|
`We've found duplicated policy name across ${source_default.underline.blue(tableKey2)} table. Please rename one of the policies with ${source_default.underline.blue(
|
28835
|
-
|
28839
|
+
policy3.name
|
28836
28840
|
)} name`
|
28837
28841
|
)}`
|
28838
28842
|
);
|
28839
28843
|
process.exit(1);
|
28840
28844
|
}
|
28841
28845
|
const mappedPolicy = {
|
28842
|
-
name:
|
28843
|
-
as:
|
28844
|
-
for:
|
28846
|
+
name: policy3.name,
|
28847
|
+
as: policy3.as?.toUpperCase() ?? "PERMISSIVE",
|
28848
|
+
for: policy3.for?.toUpperCase() ?? "ALL",
|
28845
28849
|
to: mappedTo.sort(),
|
28846
|
-
using: is(
|
28847
|
-
withCheck: is(
|
28850
|
+
using: is(policy3.using, SQL) ? dialect4.sqlToQuery(policy3.using).sql : void 0,
|
28851
|
+
withCheck: is(policy3.withCheck, SQL) ? dialect4.sqlToQuery(policy3.withCheck).sql : void 0
|
28848
28852
|
};
|
28849
28853
|
if (result[tableKey2]) {
|
28850
|
-
result[tableKey2].policies[
|
28854
|
+
result[tableKey2].policies[policy3.name] = mappedPolicy;
|
28851
28855
|
} else {
|
28852
|
-
policiesToReturn[
|
28856
|
+
policiesToReturn[policy3.name] = {
|
28853
28857
|
...mappedPolicy,
|
28854
28858
|
schema: tableConfig.schema ?? "public",
|
28855
28859
|
on: `"${tableConfig.schema ?? "public"}"."${tableConfig.name}"`
|
@@ -29820,10 +29824,7 @@ WHERE
|
|
29820
29824
|
defaultForColumn = (column4, internals, tableName) => {
|
29821
29825
|
const columnName = column4.column_name;
|
29822
29826
|
const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
|
29823
|
-
if (column4.column_default === null) {
|
29824
|
-
return void 0;
|
29825
|
-
}
|
29826
|
-
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
29827
|
+
if (column4.column_default === null || column4.column_default === void 0 || column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
29827
29828
|
return void 0;
|
29828
29829
|
}
|
29829
29830
|
if (column4.column_default.endsWith("[]")) {
|
@@ -30251,7 +30252,7 @@ var init_blob = __esm({
|
|
30251
30252
|
return "blob";
|
30252
30253
|
}
|
30253
30254
|
mapFromDriverValue(value) {
|
30254
|
-
return BigInt(value.toString());
|
30255
|
+
return BigInt(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30255
30256
|
}
|
30256
30257
|
mapToDriverValue(value) {
|
30257
30258
|
return Buffer.from(value.toString());
|
@@ -30276,7 +30277,7 @@ var init_blob = __esm({
|
|
30276
30277
|
return "blob";
|
30277
30278
|
}
|
30278
30279
|
mapFromDriverValue(value) {
|
30279
|
-
return JSON.parse(value.toString());
|
30280
|
+
return JSON.parse(Buffer.isBuffer(value) ? value.toString() : String.fromCodePoint(...value));
|
30280
30281
|
}
|
30281
30282
|
mapToDriverValue(value) {
|
30282
30283
|
return Buffer.from(JSON.stringify(value));
|
@@ -33502,6 +33503,7 @@ var init_sqliteSerializer = __esm({
|
|
33502
33503
|
init_dist();
|
33503
33504
|
init_sqlite_core();
|
33504
33505
|
init_outputs();
|
33506
|
+
init_utils();
|
33505
33507
|
init_utils6();
|
33506
33508
|
generateSqliteSnapshot = (tables, views, casing2) => {
|
33507
33509
|
const dialect4 = new SQLiteSyncDialect({ casing: casing2 });
|
@@ -33545,7 +33547,7 @@ var init_sqliteSerializer = __esm({
|
|
33545
33547
|
if (is(column4.default, SQL)) {
|
33546
33548
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
33547
33549
|
} else {
|
33548
|
-
columnToSet.default = typeof column4.default === "string" ? `'${column4.default}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33550
|
+
columnToSet.default = typeof column4.default === "string" ? `'${escapeSingleQuotes(column4.default)}'` : typeof column4.default === "object" || Array.isArray(column4.default) ? `'${JSON.stringify(column4.default)}'` : column4.default;
|
33549
33551
|
}
|
33550
33552
|
}
|
33551
33553
|
columnsObject[name2] = columnToSet;
|
@@ -34096,6 +34098,25 @@ WHERE
|
|
34096
34098
|
}
|
34097
34099
|
});
|
34098
34100
|
|
34101
|
+
// src/extensions/getTablesFilterByExtensions.ts
|
34102
|
+
var getTablesFilterByExtensions;
|
34103
|
+
var init_getTablesFilterByExtensions = __esm({
|
34104
|
+
"src/extensions/getTablesFilterByExtensions.ts"() {
|
34105
|
+
"use strict";
|
34106
|
+
getTablesFilterByExtensions = ({
|
34107
|
+
extensionsFilters,
|
34108
|
+
dialect: dialect4
|
34109
|
+
}) => {
|
34110
|
+
if (extensionsFilters) {
|
34111
|
+
if (extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
|
34112
|
+
return ["!geography_columns", "!geometry_columns", "!spatial_ref_sys"];
|
34113
|
+
}
|
34114
|
+
}
|
34115
|
+
return [];
|
34116
|
+
};
|
34117
|
+
}
|
34118
|
+
});
|
34119
|
+
|
34099
34120
|
// ../drizzle-orm/dist/mysql-core/alias.js
|
34100
34121
|
var init_alias4 = __esm({
|
34101
34122
|
"../drizzle-orm/dist/mysql-core/alias.js"() {
|
@@ -34718,7 +34739,7 @@ var init_datetime = __esm({
|
|
34718
34739
|
// ../drizzle-orm/dist/mysql-core/columns/decimal.js
|
34719
34740
|
function decimal(a, b = {}) {
|
34720
34741
|
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34721
|
-
return new MySqlDecimalBuilder(name2, config
|
34742
|
+
return new MySqlDecimalBuilder(name2, config);
|
34722
34743
|
}
|
34723
34744
|
var _a259, _b182, MySqlDecimalBuilder, _a260, _b183, MySqlDecimal;
|
34724
34745
|
var init_decimal = __esm({
|
@@ -34728,10 +34749,11 @@ var init_decimal = __esm({
|
|
34728
34749
|
init_utils2();
|
34729
34750
|
init_common4();
|
34730
34751
|
MySqlDecimalBuilder = class extends (_b182 = MySqlColumnBuilderWithAutoIncrement, _a259 = entityKind, _b182) {
|
34731
|
-
constructor(name2,
|
34752
|
+
constructor(name2, config) {
|
34732
34753
|
super(name2, "string", "MySqlDecimal");
|
34733
|
-
this.config.precision = precision;
|
34734
|
-
this.config.scale = scale;
|
34754
|
+
this.config.precision = config?.precision;
|
34755
|
+
this.config.scale = config?.scale;
|
34756
|
+
this.config.unsigned = config?.unsigned;
|
34735
34757
|
}
|
34736
34758
|
/** @internal */
|
34737
34759
|
build(table4) {
|
@@ -34747,15 +34769,19 @@ var init_decimal = __esm({
|
|
34747
34769
|
super(...arguments);
|
34748
34770
|
__publicField(this, "precision", this.config.precision);
|
34749
34771
|
__publicField(this, "scale", this.config.scale);
|
34772
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34750
34773
|
}
|
34751
34774
|
getSQLType() {
|
34775
|
+
let type = "";
|
34752
34776
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34753
|
-
|
34777
|
+
type += `decimal(${this.precision},${this.scale})`;
|
34754
34778
|
} else if (this.precision === void 0) {
|
34755
|
-
|
34779
|
+
type += "decimal";
|
34756
34780
|
} else {
|
34757
|
-
|
34781
|
+
type += `decimal(${this.precision})`;
|
34758
34782
|
}
|
34783
|
+
type = type === "decimal(10,0)" || type === "decimal(10)" ? "decimal" : type;
|
34784
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34759
34785
|
}
|
34760
34786
|
};
|
34761
34787
|
__publicField(MySqlDecimal, _a260, "MySqlDecimal");
|
@@ -34779,6 +34805,7 @@ var init_double = __esm({
|
|
34779
34805
|
super(name2, "number", "MySqlDouble");
|
34780
34806
|
this.config.precision = config?.precision;
|
34781
34807
|
this.config.scale = config?.scale;
|
34808
|
+
this.config.unsigned = config?.unsigned;
|
34782
34809
|
}
|
34783
34810
|
/** @internal */
|
34784
34811
|
build(table4) {
|
@@ -34791,15 +34818,18 @@ var init_double = __esm({
|
|
34791
34818
|
super(...arguments);
|
34792
34819
|
__publicField(this, "precision", this.config.precision);
|
34793
34820
|
__publicField(this, "scale", this.config.scale);
|
34821
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34794
34822
|
}
|
34795
34823
|
getSQLType() {
|
34824
|
+
let type = "";
|
34796
34825
|
if (this.precision !== void 0 && this.scale !== void 0) {
|
34797
|
-
|
34826
|
+
type += `double(${this.precision},${this.scale})`;
|
34798
34827
|
} else if (this.precision === void 0) {
|
34799
|
-
|
34828
|
+
type += "double";
|
34800
34829
|
} else {
|
34801
|
-
|
34830
|
+
type += `double(${this.precision})`;
|
34802
34831
|
}
|
34832
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34803
34833
|
}
|
34804
34834
|
};
|
34805
34835
|
__publicField(MySqlDouble, _a262, "MySqlDouble");
|
@@ -34849,18 +34879,23 @@ var init_enum2 = __esm({
|
|
34849
34879
|
});
|
34850
34880
|
|
34851
34881
|
// ../drizzle-orm/dist/mysql-core/columns/float.js
|
34852
|
-
function float(
|
34853
|
-
|
34882
|
+
function float(a, b) {
|
34883
|
+
const { name: name2, config } = getColumnNameAndConfig(a, b);
|
34884
|
+
return new MySqlFloatBuilder(name2, config);
|
34854
34885
|
}
|
34855
34886
|
var _a265, _b188, MySqlFloatBuilder, _a266, _b189, MySqlFloat;
|
34856
34887
|
var init_float = __esm({
|
34857
34888
|
"../drizzle-orm/dist/mysql-core/columns/float.js"() {
|
34858
34889
|
"use strict";
|
34859
34890
|
init_entity();
|
34891
|
+
init_utils2();
|
34860
34892
|
init_common4();
|
34861
34893
|
MySqlFloatBuilder = class extends (_b188 = MySqlColumnBuilderWithAutoIncrement, _a265 = entityKind, _b188) {
|
34862
|
-
constructor(name2) {
|
34894
|
+
constructor(name2, config) {
|
34863
34895
|
super(name2, "number", "MySqlFloat");
|
34896
|
+
this.config.precision = config?.precision;
|
34897
|
+
this.config.scale = config?.scale;
|
34898
|
+
this.config.unsigned = config?.unsigned;
|
34864
34899
|
}
|
34865
34900
|
/** @internal */
|
34866
34901
|
build(table4) {
|
@@ -34869,8 +34904,22 @@ var init_float = __esm({
|
|
34869
34904
|
};
|
34870
34905
|
__publicField(MySqlFloatBuilder, _a265, "MySqlFloatBuilder");
|
34871
34906
|
MySqlFloat = class extends (_b189 = MySqlColumnWithAutoIncrement, _a266 = entityKind, _b189) {
|
34907
|
+
constructor() {
|
34908
|
+
super(...arguments);
|
34909
|
+
__publicField(this, "precision", this.config.precision);
|
34910
|
+
__publicField(this, "scale", this.config.scale);
|
34911
|
+
__publicField(this, "unsigned", this.config.unsigned);
|
34912
|
+
}
|
34872
34913
|
getSQLType() {
|
34873
|
-
|
34914
|
+
let type = "";
|
34915
|
+
if (this.precision !== void 0 && this.scale !== void 0) {
|
34916
|
+
type += `float(${this.precision},${this.scale})`;
|
34917
|
+
} else if (this.precision === void 0) {
|
34918
|
+
type += "float";
|
34919
|
+
} else {
|
34920
|
+
type += `float(${this.precision})`;
|
34921
|
+
}
|
34922
|
+
return this.unsigned ? `${type} unsigned` : type;
|
34874
34923
|
}
|
34875
34924
|
};
|
34876
34925
|
__publicField(MySqlFloat, _a266, "MySqlFloat");
|
@@ -38398,15 +38447,15 @@ function clearDefaults(defaultValue, collate) {
|
|
38398
38447
|
if (defaultValue.startsWith(collate)) {
|
38399
38448
|
resultDefault = resultDefault.substring(collate.length, defaultValue.length).replace(/\\/g, "");
|
38400
38449
|
if (resultDefault.startsWith("'") && resultDefault.endsWith("'")) {
|
38401
|
-
return `('${resultDefault.substring(1, resultDefault.length - 1)}')`;
|
38450
|
+
return `('${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}')`;
|
38402
38451
|
} else {
|
38403
|
-
return `'${resultDefault}'`;
|
38452
|
+
return `'${escapeSingleQuotes(resultDefault.substring(1, resultDefault.length - 1))}'`;
|
38404
38453
|
}
|
38405
38454
|
} else {
|
38406
38455
|
return `(${resultDefault})`;
|
38407
38456
|
}
|
38408
38457
|
}
|
38409
|
-
var generateMySqlSnapshot, fromDatabase3;
|
38458
|
+
var handleEnumType, generateMySqlSnapshot, fromDatabase3;
|
38410
38459
|
var init_mysqlSerializer = __esm({
|
38411
38460
|
"src/serializer/mysqlSerializer.ts"() {
|
38412
38461
|
"use strict";
|
@@ -38414,7 +38463,14 @@ var init_mysqlSerializer = __esm({
|
|
38414
38463
|
init_dist();
|
38415
38464
|
init_mysql_core();
|
38416
38465
|
init_outputs();
|
38466
|
+
init_utils();
|
38417
38467
|
init_utils6();
|
38468
|
+
handleEnumType = (type) => {
|
38469
|
+
let str = type.split("(")[1];
|
38470
|
+
str = str.substring(0, str.length - 1);
|
38471
|
+
const values = str.split(",").map((v) => `'${escapeSingleQuotes(v.substring(1, v.length - 1))}'`);
|
38472
|
+
return `enum(${values.join(",")})`;
|
38473
|
+
};
|
38418
38474
|
generateMySqlSnapshot = (tables, views, casing2) => {
|
38419
38475
|
const dialect4 = new MySqlDialect({ casing: casing2 });
|
38420
38476
|
const result = {};
|
@@ -38441,12 +38497,13 @@ var init_mysqlSerializer = __esm({
|
|
38441
38497
|
columns.forEach((column4) => {
|
38442
38498
|
const name2 = getColumnCasing(column4, casing2);
|
38443
38499
|
const notNull = column4.notNull;
|
38444
|
-
const
|
38500
|
+
const sqlType = column4.getSQLType();
|
38501
|
+
const sqlTypeLowered = sqlType.toLowerCase();
|
38445
38502
|
const autoIncrement = typeof column4.autoIncrement === "undefined" ? false : column4.autoIncrement;
|
38446
38503
|
const generated = column4.generated;
|
38447
38504
|
const columnToSet = {
|
38448
38505
|
name: name2,
|
38449
|
-
type:
|
38506
|
+
type: sqlType.startsWith("enum") ? handleEnumType(sqlType) : sqlType,
|
38450
38507
|
primaryKey: false,
|
38451
38508
|
// If field is autoincrement it's notNull by default
|
38452
38509
|
// notNull: autoIncrement ? true : notNull,
|
@@ -38493,7 +38550,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
38493
38550
|
columnToSet.default = sqlToStr(column4.default, casing2);
|
38494
38551
|
} else {
|
38495
38552
|
if (typeof column4.default === "string") {
|
38496
|
-
columnToSet.default = `'${column4.default}'`;
|
38553
|
+
columnToSet.default = `'${escapeSingleQuotes(column4.default)}'`;
|
38497
38554
|
} else {
|
38498
38555
|
if (sqlTypeLowered === "json") {
|
38499
38556
|
columnToSet.default = `'${JSON.stringify(column4.default)}'`;
|
@@ -38862,15 +38919,15 @@ ${withStyle.errorWarning(
|
|
38862
38919
|
changedType = columnType.replace("bigint unsigned", "serial");
|
38863
38920
|
}
|
38864
38921
|
}
|
38865
|
-
if (columnType.
|
38866
|
-
changedType = "
|
38922
|
+
if (columnType.includes("decimal(10,0)")) {
|
38923
|
+
changedType = columnType.replace("decimal(10,0)", "decimal");
|
38867
38924
|
}
|
38868
38925
|
let onUpdate = void 0;
|
38869
38926
|
if (columnType.startsWith("timestamp") && typeof columnExtra !== "undefined" && columnExtra.includes("on update CURRENT_TIMESTAMP")) {
|
38870
38927
|
onUpdate = true;
|
38871
38928
|
}
|
38872
38929
|
const newColumn = {
|
38873
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
38930
|
+
default: columnDefault === null || columnDefault === void 0 ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${escapeSingleQuotes(columnDefault)}'`,
|
38874
38931
|
autoincrement: isAutoincrement,
|
38875
38932
|
name: columnName,
|
38876
38933
|
type: changedType,
|
@@ -39385,6 +39442,7 @@ var init_utils9 = __esm({
|
|
39385
39442
|
"use strict";
|
39386
39443
|
import_hanji7 = __toESM(require_hanji());
|
39387
39444
|
init_lib();
|
39445
|
+
init_getTablesFilterByExtensions();
|
39388
39446
|
init_global();
|
39389
39447
|
init_schemaValidator();
|
39390
39448
|
init_serializer();
|
@@ -40327,6 +40385,7 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
40327
40385
|
|
40328
40386
|
// src/api.ts
|
40329
40387
|
init_sqlitePushUtils();
|
40388
|
+
init_getTablesFilterByExtensions();
|
40330
40389
|
init_global();
|
40331
40390
|
init_migrationPreparator();
|
40332
40391
|
init_mysqlSchema();
|
@@ -40380,9 +40439,12 @@ var generateMigration = async (prev, cur) => {
|
|
40380
40439
|
);
|
40381
40440
|
return sqlStatements;
|
40382
40441
|
};
|
40383
|
-
var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
40442
|
+
var pushSchema = async (imports, drizzleInstance, schemaFilters, tablesFilter, extensionsFilters) => {
|
40384
40443
|
const { applyPgSnapshotsDiff: applyPgSnapshotsDiff2 } = await Promise.resolve().then(() => (init_snapshotsDiffer(), snapshotsDiffer_exports));
|
40385
40444
|
const { sql: sql2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
40445
|
+
const filters = (tablesFilter ?? []).concat(
|
40446
|
+
getTablesFilterByExtensions({ extensionsFilters, dialect: "postgresql" })
|
40447
|
+
);
|
40386
40448
|
const db = {
|
40387
40449
|
query: async (query, params) => {
|
40388
40450
|
const res = await drizzleInstance.execute(sql2.raw(query));
|
@@ -40392,7 +40454,7 @@ var pushSchema = async (imports, drizzleInstance, schemaFilters) => {
|
|
40392
40454
|
const cur = generateDrizzleJson(imports);
|
40393
40455
|
const { schema: prev } = await pgPushIntrospect(
|
40394
40456
|
db,
|
40395
|
-
|
40457
|
+
filters,
|
40396
40458
|
schemaFilters ?? ["public"],
|
40397
40459
|
void 0
|
40398
40460
|
);
|