From 13b9db1e4c8522ea25f0db9ea32686317bf05caa Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 2 Mar 2021 16:46:41 +0100 Subject: [PATCH] Update conversation messages table --- docs/db_struct.sql | 17 +++++++++++------ docs/migration.sql | 12 +++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/db_struct.sql b/docs/db_struct.sql index f34675d..09fee3f 100644 --- a/docs/db_struct.sql +++ b/docs/db_struct.sql @@ -73,16 +73,21 @@ CREATE TABLE `comunic_conversations_list` ( DROP TABLE IF EXISTS `comunic_conversations_messages`; CREATE TABLE `comunic_conversations_messages` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `conv_id` int(11) DEFAULT NULL, - `user_id` int(11) DEFAULT NULL, - `time_insert` int(11) DEFAULT NULL, - `message` varchar(200) DEFAULT NULL, - `image_path` varchar(100) DEFAULT NULL, + `id` int NOT NULL AUTO_INCREMENT, + `conv_id` int DEFAULT NULL, + `user_id` int DEFAULT NULL, + `time_sent` int DEFAULT NULL, + `message` text, + `filepath` varchar(255) DEFAULT NULL, + `file_size` int DEFAULT NULL, + `file_name` varchar(255) DEFAULT NULL, + `file_thumbnail` varchar(255) DEFAULT NULL, + `file_type` varchar(128) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; + DROP TABLE IF EXISTS `comunic_conversations_users`; CREATE TABLE `comunic_conversations_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, diff --git a/docs/migration.sql b/docs/migration.sql index 105f2e9..a2229cf 100644 --- a/docs/migration.sql +++ b/docs/migration.sql @@ -1 +1,11 @@ --- Nothing yet \ No newline at end of file +-- Conversations table +alter table comunic_conversations_messages rename column time_insert to time_sent; +alter table comunic_conversations_messages modify message TEXT; +alter table comunic_conversations_messages + add column filepath varchar(255) default null, + add column file_size int default null, + add column file_name varchar(255) default null, + add column file_thumbnail varchar(255) default null, + add column file_type varchar(128) default null; +update comunic_conversations_messages set filepath = image_path, file_size = 10, file_type = "image/png", file_name = "image.png" where image_path is not null and id >= 1; +alter table comunic_conversations_messages drop column image_path; \ No newline at end of file