Track database column versions and include in database version data
This commit is contained in:
parent
9398c827ed
commit
14babd5b8b
@ -163,7 +163,7 @@ class FormDatabase extends Controller {
|
|||||||
assoc_columns[col.UUID].DatabaseId = db.UUID
|
assoc_columns[col.UUID].DatabaseId = db.UUID
|
||||||
assoc_columns[col.UUID].Type = col.Type
|
assoc_columns[col.UUID].Type = col.Type
|
||||||
assoc_columns[col.UUID].additionalData = JSON.stringify(col.additionalData)
|
assoc_columns[col.UUID].additionalData = JSON.stringify(col.additionalData)
|
||||||
await assoc_columns[col.UUID].save()
|
await assoc_columns[col.UUID].version_save(`Updated in page "${page.Name}"`, req.user.id)
|
||||||
update_columns.push(assoc_columns[col.UUID])
|
update_columns.push(assoc_columns[col.UUID])
|
||||||
} else {
|
} else {
|
||||||
const new_col = new ColumnDef({
|
const new_col = new ColumnDef({
|
||||||
@ -181,7 +181,7 @@ class FormDatabase extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await new_col.save()
|
await new_col.version_save(`Added to database`, req.user.id)
|
||||||
update_columns.push(new_col)
|
update_columns.push(new_col)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const Model = require('flitter-orm/src/model/Model')
|
const VersionedModel = require('../../VersionedModel')
|
||||||
const uuid = require('uuid/v4')
|
const uuid = require('uuid/v4')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6,10 +6,11 @@ const uuid = require('uuid/v4')
|
|||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* Put some description here!
|
* Put some description here!
|
||||||
*/
|
*/
|
||||||
class ColumnDef extends Model {
|
class ColumnDef extends VersionedModel {
|
||||||
static get schema() {
|
static get schema() {
|
||||||
// Return a flitter-orm schema here.
|
// Return a flitter-orm schema here.
|
||||||
return {
|
return {
|
||||||
|
...super.schema,
|
||||||
headerName: String,
|
headerName: String,
|
||||||
field: String,
|
field: String,
|
||||||
DatabaseId: String,
|
DatabaseId: String,
|
||||||
@ -18,7 +19,7 @@ class ColumnDef extends Model {
|
|||||||
additionalData: { type: String, default: '{}' }
|
additionalData: { type: String, default: '{}' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static and instance methods can go here
|
// Static and instance methods can go here
|
||||||
data_get(key) {
|
data_get(key) {
|
||||||
return JSON.parse(this.additionalData ? this.additionalData : '{}')[key]
|
return JSON.parse(this.additionalData ? this.additionalData : '{}')[key]
|
||||||
@ -40,7 +41,9 @@ class ColumnDef extends Model {
|
|||||||
uuid: this.UUID,
|
uuid: this.UUID,
|
||||||
database_id: this.DatabaseId,
|
database_id: this.DatabaseId,
|
||||||
type: this.Type,
|
type: this.Type,
|
||||||
metadata: this.data()
|
metadata: this.data(),
|
||||||
|
version_num: this.version_num,
|
||||||
|
version_message: this.version_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,20 @@ class Database extends VersionedModel {
|
|||||||
version_message: this.version_message,
|
version_message: this.version_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cast_to_version_data() {
|
||||||
|
const data = await super.cast_to_version_data()
|
||||||
|
const cols = await this.get_columns()
|
||||||
|
|
||||||
|
data.column_version_nums = cols.map(x => {
|
||||||
|
return {
|
||||||
|
ColumnId: x.UUID,
|
||||||
|
version_num: x.version_num,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = exports = Database
|
module.exports = exports = Database
|
||||||
|
Loading…
Reference in New Issue
Block a user