summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdo Walter2019-03-15 17:41:13 +0100
committerUdo Walter2019-03-15 17:41:13 +0100
commit8d1e3f99946d06588d9aca682c1ce85ce4b32e16 (patch)
tree73b735c783731a78afd2d82fbe83fe2121c0b666
parent[server/registration] Add log to the first registration. (diff)
downloadbas-8d1e3f99946d06588d9aca682c1ce85ce4b32e16.tar.gz
bas-8d1e3f99946d06588d9aca682c1ce85ce4b32e16.tar.xz
bas-8d1e3f99946d06588d9aca682c1ce85ce4b32e16.zip
[server/log] sql JSON to TEXT for mariadb compatibility
-rw-r--r--server/lib/log.js8
-rw-r--r--server/migrations/20190304043012-create-log.js8
-rw-r--r--server/models/log.js8
3 files changed, 12 insertions, 12 deletions
diff --git a/server/lib/log.js b/server/lib/log.js
index 1f214c5..3b5dcd3 100644
--- a/server/lib/log.js
+++ b/server/lib/log.js
@@ -11,11 +11,11 @@ async function log ({ category, description, groupId, clientId, userId }) {
clientId,
userId
})
- if (groupId) entry.groupSnapshot = await db.group.findOne({ where: { id: groupId } })
- if (clientId) entry.clientSnapshot = await db.client.findOne({ where: { id: clientId } })
- if (userId) entry.userSnapshot = await db.user.findOne({ where: { id: userId } })
+ if (groupId) entry.groupSnapshot = JSON.stringify(await db.group.findOne({ where: { id: groupId }}))
+ if (clientId) entry.clientSnapshot = JSON.stringify(await db.client.findOne({ where: { id: clientId }}))
+ if (userId) entry.userSnapshot = JSON.stringify(await db.user.findOne({ where: { id: userId }}))
await entry.save()
return entry
}
-module.exports = log
+module.exports = log \ No newline at end of file
diff --git a/server/migrations/20190304043012-create-log.js b/server/migrations/20190304043012-create-log.js
index a7f9c25..6ffff4c 100644
--- a/server/migrations/20190304043012-create-log.js
+++ b/server/migrations/20190304043012-create-log.js
@@ -15,7 +15,7 @@ module.exports = {
type: Sequelize.STRING
},
description: {
- type: Sequelize.STRING(2048)
+ type: Sequelize.TEXT
},
groupId: {
type: Sequelize.INTEGER,
@@ -26,7 +26,7 @@ module.exports = {
}
},
groupSnapshot: {
- type: Sequelize.JSON
+ type: Sequelize.TEXT
},
clientId: {
type: Sequelize.INTEGER,
@@ -37,7 +37,7 @@ module.exports = {
}
},
clientSnapshot: {
- type: Sequelize.JSON
+ type: Sequelize.TEXT
},
userId: {
type: Sequelize.INTEGER,
@@ -48,7 +48,7 @@ module.exports = {
}
},
userSnapshot: {
- type: Sequelize.JSON
+ type: Sequelize.TEXT
}
})
},
diff --git a/server/models/log.js b/server/models/log.js
index 36fdf20..b003397 100644
--- a/server/models/log.js
+++ b/server/models/log.js
@@ -9,10 +9,10 @@ module.exports = (sequelize, DataTypes) => {
},
timestamp: DataTypes.BIGINT,
category: DataTypes.STRING,
- description: DataTypes.STRING(2048),
- groupSnapshot: DataTypes.JSON,
- clientSnapshot: DataTypes.JSON,
- userSnapshot: DataTypes.JSON
+ description: DataTypes.TEXT,
+ groupSnapshot: DataTypes.TEXT,
+ clientSnapshot: DataTypes.TEXT,
+ userSnapshot: DataTypes.TEXT
}, {
timestamps: false,
freezeTableName: true