masterrecord 0.2.17 → 0.2.19

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/Migrations/cli.js CHANGED
@@ -569,7 +569,7 @@ program.option('-V', 'output the version');
569
569
  var executedLocation = process.cwd();
570
570
  try{
571
571
  // Find all context snapshots and run update per snapshot (avoids unrelated framework contexts)
572
- var snapshotFiles = globSearch.sync('**/*_contextSnapShot.json', executedLocation);
572
+ var snapshotFiles = globSearch.sync('**/*_contextSnapShot.json', { cwd: executedLocation, dot: true, windowsPathsNoEscape: true, nocase: true });
573
573
  if(!(snapshotFiles && snapshotFiles.length)){
574
574
  console.log('No context snapshots found. Run enable-migrations for each context first.');
575
575
  return;
@@ -584,7 +584,13 @@ program.option('-V', 'output the version');
584
584
  const ctxName = (cs && cs.contextLocation)
585
585
  ? path.basename(cs.contextLocation).replace(/\.js$/i, '').toLowerCase()
586
586
  : nameFromPath;
587
- const migRel = globSearch.sync('**/*_migration.js', cs.migrationFolder) || [];
587
+ // Find migrations in snapshot's migrationFolder; fallback to <ContextDir>/db/migrations
588
+ let migRel = globSearch.sync('**/*_migration.js', { cwd: cs.migrationFolder, dot: true, windowsPathsNoEscape: true, nocase: true }) || [];
589
+ if(!(migRel && migRel.length)){
590
+ const defaultFolder = path.join(path.dirname(cs.contextLocation || snapFile), 'db', 'migrations');
591
+ migRel = globSearch.sync('**/*_migration.js', { cwd: defaultFolder, dot: true, windowsPathsNoEscape: true, nocase: true }) || [];
592
+ if(migRel && migRel.length){ cs.migrationFolder = defaultFolder; }
593
+ }
588
594
  const migs = migRel.map(f => path.resolve(cs.migrationFolder, f));
589
595
  if(!groups[ctxName]) groups[ctxName] = [];
590
596
  groups[ctxName].push({ snapFile, cs, ctxName, migs });
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "app-root-path": "^3.1.0",
10
10
  "better-sqlite3": "^12.4.1"
11
11
  },
12
- "version": "0.2.17",
12
+ "version": "0.2.19",
13
13
  "description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
14
14
  "homepage": "https://github.com/Tailor/MasterRecord#readme",
15
15
  "repository": {