orchid-orm 1.26.1 → 1.26.3

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.
@@ -3,6 +3,7 @@ export * from 'rake-db';
3
3
  import { EnumColumn, DomainColumn, RawSQL, ArrayColumn, VirtualColumn, UnknownColumn, defaultSchemaConfig, columnsShapeToCode, pushTableDataCode, Adapter } from 'pqb';
4
4
  import { deepCompare, toArray, addCode, codeToString, toCamelCase, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
5
5
  import path from 'node:path';
6
+ import { pathToFileURL } from 'url';
6
7
  import fs from 'fs/promises';
7
8
  import typescript from 'typescript';
8
9
 
@@ -1487,6 +1488,7 @@ const processTables = async (ast, structureToAstCtx, domainsMap, adapter, tables
1487
1488
  const compareSql = { values: [], expressions: [] };
1488
1489
  const tableExpressions = [];
1489
1490
  const { changeTables, changeTableSchemas, dropTables, tableShapes } = collectChangeAndDropTables(
1491
+ config,
1490
1492
  tables,
1491
1493
  dbStructure,
1492
1494
  currentSchema,
@@ -1540,13 +1542,13 @@ const collectCreateTables = (tables, dbStructure, currentSchema) => {
1540
1542
  return acc;
1541
1543
  }, []);
1542
1544
  };
1543
- const collectChangeAndDropTables = (tables, dbStructure, currentSchema, createTables) => {
1545
+ const collectChangeAndDropTables = (config, tables, dbStructure, currentSchema, createTables) => {
1544
1546
  const changeTables = [];
1545
1547
  const changeTableSchemas = [];
1546
1548
  const dropTables = [];
1547
1549
  const tableShapes = {};
1548
1550
  for (const dbTable of dbStructure.tables) {
1549
- if (dbTable.name === "schemaMigrations")
1551
+ if (dbTable.name === config.migrationsTable)
1550
1552
  continue;
1551
1553
  const codeTable = tables.find(
1552
1554
  (t) => {
@@ -2234,7 +2236,9 @@ const invalidConfig = (config) => new Error(
2234
2236
  );
2235
2237
  const getDbFromConfig = async (config, dbPath) => {
2236
2238
  var _a, _b;
2237
- const module = await config.import(path.resolve(config.basePath, dbPath));
2239
+ const module = await config.import(
2240
+ pathToFileURL(path.resolve(config.basePath, dbPath)).toString()
2241
+ );
2238
2242
  const db = module[(_a = config.dbExportedAs) != null ? _a : "db"];
2239
2243
  if (!(db == null ? void 0 : db.$queryBuilder)) {
2240
2244
  throw new Error(
@@ -2755,7 +2759,7 @@ const pull = async (options, config) => {
2755
2759
  const [adapter] = adapters;
2756
2760
  const currentSchema = adapter.schema || "public";
2757
2761
  const ctx = makeStructureToAstCtx(config, currentSchema);
2758
- const asts = await structureToAst(ctx, adapter);
2762
+ const asts = await structureToAst(ctx, adapter, config);
2759
2763
  const { tableInfos, fkeys } = getTableInfosAndFKeys(asts, config);
2760
2764
  const exclusiveWriteOptions = { flag: "wx" };
2761
2765
  const pendingFileWrites = [];