peta-orm 0.2.1 → 0.2.2
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.
|
@@ -2159,6 +2159,15 @@ ${downTables.join(`
|
|
|
2159
2159
|
if (col.isUnique && !col.isPrimaryKey) {
|
|
2160
2160
|
calls.push("unique()");
|
|
2161
2161
|
}
|
|
2162
|
+
const refConstraint = col.constraints.find((c) => c.type === "references");
|
|
2163
|
+
if (refConstraint?.args[0]) {
|
|
2164
|
+
const targetClass = typeof refConstraint.args[0] === "function" ? refConstraint.args[0]() : refConstraint.args[0];
|
|
2165
|
+
const targetTable = targetClass?.table;
|
|
2166
|
+
const targetColumns = refConstraint.args[1];
|
|
2167
|
+
if (typeof targetTable === "string" && targetTable && targetColumns?.length) {
|
|
2168
|
+
calls.push(`references("${targetTable}.${targetColumns[0]}")`);
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2162
2171
|
if (calls.length === 0)
|
|
2163
2172
|
return "";
|
|
2164
2173
|
const str = calls.join(".");
|
package/dist/migrations/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/migrations/generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,kBAAkB;;IAC7B,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/migrations/generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,kBAAkB;;IAC7B,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;CAqIlG"}
|
package/dist/migrations/index.js
CHANGED