masterrecord 0.3.1 → 0.3.3
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.
|
@@ -152,6 +152,14 @@ class migrationMySQLQuery {
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
addColum(table){
|
|
155
|
+
// Fixed: Use columnMapping to generate full column definition with constraints
|
|
156
|
+
// This includes NOT NULL, DEFAULT, UNIQUE, PRIMARY KEY, AUTO_INCREMENT
|
|
157
|
+
if(table.type && table.tableName && table.name){
|
|
158
|
+
const def = this.#columnMapping(table);
|
|
159
|
+
return `ALTER TABLE \`${table.tableName}\`
|
|
160
|
+
ADD ${def}`;
|
|
161
|
+
}
|
|
162
|
+
// Fallback for legacy behavior with just realDataType
|
|
155
163
|
return `ALTER TABLE \`${table.tableName}\`
|
|
156
164
|
ADD \`${table.name}\` ${table.realDataType}`;
|
|
157
165
|
|
|
@@ -167,7 +167,14 @@ class migrationPostgresQuery {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
addColum(table){
|
|
170
|
-
//
|
|
170
|
+
// Fixed: Use columnMapping to generate full column definition with constraints
|
|
171
|
+
// This includes NOT NULL, DEFAULT, UNIQUE, PRIMARY KEY
|
|
172
|
+
if(table.type && table.tableName && table.name){
|
|
173
|
+
const def = this.#columnMapping(table);
|
|
174
|
+
return `ALTER TABLE "${table.tableName}"
|
|
175
|
+
ADD COLUMN ${def}`;
|
|
176
|
+
}
|
|
177
|
+
// Fallback for legacy behavior with just realDataType
|
|
171
178
|
return `ALTER TABLE "${table.tableName}"
|
|
172
179
|
ADD COLUMN "${table.name}" ${table.realDataType}`;
|
|
173
180
|
}
|
|
@@ -108,6 +108,13 @@ class migrationSQLiteQuery {
|
|
|
108
108
|
return `ALTER TABLE ${table.tableName}
|
|
109
109
|
ADD COLUMN ${def}`;
|
|
110
110
|
}
|
|
111
|
+
// Fixed: Support direct column definitions (when table itself IS the column spec)
|
|
112
|
+
// This matches MySQL/PostgreSQL behavior for explicit column definitions
|
|
113
|
+
if(table.type && table.tableName && table.name){
|
|
114
|
+
const def = this.#columnMapping(table);
|
|
115
|
+
return `ALTER TABLE ${table.tableName}
|
|
116
|
+
ADD COLUMN ${def}`;
|
|
117
|
+
}
|
|
111
118
|
// Fallback legacy behavior: raw name provided must include full definition if caller wants type/constraints
|
|
112
119
|
return `ALTER TABLE ${table.tableName}
|
|
113
120
|
ADD COLUMN ${table.name}`;
|
package/Migrations/schema.js
CHANGED
|
@@ -24,17 +24,17 @@ class schema{
|
|
|
24
24
|
if(this.context.isSQLite){
|
|
25
25
|
var sqliteQuery = require("./migrationSQLiteQuery");
|
|
26
26
|
var queryBuilder = new sqliteQuery();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
// Fixed: Use addColum (consistent with MySQL/PostgreSQL) instead of alterColumn
|
|
28
|
+
// This allows explicit column definitions to work, not just CLI-generated migrations
|
|
29
|
+
// Note: No need to set table.realDataType - columnMapping handles type conversion internally
|
|
30
|
+
var query = queryBuilder.addColum(table);
|
|
31
|
+
this.context._execute(query);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if(this.context.isMySQL){
|
|
35
35
|
var sqlquery = require("./migrationMySQLQuery");
|
|
36
36
|
var queryBuilder = new sqlquery();
|
|
37
|
-
table.realDataType
|
|
37
|
+
// Note: No need to set table.realDataType - columnMapping handles type conversion internally
|
|
38
38
|
var query = queryBuilder.addColum(table);
|
|
39
39
|
this.context._execute(query);
|
|
40
40
|
}
|
|
@@ -42,7 +42,7 @@ class schema{
|
|
|
42
42
|
if(this.context.isPostgres){
|
|
43
43
|
var postgresQuery = require("./migrationPostgresQuery");
|
|
44
44
|
var queryBuilder = new postgresQuery();
|
|
45
|
-
table.realDataType
|
|
45
|
+
// Note: No need to set table.realDataType - columnMapping handles type conversion internally
|
|
46
46
|
var query = queryBuilder.addColum(table);
|
|
47
47
|
this.context._execute(query);
|
|
48
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "masterrecord",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
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": {
|