@itrocks/mysql-maintainer 0.0.6 → 0.0.7
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/cjs/mysql-maintainer.js +9 -9
- package/cjs/mysql.js +2 -2
- package/esm/mysql-maintainer.js +9 -9
- package/esm/mysql.js +2 -2
- package/package.json +1 -1
package/cjs/mysql-maintainer.js
CHANGED
|
@@ -68,20 +68,20 @@ class MysqlMaintainer {
|
|
|
68
68
|
throw 'No table name for type';
|
|
69
69
|
}
|
|
70
70
|
console.log('##### UPDATE TABLE');
|
|
71
|
-
console.log('class table before normalize:');
|
|
72
71
|
const classTable = new reflect_to_schema_1.ReflectToTable().convert(type);
|
|
73
|
-
console.dir(classTable, { depth: null });
|
|
74
|
-
console.log('class table after normalize:');
|
|
75
72
|
new mysql_to_schema_1.MysqlToTable(this.connection).normalize(classTable);
|
|
76
|
-
console.dir(classTable, { depth: null });
|
|
77
|
-
console.log('mysql table:');
|
|
78
73
|
const mysqlTable = await ((new mysql_to_schema_1.MysqlToTable(this.connection)).convert(tableName));
|
|
79
|
-
console.dir(mysqlTable, { depth: null });
|
|
80
|
-
console.log('table diff:');
|
|
81
74
|
const schemaDiff = new schema_diff_1.TableDiff(mysqlTable, classTable);
|
|
82
|
-
console.
|
|
75
|
+
console.log('##### Additions:');
|
|
76
|
+
console.dir(schemaDiff.additions, { depth: null });
|
|
77
|
+
console.log('##### Changes:');
|
|
78
|
+
console.dir(schemaDiff.changes, { depth: null });
|
|
79
|
+
console.log('##### Deletions:');
|
|
80
|
+
console.dir(schemaDiff.deletions, { depth: null });
|
|
83
81
|
const schemaDiffMysql = new schema_diff_mysql_1.SchemaDiffMysql();
|
|
84
|
-
|
|
82
|
+
const sql = schemaDiffMysql.sql(schemaDiff, true);
|
|
83
|
+
console.log(sql);
|
|
84
|
+
await this.connection.query(sql);
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
87
87
|
}
|
package/cjs/mysql.js
CHANGED
|
@@ -43,14 +43,14 @@ class Mysql extends mysql_1.Mysql {
|
|
|
43
43
|
context.pop();
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
|
-
async readCollection(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType) {
|
|
46
|
+
async readCollection(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType.type) {
|
|
47
47
|
const context = (this.connection ?? await this.connect()).context;
|
|
48
48
|
context.push([object, type]);
|
|
49
49
|
const result = await super.readCollection(object, property, type);
|
|
50
50
|
context.pop();
|
|
51
51
|
return result;
|
|
52
52
|
}
|
|
53
|
-
async readCollectionIds(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType) {
|
|
53
|
+
async readCollectionIds(object, property, type = new reflect_1.ReflectProperty(object, property).collectionType.elementType.type) {
|
|
54
54
|
const context = (this.connection ?? await this.connect()).context;
|
|
55
55
|
context.push([object, type]);
|
|
56
56
|
const result = await super.readCollectionIds(object, property, type);
|
package/esm/mysql-maintainer.js
CHANGED
|
@@ -51,20 +51,20 @@ export class MysqlMaintainer {
|
|
|
51
51
|
throw 'No table name for type';
|
|
52
52
|
}
|
|
53
53
|
console.log('##### UPDATE TABLE');
|
|
54
|
-
console.log('class table before normalize:');
|
|
55
54
|
const classTable = new ReflectToTable().convert(type);
|
|
56
|
-
console.dir(classTable, { depth: null });
|
|
57
|
-
console.log('class table after normalize:');
|
|
58
55
|
new MysqlToTable(this.connection).normalize(classTable);
|
|
59
|
-
console.dir(classTable, { depth: null });
|
|
60
|
-
console.log('mysql table:');
|
|
61
56
|
const mysqlTable = await ((new MysqlToTable(this.connection)).convert(tableName));
|
|
62
|
-
console.dir(mysqlTable, { depth: null });
|
|
63
|
-
console.log('table diff:');
|
|
64
57
|
const schemaDiff = new TableDiff(mysqlTable, classTable);
|
|
65
|
-
console.
|
|
58
|
+
console.log('##### Additions:');
|
|
59
|
+
console.dir(schemaDiff.additions, { depth: null });
|
|
60
|
+
console.log('##### Changes:');
|
|
61
|
+
console.dir(schemaDiff.changes, { depth: null });
|
|
62
|
+
console.log('##### Deletions:');
|
|
63
|
+
console.dir(schemaDiff.deletions, { depth: null });
|
|
66
64
|
const schemaDiffMysql = new SchemaDiffMysql();
|
|
67
|
-
|
|
65
|
+
const sql = schemaDiffMysql.sql(schemaDiff, true);
|
|
66
|
+
console.log(sql);
|
|
67
|
+
await this.connection.query(sql);
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
}
|
package/esm/mysql.js
CHANGED
|
@@ -40,14 +40,14 @@ export class Mysql extends M {
|
|
|
40
40
|
context.pop();
|
|
41
41
|
return result;
|
|
42
42
|
}
|
|
43
|
-
async readCollection(object, property, type = new ReflectProperty(object, property).collectionType.elementType) {
|
|
43
|
+
async readCollection(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
|
|
44
44
|
const context = (this.connection ?? await this.connect()).context;
|
|
45
45
|
context.push([object, type]);
|
|
46
46
|
const result = await super.readCollection(object, property, type);
|
|
47
47
|
context.pop();
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
|
-
async readCollectionIds(object, property, type = new ReflectProperty(object, property).collectionType.elementType) {
|
|
50
|
+
async readCollectionIds(object, property, type = new ReflectProperty(object, property).collectionType.elementType.type) {
|
|
51
51
|
const context = (this.connection ?? await this.connect()).context;
|
|
52
52
|
context.push([object, type]);
|
|
53
53
|
const result = await super.readCollectionIds(object, property, type);
|
package/package.json
CHANGED