Browse Source

Merge pull request #793 from Arantor/release-2.1

! Database stuff for likes, just to get it out the way really.
Arantor 11 years ago
parent
commit
6b0e1050df

+ 15 - 0
other/install_2-1_mysql.sql

@@ -1369,6 +1369,7 @@ CREATE TABLE {$db_prefix}messages (
   body text NOT NULL,
   icon varchar(16) NOT NULL default 'xx',
   approved tinyint(3) NOT NULL default '1',
+  likes smallint(5) unsigned NOT NULL default '0',
   PRIMARY KEY (id_msg),
   UNIQUE topic (id_topic, id_msg),
   UNIQUE id_board (id_board, id_msg),
@@ -2106,3 +2107,17 @@ CREATE TABLE {$db_prefix}user_drafts (
   PRIMARY KEY (id_draft),
   UNIQUE id_member (id_member, id_draft, type)
 ) ENGINE=MyISAM;
+
+#
+# Table structure for table `user_likes`
+#
+
+CREATE TABLE {$db_prefix}user_likes (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int(10) unsigned NOT NULL default '0',
+  like_time int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member),
+  INDEX content (content_id, content_type),
+  INDEX liker (id_member)
+) ENGINE=MyISAM;

+ 20 - 0
other/install_2-1_postgresql.sql

@@ -1798,6 +1798,7 @@ CREATE TABLE {$db_prefix}messages (
   body text NOT NULL,
   icon varchar(16) NOT NULL default 'xx',
   approved smallint NOT NULL default '1',
+  likes smallint NOT NULL default '0',
   PRIMARY KEY (id_msg)
 );
 
@@ -2650,3 +2651,22 @@ CREATE TABLE {$db_prefix}user_drafts (
 #
 
 CREATE UNIQUE INDEX {$db_prefix}user_drafts_id_member ON {$db_prefix}user_drafts (id_member, id_draft, type);
+
+#
+# Table structure for table `user_likes`
+#
+
+CREATE TABLE {$db_prefix}user_likes (
+  id_member int NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int NOT NULL default '0',
+  like_time int NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member)
+);
+
+#
+# Indexes for table `user_likes`
+#
+
+CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
+CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);

+ 21 - 1
other/install_2-1_sqlite.sql

@@ -1485,7 +1485,8 @@ CREATE TABLE {$db_prefix}messages (
   modified_name varchar(255) NOT NULL,
   body text NOT NULL,
   icon varchar(16) NOT NULL default 'xx',
-  approved smallint NOT NULL default '1'
+  approved smallint NOT NULL default '1',
+  likes smallint NOT NULL default '0'
 );
 
 #
@@ -2270,3 +2271,22 @@ CREATE TABLE {$db_prefix}user_drafts (
 #
 
 CREATE UNIQUE INDEX {$db_prefix}user_drafts_id_member ON {$db_prefix}user_drafts (id_member, id_draft, type);
+
+#
+# Table structure for table `user_likes`
+#
+
+CREATE TABLE {$db_prefix}user_likes (
+  id_member int NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int NOT NULL default '0',
+  like_time int NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member)
+);
+
+#
+# Indexes for table `user_likes`
+#
+
+CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
+CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);

+ 21 - 1
other/install_2-1_sqlite3.sql

@@ -1485,7 +1485,8 @@ CREATE TABLE {$db_prefix}messages (
   modified_name varchar(255) NOT NULL,
   body text NOT NULL,
   icon varchar(16) NOT NULL default 'xx',
-  approved smallint NOT NULL default '1'
+  approved smallint NOT NULL default '1',
+  likes smallint NOT NULL default '0'
 );
 
 #
@@ -2270,3 +2271,22 @@ CREATE TABLE {$db_prefix}user_drafts (
 #
 
 CREATE UNIQUE INDEX {$db_prefix}user_drafts_id_member ON {$db_prefix}user_drafts (id_member, id_draft, type);
+
+#
+# Table structure for table `user_likes`
+#
+
+CREATE TABLE {$db_prefix}user_likes (
+  id_member int NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int NOT NULL default '0',
+  like_time int NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member)
+);
+
+#
+# Indexes for table `user_likes`
+#
+
+CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
+CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);

+ 20 - 0
other/upgrade_2-1_mysql.sql

@@ -405,6 +405,26 @@ VALUES
 	('1', 'drafts_show_saved_enabled', '1');
 ---#
 
+/******************************************************************************/
+--- Adding support for likes
+/******************************************************************************/
+---# Creating likes table.
+CREATE TABLE IF NOT EXISTS {$db_prefix}user_likes (
+  id_member mediumint(8) unsigned NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int(10) unsigned NOT NULL default '0',
+  like_time int(10) unsigned NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member),
+  INDEX content (content_id, content_type),
+  INDEX liker (id_member)
+) ENGINE=MyISAM;
+---#
+
+---# Adding count to the messages table.
+ALTER TABLE {$db_prefix}messages
+ADD COLUMN likes smallint(5) unsigned NOT NULL DEFAULT '0';
+---#
+
 /******************************************************************************/
 --- Adding support for group-based board moderation
 /******************************************************************************/

+ 21 - 0
other/upgrade_2-1_postgresql.sql

@@ -467,6 +467,27 @@ INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_
 INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_show_saved_enabled', '1');
 ---#
 
+/******************************************************************************/
+--- Adding support for likes
+/******************************************************************************/
+---# Creating likes table.
+CREATE TABLE IF NOT EXISTS {$db_prefix}user_likes (
+  id_member int NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int NOT NULL default '0',
+  like_time int NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member)
+);
+
+CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
+CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);
+---#
+
+---# Adding count to the messages table.
+ALTER TABLE {$db_prefix}messages
+ADD COLUMN likes smallint NOT NULL default '0';
+---#
+
 /******************************************************************************/
 --- Adding support for group-based board moderation
 /******************************************************************************/

+ 21 - 0
other/upgrade_2-1_sqlite.sql

@@ -457,6 +457,27 @@ INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_
 INSERT INTO {$db_prefix}themes (id_theme, variable, value) VALUES ('1', 'drafts_show_saved_enabled', '1');
 ---#
 
+/******************************************************************************/
+--- Adding support for likes
+/******************************************************************************/
+---# Creating likes table.
+CREATE TABLE IF NOT EXISTS {$db_prefix}user_likes (
+  id_member int NOT NULL default '0',
+  content_type char(6) default '',
+  content_id int NOT NULL default '0',
+  like_time int NOT NULL default '0',
+  PRIMARY KEY (content_id, content_type, id_member)
+);
+
+CREATE INDEX {$db_prefix}user_likes_content ON {$db_prefix}user_likes (content_id, content_type);
+CREATE INDEX {$db_prefix}user_likes_liker ON {$db_prefix}user_likes (id_member);
+---#
+
+---# Adding count to the messages table.
+ALTER TABLE {$db_prefix}messages
+ADD COLUMN likes smallint NOT NULL default '0';
+---#
+
 /******************************************************************************/
 --- Adding support for group-based board moderation
 /******************************************************************************/