drizzle-kit 0.16.9-43ec28a → 0.16.9-54306c5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +28 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12802,7 +12802,7 @@ __export(pgSerializer_exports, {
|
|
|
12802
12802
|
generatePgSnapshot: () => generatePgSnapshot,
|
|
12803
12803
|
indexName: () => indexName
|
|
12804
12804
|
});
|
|
12805
|
-
var import_pg_core2, import_utils6, import_sql2, import_table2, dialect4, indexName, generatePgSnapshot, fromDatabase;
|
|
12805
|
+
var import_pg_core2, import_utils6, import_sql2, import_table2, dialect4, indexName, generatePgSnapshot, fromDatabase, defaultForColumn;
|
|
12806
12806
|
var init_pgSerializer = __esm({
|
|
12807
12807
|
"src/serializer/pgSerializer.ts"() {
|
|
12808
12808
|
import_pg_core2 = require("drizzle-orm/pg-core");
|
|
@@ -12924,7 +12924,7 @@ var init_pgSerializer = __esm({
|
|
|
12924
12924
|
return map;
|
|
12925
12925
|
}, {});
|
|
12926
12926
|
const schemasObject = Object.fromEntries(
|
|
12927
|
-
schemas.map((it) => [it.schemaName, it.schemaName])
|
|
12927
|
+
schemas.filter((it) => it.schemaName !== "public").map((it) => [it.schemaName, it.schemaName])
|
|
12928
12928
|
);
|
|
12929
12929
|
return {
|
|
12930
12930
|
version: "5",
|
|
@@ -12944,7 +12944,10 @@ var init_pgSerializer = __esm({
|
|
|
12944
12944
|
const allTables = await db.query(
|
|
12945
12945
|
`SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema = 'public';`
|
|
12946
12946
|
);
|
|
12947
|
-
const schemas = new Set(
|
|
12947
|
+
const schemas = new Set(
|
|
12948
|
+
allTables.rows.map((it) => it.table_schema)
|
|
12949
|
+
);
|
|
12950
|
+
schemas.delete("public");
|
|
12948
12951
|
progressCallback("tables", allTables.rows.length, "done");
|
|
12949
12952
|
let columnsCount = 0;
|
|
12950
12953
|
let indexesCount = 0;
|
|
@@ -13055,7 +13058,7 @@ var init_pgSerializer = __esm({
|
|
|
13055
13058
|
const uniqueKey = tableConstraints.rows.filter(
|
|
13056
13059
|
(mapRow) => columnName === mapRow.column_name && mapRow.constraint_type === "UNIQUE"
|
|
13057
13060
|
);
|
|
13058
|
-
const defaultValue = columnResponse
|
|
13061
|
+
const defaultValue = defaultForColumn(columnResponse);
|
|
13059
13062
|
const isSerial = columnType === "serial";
|
|
13060
13063
|
columnToReturn[columnName] = {
|
|
13061
13064
|
name: columnName,
|
|
@@ -13108,7 +13111,7 @@ var init_pgSerializer = __esm({
|
|
|
13108
13111
|
progressCallback("indexes", indexesCount, "fetching");
|
|
13109
13112
|
result[tableName] = {
|
|
13110
13113
|
name: tableName,
|
|
13111
|
-
schema: tableSchema,
|
|
13114
|
+
schema: tableSchema !== "public" ? tableSchema : "",
|
|
13112
13115
|
columns: columnToReturn,
|
|
13113
13116
|
indexes: indexToReturn,
|
|
13114
13117
|
foreignKeys: foreignKeysToReturn
|
|
@@ -13161,6 +13164,13 @@ var init_pgSerializer = __esm({
|
|
|
13161
13164
|
}
|
|
13162
13165
|
};
|
|
13163
13166
|
};
|
|
13167
|
+
defaultForColumn = (column5) => {
|
|
13168
|
+
if (column5.data_type === "serial" || column5.data_type === "smallserial" || column5.data_type === "bigserial") {
|
|
13169
|
+
return void 0;
|
|
13170
|
+
}
|
|
13171
|
+
const defaultValue = column5.column_default === null ? void 0 : column5.column_default;
|
|
13172
|
+
return defaultValue;
|
|
13173
|
+
};
|
|
13164
13174
|
}
|
|
13165
13175
|
});
|
|
13166
13176
|
|
|
@@ -13453,7 +13463,8 @@ var init_sqlgenerator = __esm({
|
|
|
13453
13463
|
isPgNativeType = (it) => {
|
|
13454
13464
|
if (pgNativeTypes.has(it))
|
|
13455
13465
|
return true;
|
|
13456
|
-
|
|
13466
|
+
const toCheck = it.replace(/ /g, "");
|
|
13467
|
+
return toCheck.startsWith("varchar(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(");
|
|
13457
13468
|
};
|
|
13458
13469
|
Convertor = class {
|
|
13459
13470
|
};
|
|
@@ -21986,7 +21997,6 @@ var init_words = __esm({
|
|
|
21986
21997
|
"hiroim",
|
|
21987
21998
|
"hitman",
|
|
21988
21999
|
"hobgoblin",
|
|
21989
|
-
"holocaust",
|
|
21990
22000
|
"hulk",
|
|
21991
22001
|
"human_cannonball",
|
|
21992
22002
|
"human_fly",
|
|
@@ -27387,7 +27397,8 @@ var init_introspect = __esm({
|
|
|
27387
27397
|
"interval",
|
|
27388
27398
|
"bigint",
|
|
27389
27399
|
"bigserial",
|
|
27390
|
-
"doublePrecision"
|
|
27400
|
+
"doublePrecision",
|
|
27401
|
+
"uuid"
|
|
27391
27402
|
]);
|
|
27392
27403
|
objToStatement = (json) => {
|
|
27393
27404
|
json = Object.fromEntries(Object.entries(json).filter((it) => it[1]));
|
|
@@ -27464,13 +27475,13 @@ var init_introspect = __esm({
|
|
|
27464
27475
|
return `export const ${it.name.camelCase()} = pgEnum("${it.name}", [${values}])
|
|
27465
27476
|
`;
|
|
27466
27477
|
}).join("").concat("\n");
|
|
27467
|
-
const schemaStatements = Object.entries(schemas).
|
|
27478
|
+
const schemaStatements = Object.entries(schemas).map((it) => {
|
|
27468
27479
|
return `export const ${it[1]} = pgSchema("${it[0]}");
|
|
27469
27480
|
`;
|
|
27470
27481
|
}).join();
|
|
27471
27482
|
const tableStatements = Object.values(schema4.tables).map((table4) => {
|
|
27472
27483
|
const schema5 = schemas[table4.schema];
|
|
27473
|
-
const func = schema5
|
|
27484
|
+
const func = schema5 ? schema5 : "pgTable";
|
|
27474
27485
|
let statement = `export const ${table4.name.camelCase()} = ${func}("${table4.name}", {
|
|
27475
27486
|
`;
|
|
27476
27487
|
statement += createTableColumns(
|
|
@@ -27508,6 +27519,8 @@ var init_introspect = __esm({
|
|
|
27508
27519
|
`;
|
|
27509
27520
|
result += enumStatements;
|
|
27510
27521
|
result += schemaStatements;
|
|
27522
|
+
result += `import { sql } from "drizzle-orm/sql"
|
|
27523
|
+
`;
|
|
27511
27524
|
result += "\n";
|
|
27512
27525
|
result += tableStatements.join("\n\n");
|
|
27513
27526
|
return result;
|
|
@@ -27558,6 +27571,11 @@ var init_introspect = __esm({
|
|
|
27558
27571
|
out += defaultValue ? `.default(${defaultValue})` : "";
|
|
27559
27572
|
return out;
|
|
27560
27573
|
}
|
|
27574
|
+
if (lowered === "uuid") {
|
|
27575
|
+
let out = `${name.camelCase()}: uuid("${name}")`;
|
|
27576
|
+
out += defaultValue === "gen_random_uuid()" ? ".defaultRandom()" : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
|
27577
|
+
return out;
|
|
27578
|
+
}
|
|
27561
27579
|
if (lowered.startsWith("numeric")) {
|
|
27562
27580
|
let params;
|
|
27563
27581
|
if (lowered.length > 7) {
|