dracidoupe / graveyard

Open Source reimplementation of https://www.dracidoupe.cz/
https://nove.dracidoupe.cz/
MIT License
6 stars 4 forks source link

Fix reputation migrations #307

Closed Almad closed 3 years ago

Almad commented 3 years ago

In #288, migrations actually altered table instead of only renaming model fields and leaving the underlying db_column intact.

This should be fixed so that old version works until migration.

Almad commented 3 years ago

OK, this is more tricky than it looks like! The fields were not, in fact, renamed. But there was an alter table that was run:


mysql> describe reputace_log; 
+--------------+--------------+------+-----+---------+----------------+
| Field        | Type         | Null | Key | Default | Extra          |
+--------------+--------------+------+-----+---------+----------------+
| id_zaznamu   | int unsigned | NO   | PRI | NULL    | auto_increment |
| dal          | varchar(30)  | NO   |     |         |                |
| prijal       | varchar(30)  | NO   |     |         |                |
| akce         | char(3)      | NO   |     |         |                |
| v_diskuzi    | varchar(1)   | YES  |     | NULL    |                |
| id_prispevku | int unsigned | YES  |     | NULL    |                |
| date         | int          | NO   |     | 1       |                |
+--------------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql> 

mysql> describe reputace_log;
+--------------+---------------------------+------+-----+---------+----------------+
| Field        | Type                      | Null | Key | Default | Extra          |
+--------------+---------------------------+------+-----+---------+----------------+
| id_zaznamu   | int unsigned              | NO   | PRI | NULL    | auto_increment |
| dal          | varchar(30)               | NO   |     |         |                |
| prijal       | varchar(30)               | NO   |     |         |                |
| akce         | char(3)                   | NO   |     |         |                |
| v_diskusi    | enum('a','n','z','s','f') | YES  |     | NULL    |                |
| id_prispevku | int unsigned              | YES  |     | NULL    |                |
| date         | int                       | NO   |     | 1       |                |
+--------------+---------------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql> 

Now I don't know why that causes issues, but it does 🤔

Almad commented 3 years ago

Possibly related to enum gotchas: http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

Almad commented 3 years ago

OK no, I am blind. The problem is v_diskuzi vs v_diskusi 🤦