masterrecord 0.3.12 → 0.3.13
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 +3 -3
- package/Migrations/migrations.js +10 -0
- package/package.json +1 -1
- package/readme.md +17 -0
package/Migrations/cli.js
CHANGED
|
@@ -58,15 +58,15 @@ program.option('-V', 'output the version');
|
|
|
58
58
|
// location of folder where command is being executed..
|
|
59
59
|
var executedLocation = process.cwd();
|
|
60
60
|
// find context file from main folder location
|
|
61
|
-
var
|
|
62
|
-
if(!
|
|
61
|
+
var contextFile = migration.findContextFile(executedLocation, contextFileName);
|
|
62
|
+
if(!contextFile){
|
|
63
63
|
console.error(`\n❌ Error - Cannot read or find Context file '${contextFileName}.js'`);
|
|
64
64
|
console.error(`\nSearched in: ${executedLocation}`);
|
|
65
65
|
console.error(`\nMake sure your Context file exists and is named correctly.`);
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
var snap = {
|
|
69
|
-
file :
|
|
69
|
+
file : contextFile,
|
|
70
70
|
executedLocation : executedLocation,
|
|
71
71
|
contextEntities : [],
|
|
72
72
|
contextFileName: contextFileName.toLowerCase()
|
package/Migrations/migrations.js
CHANGED
|
@@ -166,6 +166,16 @@ class Migrations{
|
|
|
166
166
|
|
|
167
167
|
|
|
168
168
|
|
|
169
|
+
findContextFile(executedLocation, contextFileName){
|
|
170
|
+
var files = globSearch.sync(`**/*${contextFileName}.js`, {
|
|
171
|
+
cwd: executedLocation,
|
|
172
|
+
dot: true,
|
|
173
|
+
windowsPathsNoEscape: true
|
|
174
|
+
});
|
|
175
|
+
var file = files && files[0] ? path.resolve(executedLocation, files[0]) : null;
|
|
176
|
+
return file;
|
|
177
|
+
}
|
|
178
|
+
|
|
169
179
|
findContext(executedLocation, contextFileName){
|
|
170
180
|
var files = globSearch.sync(`**/*${contextFileName}.js`, {
|
|
171
181
|
cwd: executedLocation,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"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 ",
|
|
5
5
|
"main": "MasterRecord.js",
|
|
6
6
|
"bin": {
|
package/readme.md
CHANGED
|
@@ -1640,10 +1640,27 @@ MasterRecord has been upgraded to meet **FAANG engineering standards** (Google/M
|
|
|
1640
1640
|
- ✅ **Duplicate db/migrations Path Fixed** - Resolved bug where snapshot files were created with duplicate nested paths
|
|
1641
1641
|
- **Before**: `/components/qa/app/models/db/migrations/db/migrations/qacontext_contextSnapShot.json` ❌
|
|
1642
1642
|
- **After**: `/components/qa/app/models/db/migrations/qacontext_contextSnapShot.json` ✅
|
|
1643
|
+
- **Root Cause**: Incorrect glob API usage in `findContext` method (migrations.js:169-181)
|
|
1644
|
+
- **Fix**: Changed to use relative pattern + options object + `path.resolve()` for guaranteed absolute paths
|
|
1643
1645
|
- ✅ **Smart Path Resolution** - Added `pathUtils.js` with intelligent path detection
|
|
1644
1646
|
- ✅ **Prevents update-database-restart Failures** - Snapshot files now always created in the correct location
|
|
1645
1647
|
- ✅ **Cross-Platform Support** - Works correctly on Windows and Unix-based systems
|
|
1646
1648
|
|
|
1649
|
+
**Running Migrations - Important Notes:**
|
|
1650
|
+
- **Don't move migration files** - Leave them in their generated location (e.g., `/components/qa/db/migrations/`)
|
|
1651
|
+
- **Two ways to run migrations:**
|
|
1652
|
+
1. **From anywhere** - Run MasterRecord CLI from your project root, it will find migrations automatically:
|
|
1653
|
+
```bash
|
|
1654
|
+
npx masterrecord enable-migrations components/qa/app/models/qaContext
|
|
1655
|
+
npx masterrecord update-database components/qa/app/models/qaContext
|
|
1656
|
+
```
|
|
1657
|
+
2. **From migration directory** - cd into the specific migration area and run CLI there:
|
|
1658
|
+
```bash
|
|
1659
|
+
cd components/qa/db/migrations
|
|
1660
|
+
npx masterrecord update-database ../../app/models/qaContext
|
|
1661
|
+
```
|
|
1662
|
+
- MasterRecord uses intelligent path resolution to locate migrations regardless of where you run the command
|
|
1663
|
+
|
|
1647
1664
|
### Core Improvements (context.js)
|
|
1648
1665
|
|
|
1649
1666
|
**Critical Fixes:**
|