masterrecord 0.3.17 → 0.3.18

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
@@ -153,7 +153,7 @@ program.option('-V', 'output the version');
153
153
 
154
154
  if(typeof mig.createdatabase === 'function'){
155
155
  try{
156
- mig.createdatabase();
156
+ await mig.createdatabase();
157
157
  console.log('✓ Database ensured');
158
158
  await __cleanupAndExit(contextInstance, 0);
159
159
  }catch(err){
@@ -163,7 +163,7 @@ program.option('-V', 'output the version');
163
163
  }
164
164
  } else if(typeof mig.createDatabase === 'function'){
165
165
  try{
166
- mig.createDatabase();
166
+ await mig.createDatabase();
167
167
  console.log('✓ Database ensured');
168
168
  await __cleanupAndExit(contextInstance, 0);
169
169
  }catch(err){
@@ -447,7 +447,7 @@ program.option('-V', 'output the version');
447
447
  try{
448
448
  var newMigrationProjectInstance = new migrationProjectFile(ContextCtor);
449
449
  var tableObj = migration.buildUpObject(contextSnapshot.schema, cleanEntities);
450
- newMigrationProjectInstance.up(tableObj);
450
+ await newMigrationProjectInstance.up(tableObj);
451
451
  }catch(err){
452
452
  console.error(`\n❌ Error - Migration failed during execution`);
453
453
  console.error(`\nMigration file: ${mFile}`);
@@ -571,7 +571,7 @@ program.option('-V', 'output the version');
571
571
  var MigCtor = require(latestFile);
572
572
  var migInstance = new MigCtor(ContextCtor);
573
573
  if(typeof migInstance.down === 'function'){
574
- migInstance.down(tableObj);
574
+ await migInstance.down(tableObj);
575
575
  }else{
576
576
  console.log(`Warning - Migration '${path.basename(latestFile)}' has no down method; skipping.`);
577
577
  }
@@ -668,7 +668,7 @@ program.option('-V', 'output the version');
668
668
  var migrationProjectFile = require(migFile);
669
669
  var newMigrationProjectInstance = new migrationProjectFile(ContextCtor);
670
670
  var tableObj = migration.buildUpObject(contextSnapshot.schema, cleanEntities);
671
- newMigrationProjectInstance.up(tableObj);
671
+ await newMigrationProjectInstance.up(tableObj);
672
672
  }
673
673
  const snap = {
674
674
  file : contextAbs,
@@ -820,7 +820,7 @@ program.option('-V', 'output the version');
820
820
  var MigCtor = require(migFile);
821
821
  var migInstance = new MigCtor(ContextCtor);
822
822
  if(typeof migInstance.down === 'function'){
823
- migInstance.down(tableObj);
823
+ await migInstance.down(tableObj);
824
824
  } else {
825
825
  console.log(`Warning - Migration '${path.basename(migFile)}' has no down method; skipping.`);
826
826
  }
@@ -1004,7 +1004,7 @@ program.option('-V', 'output the version');
1004
1004
  var newMigrationProjectInstance = new migrationProjectFile(ContextCtor);
1005
1005
  var cleanEntities = migration.cleanEntities(contextInstance.__entities);
1006
1006
  var tableObj = migration.buildUpObject(entry.cs.schema, cleanEntities);
1007
- newMigrationProjectInstance.up(tableObj);
1007
+ await newMigrationProjectInstance.up(tableObj);
1008
1008
  var snap = {
1009
1009
  file : entry.contextAbs,
1010
1010
  executedLocation : executedLocation,
@@ -82,13 +82,13 @@ class schema{
82
82
  }
83
83
  }
84
84
 
85
- createTable(table){
85
+ async createTable(table){
86
86
 
87
87
  if(table){
88
88
  // If table exists, run sync instead of blind create
89
89
  const tableName = table.__name;
90
- if(this.context._SQLEngine.tableExists && this.context._SQLEngine.tableExists(tableName)){
91
- this.syncTable(table);
90
+ if(this.context._SQLEngine.tableExists && await this.context._SQLEngine.tableExists(tableName)){
91
+ await this.syncTable(table);
92
92
  } else {
93
93
  if(this.context.isSQLite){
94
94
  var sqliteQuery = require("./migrationSQLiteQuery");
@@ -117,10 +117,10 @@ class schema{
117
117
  }
118
118
 
119
119
  // Compute diffs and apply minimal changes
120
- syncTable(table){
120
+ async syncTable(table){
121
121
  const engine = this.context._SQLEngine;
122
122
  const tableName = table.__name;
123
- const existing = engine.getTableInfo ? engine.getTableInfo(tableName) : [];
123
+ const existing = engine.getTableInfo ? await engine.getTableInfo(tableName) : [];
124
124
  // Build a set of existing columns (sqlite: name, mysql: name)
125
125
  const existingNames = new Set((existing || []).map(c => (c.name || c.COLUMN_NAME))); // both engines map to name
126
126
  // Add missing columns only (safe path)
@@ -254,7 +254,7 @@ class schema{
254
254
  const create = queryBuilder.createTable(table);
255
255
  this.context._execute(create);
256
256
  // compute common columns
257
- const oldInfo = engine.getTableInfo(tableName.replace(/.*/, '_temp_alter_column_update')) || engine.getTableInfo("_temp_alter_column_update");
257
+ const oldInfo = await engine.getTableInfo(tableName.replace(/.*/, '_temp_alter_column_update')) || await engine.getTableInfo("_temp_alter_column_update");
258
258
  const oldNames = new Set((oldInfo || existing).map(r => r.name));
259
259
  const newNames = desiredCols.map(d => d.name);
260
260
  const common = newNames.filter(n => oldNames.has(n));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "masterrecord",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
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": {