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(".");
@@ -4,7 +4,7 @@ import {
4
4
  MigrationRunner,
5
5
  loadConfig,
6
6
  loadMigrationFiles
7
- } from "../index-m8r7jkr4.js";
7
+ } from "../index-zth6eamb.js";
8
8
  import"../index-qwps5bne.js";
9
9
  import {
10
10
  __export
@@ -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;CA0HlG"}
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"}
@@ -5,7 +5,7 @@ import {
5
5
  defineConfig,
6
6
  loadConfig,
7
7
  loadMigrationFiles
8
- } from "../index-m8r7jkr4.js";
8
+ } from "../index-zth6eamb.js";
9
9
  import"../index-qwps5bne.js";
10
10
  import"../index-k18nf2r7.js";
11
11
  export {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "peta-orm",
3
3
  "type": "module",
4
4
  "private": false,
5
- "version": "0.2.1",
5
+ "version": "0.2.2",
6
6
  "description": "ORM for Bun, built on Kysely",
7
7
  "license": "MIT",
8
8
  "module": "src/index.ts",