Browse Source

blog_posts table shcema toinstall action

Vova Tkach 6 years ago
parent
commit
d48992d6b0
1 changed files with 23 additions and 0 deletions
  1. 23 0
      modules/module_index.go

+ 23 - 0
modules/module_index.go

@@ -538,6 +538,29 @@ func (this *Modules) RegisterAction_IndexMysqlSetup() *Action {
 			wrap.MsgError(err.Error())
 			return
 		}
+		_, err = db.Query(fmt.Sprintf(
+			`CREATE TABLE %s.blog_posts (
+				id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',
+				user int(11) NOT NULL COMMENT 'User id',
+				name varchar(255) NOT NULL COMMENT 'Post name',
+				alias varchar(255) NOT NULL COMMENT 'Post alias',
+				content text NOT NULL COMMENT 'Post content',
+				datetime datetime NOT NULL COMMENT 'Creation date/time',
+				active int(1) NOT NULL COMMENT 'Is active post or not',
+				PRIMARY KEY (id)
+			) ENGINE=InnoDB DEFAULT CHARSET=utf8;`,
+			pf_name))
+		if err != nil {
+			wrap.MsgError(err.Error())
+			return
+		}
+		_, err = db.Query(fmt.Sprintf(
+			`ALTER TABLE %s.blog_posts ADD UNIQUE KEY alias (alias);`,
+			pf_name))
+		if err != nil {
+			wrap.MsgError(err.Error())
+			return
+		}
 		_, err = db.Query(fmt.Sprintf(
 			`CREATE TABLE %s.blog_cats (
 				id int(11) NOT NULL AUTO_INCREMENT COMMENT 'AI',