From 9f2c1b25560487c7c067614098aa2e0773ce17b8 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 20 Nov 2024 20:35:03 +0800 Subject: [PATCH] chore: tweak reaction_type column type for mysql --- store/migration/mysql/dev/LATEST.sql | 2 +- store/migration/mysql/prod/0.23/00__reactions.sql | 4 ++++ store/migration/mysql/prod/LATEST.sql | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/store/migration/mysql/dev/LATEST.sql b/store/migration/mysql/dev/LATEST.sql index 3a3fb7d0..4191e7dc 100644 --- a/store/migration/mysql/dev/LATEST.sql +++ b/store/migration/mysql/dev/LATEST.sql @@ -127,6 +127,6 @@ CREATE TABLE `reaction` ( `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `creator_id` INT NOT NULL, `content_id` VARCHAR(256) NOT NULL, - `reaction_type` VARCHAR(256) NOT NULL, + `reaction_type` TINYTEXT NOT NULL, UNIQUE(`creator_id`,`content_id`,`reaction_type`) ); diff --git a/store/migration/mysql/prod/0.23/00__reactions.sql b/store/migration/mysql/prod/0.23/00__reactions.sql index 13979d15..8220ad0d 100644 --- a/store/migration/mysql/prod/0.23/00__reactions.sql +++ b/store/migration/mysql/prod/0.23/00__reactions.sql @@ -1,3 +1,7 @@ +-- modify reaction_type to be a TINYTEXT instead of varchar(256). +ALTER TABLE `reaction` MODIFY `reaction_type` TINYTEXT NOT NULL; + +-- update reaction_type to emoji. UPDATE `reaction` SET `reaction_type` = '👍' WHERE `reaction_type` = 'THUMBS_UP'; UPDATE `reaction` SET `reaction_type` = '👎' WHERE `reaction_type` = 'THUMBS_DOWN'; UPDATE `reaction` SET `reaction_type` = '💛' WHERE `reaction_type` = 'HEART'; diff --git a/store/migration/mysql/prod/LATEST.sql b/store/migration/mysql/prod/LATEST.sql index 3a3fb7d0..4191e7dc 100644 --- a/store/migration/mysql/prod/LATEST.sql +++ b/store/migration/mysql/prod/LATEST.sql @@ -127,6 +127,6 @@ CREATE TABLE `reaction` ( `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `creator_id` INT NOT NULL, `content_id` VARCHAR(256) NOT NULL, - `reaction_type` VARCHAR(256) NOT NULL, + `reaction_type` TINYTEXT NOT NULL, UNIQUE(`creator_id`,`content_id`,`reaction_type`) );