Track database column versions and include in database version data
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

This commit is contained in:
Garrett Mills 2020-11-02 16:04:45 -06:00
parent 9398c827ed
commit 14babd5b8b
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246
3 changed files with 23 additions and 6 deletions

View File

@ -163,7 +163,7 @@ class FormDatabase extends Controller {
assoc_columns[col.UUID].DatabaseId = db.UUID
assoc_columns[col.UUID].Type = col.Type
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])
} else {
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)
}
}

View File

@ -1,4 +1,4 @@
const Model = require('flitter-orm/src/model/Model')
const VersionedModel = require('../../VersionedModel')
const uuid = require('uuid/v4')
/*
@ -6,10 +6,11 @@ const uuid = require('uuid/v4')
* -------------------------------------------------------------
* Put some description here!
*/
class ColumnDef extends Model {
class ColumnDef extends VersionedModel {
static get schema() {
// Return a flitter-orm schema here.
return {
...super.schema,
headerName: String,
field: String,
DatabaseId: String,
@ -40,7 +41,9 @@ class ColumnDef extends Model {
uuid: this.UUID,
database_id: this.DatabaseId,
type: this.Type,
metadata: this.data()
metadata: this.data(),
version_num: this.version_num,
version_message: this.version_message,
}
}
}

View File

@ -66,6 +66,20 @@ class Database extends VersionedModel {
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