Fix rounding in thread messages that only contain an ID
Internally, the thread_messages table's body column's type was undefined in sqlite. This is because it was set to mediumtext, but sqlite doesn't have that type. Because of that, sqlite treated the column as a numeric column. Sqlite also allows storing text data in numeric columns (because reasons), so in most cases everything worked fine. It was only when storing an actual number, like an ID, that it was also *treated* as a number. And since snowflake IDs are larger than the maximum safe integer in JavaScript, the stored ID could get rounded when retrieving data from the database.cshd
parent
5b0f9d31b7
commit
192fec6952
|
@ -0,0 +1,19 @@
|
|||
exports.up = async function(knex) {
|
||||
await knex.schema.table("thread_messages", table => {
|
||||
table.text("temp_body");
|
||||
});
|
||||
|
||||
await knex.raw("UPDATE thread_messages SET temp_body = body");
|
||||
|
||||
await knex.schema.table("thread_messages", table => {
|
||||
table.dropColumn("body");
|
||||
});
|
||||
|
||||
await knex.schema.table("thread_messages", table => {
|
||||
table.renameColumn("temp_body", "body");
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = async function(knex) {
|
||||
|
||||
};
|
Loading…
Reference in New Issue