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