Fix thread alert_id being limited to 20 chars on MySQL
parent
47125fd7fd
commit
fdabf65882
|
@ -0,0 +1,21 @@
|
||||||
|
exports.up = async function(knex) {
|
||||||
|
await knex.schema.table("threads", table => {
|
||||||
|
table.text("alert_ids").nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex("threads")
|
||||||
|
.update({
|
||||||
|
alert_ids: knex.raw("alert_id"),
|
||||||
|
});
|
||||||
|
|
||||||
|
await knex.schema.table("threads", table => {
|
||||||
|
table.dropColumn("alert_id");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async function(knex) {
|
||||||
|
await knex.schema.table("threads", table => {
|
||||||
|
table.dropColumn("alert_ids");
|
||||||
|
table.text("alert_id").nullable();
|
||||||
|
});
|
||||||
|
};
|
|
@ -23,7 +23,7 @@ const {THREAD_MESSAGE_TYPE, THREAD_STATUS, DISCORD_MESSAGE_ACTIVITY_TYPES} = req
|
||||||
* @property {String} scheduled_close_id
|
* @property {String} scheduled_close_id
|
||||||
* @property {String} scheduled_close_name
|
* @property {String} scheduled_close_name
|
||||||
* @property {Number} scheduled_close_silent
|
* @property {Number} scheduled_close_silent
|
||||||
* @property {String} alert_id
|
* @property {String} alert_ids
|
||||||
* @property {String} created_at
|
* @property {String} created_at
|
||||||
*/
|
*/
|
||||||
class Thread {
|
class Thread {
|
||||||
|
@ -334,8 +334,8 @@ class Thread {
|
||||||
await this.postSystemMessage(`<@!${this.scheduled_close_id}> Thread that was scheduled to be closed got a new reply. Cancelling.`);
|
await this.postSystemMessage(`<@!${this.scheduled_close_id}> Thread that was scheduled to be closed got a new reply. Cancelling.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.alert_id) {
|
if (this.alert_ids) {
|
||||||
const ids = this.alert_id.split(",");
|
const ids = this.alert_ids.split(",");
|
||||||
let mentions = "";
|
let mentions = "";
|
||||||
|
|
||||||
ids.forEach(id => {
|
ids.forEach(id => {
|
||||||
|
@ -604,9 +604,9 @@ class Thread {
|
||||||
async addAlert(userId) {
|
async addAlert(userId) {
|
||||||
let alerts = await knex("threads")
|
let alerts = await knex("threads")
|
||||||
.where("id", this.id)
|
.where("id", this.id)
|
||||||
.select("alert_id")
|
.select("alert_ids")
|
||||||
.first();
|
.first();
|
||||||
alerts = alerts.alert_id;
|
alerts = alerts.alert_ids;
|
||||||
|
|
||||||
if (alerts == null) {
|
if (alerts == null) {
|
||||||
alerts = [userId]
|
alerts = [userId]
|
||||||
|
@ -621,7 +621,7 @@ class Thread {
|
||||||
await knex("threads")
|
await knex("threads")
|
||||||
.where("id", this.id)
|
.where("id", this.id)
|
||||||
.update({
|
.update({
|
||||||
alert_id: alerts
|
alert_ids: alerts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -632,9 +632,9 @@ class Thread {
|
||||||
async removeAlert(userId) {
|
async removeAlert(userId) {
|
||||||
let alerts = await knex("threads")
|
let alerts = await knex("threads")
|
||||||
.where("id", this.id)
|
.where("id", this.id)
|
||||||
.select("alert_id")
|
.select("alert_ids")
|
||||||
.first();
|
.first();
|
||||||
alerts = alerts.alert_id;
|
alerts = alerts.alert_ids;
|
||||||
|
|
||||||
if (alerts != null) {
|
if (alerts != null) {
|
||||||
alerts = alerts.split(",");
|
alerts = alerts.split(",");
|
||||||
|
@ -657,7 +657,7 @@ class Thread {
|
||||||
await knex("threads")
|
await knex("threads")
|
||||||
.where("id", this.id)
|
.where("id", this.id)
|
||||||
.update({
|
.update({
|
||||||
alert_id: alerts
|
alert_ids: alerts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ class Thread {
|
||||||
await knex("threads")
|
await knex("threads")
|
||||||
.where("id", this.id)
|
.where("id", this.id)
|
||||||
.update({
|
.update({
|
||||||
alert_id: null
|
alert_ids: null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue