masterrecord 1.23.0 → 1.27.0
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/CHANGES.md +166 -0
- package/Entity/entityTrackerModel.js +0 -3
- package/Migrations/DatabaseFacade.js +230 -0
- package/Migrations/HistoryRepository.js +278 -0
- package/Migrations/HistoryRow.js +26 -0
- package/Migrations/MigrationsAssembly.js +83 -0
- package/Migrations/Migrator.js +361 -0
- package/Migrations/RelationalDatabaseCreator.js +363 -0
- package/Migrations/cli.js +245 -263
- package/Migrations/migrationId.js +32 -0
- package/Migrations/migrationSQLiteQuery.js +3 -3
- package/SQLLiteEngine.js +4 -1
- package/context.js +11 -0
- package/mySQLEngine.js +1 -1
- package/package.json +12 -3
|
@@ -214,7 +214,7 @@ class migrationSQLiteQuery {
|
|
|
214
214
|
queryVar += `${this.foreignKeyClause(fk)}, `;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
return `CREATE TABLE IF NOT EXISTS ${table.__name} (${queryVar.replace(/,\s*$/, "")});`;
|
|
217
|
+
return `CREATE TABLE IF NOT EXISTS "${table.__name}" (${queryVar.replace(/,\s*$/, "")});`;
|
|
218
218
|
|
|
219
219
|
/*
|
|
220
220
|
INTEGER PRIMARY KEY AUTOINCREMENT
|
|
@@ -237,11 +237,11 @@ class migrationSQLiteQuery {
|
|
|
237
237
|
// `IF NOT EXISTS` and dropColumn's skip-if-gone, and matching the Postgres
|
|
238
238
|
// builder. A migration that DROPs a legacy table which never existed on a
|
|
239
239
|
// fresh install is then a no-op instead of a hard failure.
|
|
240
|
-
return `DROP TABLE IF EXISTS ${name}`
|
|
240
|
+
return `DROP TABLE IF EXISTS "${name}"`
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
renameTable(table){
|
|
244
|
-
return `ALTER TABLE ${table.tableName} RENAME TO ${table.newName}`;
|
|
244
|
+
return `ALTER TABLE "${table.tableName}" RENAME TO "${table.newName}"`;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
renameColumn(table){
|
package/SQLLiteEngine.js
CHANGED
|
@@ -706,7 +706,10 @@ class SQLLiteEngine {
|
|
|
706
706
|
buildFrom(query, entity){
|
|
707
707
|
const entityName = this.getEntity(entity.__name, query.entityMap);
|
|
708
708
|
if(entityName ){
|
|
709
|
-
|
|
709
|
+
// Bracket-quoted like every other table reference in this engine: an
|
|
710
|
+
// entity named with a SQL reserved word (Order, Group, Transaction…)
|
|
711
|
+
// otherwise produced `FROM Order AS ran` -> "near \"Order\": syntax error".
|
|
712
|
+
return `FROM [${entity.__name}] AS ${entityName}`;
|
|
710
713
|
}
|
|
711
714
|
else{ return "" }
|
|
712
715
|
}
|
package/context.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import modelBuilder from './Entity/entityModelBuilder.js';
|
|
18
18
|
import query from './QueryLanguage/queryMethods.js';
|
|
19
19
|
import tools from './Tools.js';
|
|
20
|
+
import DatabaseFacade from './Migrations/DatabaseFacade.js';
|
|
20
21
|
import SQLLiteEngine from './SQLLiteEngine.js';
|
|
21
22
|
import MySQLEngine from './mySQLEngine.js';
|
|
22
23
|
import insertManager from './insertManager.js';
|
|
@@ -2028,6 +2029,16 @@ class context {
|
|
|
2028
2029
|
* Same shape on SQLite, MySQL and Postgres (engine-specific extras such as
|
|
2029
2030
|
* pool counters / server version are added when available).
|
|
2030
2031
|
*/
|
|
2032
|
+
/**
|
|
2033
|
+
* Database-level operations for this context — EF's `context.Database`:
|
|
2034
|
+
* ensureCreated / ensureDeleted / canConnect / hasTables /
|
|
2035
|
+
* generateCreateScript / getAppliedMigrations / baseline.
|
|
2036
|
+
*/
|
|
2037
|
+
get database() {
|
|
2038
|
+
if (!this.__database) { this.__database = new DatabaseFacade(this); }
|
|
2039
|
+
return this.__database;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2031
2042
|
async healthCheck() {
|
|
2032
2043
|
const engine = this.isSQLite ? 'sqlite' : this.isMySQL ? 'mysql' : this.isPostgres ? 'postgres' : 'unknown';
|
|
2033
2044
|
const started = Date.now();
|
package/mySQLEngine.js
CHANGED
|
@@ -197,7 +197,7 @@ class MySQLEngine {
|
|
|
197
197
|
// column defaults.
|
|
198
198
|
const groups = new Map();
|
|
199
199
|
for (const row of rows) {
|
|
200
|
-
const key = `${row.sql.tableName}
|
|
200
|
+
const key = `${row.sql.tableName}\u0000${row.sql.columns}`;
|
|
201
201
|
if (!groups.has(key)) groups.set(key, []);
|
|
202
202
|
groups.get(key).push(row);
|
|
203
203
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
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
|
"type": "module",
|
|
6
6
|
"main": "./MasterRecord.js",
|
|
@@ -32,7 +32,15 @@
|
|
|
32
32
|
"./errors": "./errors.js",
|
|
33
33
|
"./sql": "./QueryLanguage/rawSql.js",
|
|
34
34
|
"./logging": "./logging.js",
|
|
35
|
-
"./resilience": "./resilience.js"
|
|
35
|
+
"./resilience": "./resilience.js",
|
|
36
|
+
"./Migrations/HistoryRow": "./Migrations/HistoryRow.js",
|
|
37
|
+
"./Migrations/HistoryRepository": "./Migrations/HistoryRepository.js",
|
|
38
|
+
"./Migrations/RelationalDatabaseCreator": "./Migrations/RelationalDatabaseCreator.js",
|
|
39
|
+
"./Migrations/DatabaseFacade": "./Migrations/DatabaseFacade.js",
|
|
40
|
+
"./Migrations/contextInit": "./Migrations/contextInit.js",
|
|
41
|
+
"./Migrations/Migrator": "./Migrations/Migrator.js",
|
|
42
|
+
"./Migrations/MigrationsAssembly": "./Migrations/MigrationsAssembly.js",
|
|
43
|
+
"./Migrations/migrationId": "./Migrations/migrationId.js"
|
|
36
44
|
},
|
|
37
45
|
"bin": {
|
|
38
46
|
"masterrecord": "Migrations/cli.js"
|
|
@@ -48,7 +56,8 @@
|
|
|
48
56
|
"!prettier.config.js",
|
|
49
57
|
"docs/**/*.md",
|
|
50
58
|
"CHANGES.md",
|
|
51
|
-
"LICENSE"
|
|
59
|
+
"LICENSE",
|
|
60
|
+
"THIRD-PARTY-NOTICES.md"
|
|
52
61
|
],
|
|
53
62
|
"engines": {
|
|
54
63
|
"node": ">=20.0.0"
|