A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
feat: remove database field comments for support multiple databases
LinkinStarcb03804f09b5
diff --git a/internal/entity/activity_entity.go b/internal/entity/activity_entity.goindex 7ae96889..644db176 100644--- a/internal/entity/activity_entity.go+++ b/internal/entity/activity_entity.go@@ -9,16 +9,16 @@ const (// Activity activitytype Activity struct {- ID string `xorm:"not null pk autoincr comment('activity id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null comment('the user ID that generated the activity or affected by the activity') index BIGINT(20) user_id"`- TriggerUserID int64 `xorm:"not null default 0 comment('the trigger user ID that generated the activity or affected by the activity') index BIGINT(20) trigger_user_id"`- ObjectID string `xorm:"not null default 0 comment('the object ID that affected by the activity') index BIGINT(20) object_id"`- ActivityType int `xorm:"not null comment('activity type, correspond to config id') INT(11) activity_type"`- Cancelled int `xorm:"not null default 0 comment('mark this activity if cancelled or not,default 0(not cancelled)') TINYINT(4) cancelled"`- Rank int `xorm:"not null default 0 comment('rank of current operating user affected') INT(11) rank"`- HasRank int `xorm:"not null default 0 comment('this activity has rank or not') TINYINT(4) has_rank"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ UserID string `xorm:"not null index BIGINT(20) user_id"`+ TriggerUserID int64 `xorm:"not null default 0 index BIGINT(20) trigger_user_id"`+ ObjectID string `xorm:"not null default 0 index BIGINT(20) object_id"`+ ActivityType int `xorm:"not null INT(11) activity_type"`+ Cancelled int `xorm:"not null default 0 TINYINT(4) cancelled"`+ Rank int `xorm:"not null default 0 INT(11) rank"`+ HasRank int `xorm:"not null default 0 TINYINT(4) has_rank"`}type ActivityRunkSum struct {diff --git a/internal/entity/answer_entity.go b/internal/entity/answer_entity.goindex bf828470..3666f106 100644--- a/internal/entity/answer_entity.go+++ b/internal/entity/answer_entity.go@@ -18,18 +18,18 @@ var CmsAnswerSearchStatus = map[string]int{// Answer answertype Answer struct {- ID string `xorm:"not null pk autoincr comment('answer id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP comment('update time') TIMESTAMP updated_at"`- QuestionID string `xorm:"not null default 0 comment('question id') BIGINT(20) question_id"`- UserID string `xorm:"not null default 0 comment('answer user id') BIGINT(20) INDEX user_id"`- OriginalText string `xorm:"not null comment('original text') MEDIUMTEXT original_text"`- ParsedText string `xorm:"not null comment('parsed text') MEDIUMTEXT parsed_text"`- Status int `xorm:"not null default 1 comment('answer status(available: 1; deleted: 10)') INT(11) status"`- Adopted int `xorm:"not null default 1 comment('adopted (1 failed 2 adopted)') INT(11) adopted"`- CommentCount int `xorm:"not null default 0 comment('comment count') INT(11) comment_count"`- VoteCount int `xorm:"not null default 0 comment('vote count') INT(11) vote_count"`- RevisionID string `xorm:"not null default 0 comment('revision id') BIGINT(20) revision_id"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`+ QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`+ UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`+ OriginalText string `xorm:"not null MEDIUMTEXT original_text"`+ ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`+ Status int `xorm:"not null default 1 INT(11) status"`+ Adopted int `xorm:"not null default 1 INT(11) adopted"`+ CommentCount int `xorm:"not null default 0 INT(11) comment_count"`+ VoteCount int `xorm:"not null default 0 INT(11) vote_count"`+ RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`}type AnswerSearch struct {diff --git a/internal/entity/collection_entity.go b/internal/entity/collection_entity.goindex 4ade11e9..c37c1234 100644--- a/internal/entity/collection_entity.go+++ b/internal/entity/collection_entity.go@@ -4,12 +4,12 @@ import "time"// Collection collectiontype Collection struct {- ID string `xorm:"not null pk default 0 comment('collection id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP comment('created time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP comment('updated time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 comment('user id') BIGINT(20) INDEX user_id"`- ObjectID string `xorm:"not null default 0 comment('object id') BIGINT(20) object_id"`- UserCollectionGroupID string `xorm:"not null default 0 comment('user collection group id') BIGINT(20) user_collection_group_id"`+ ID string `xorm:"not null pk default 0 BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`+ ObjectID string `xorm:"not null default 0 BIGINT(20) object_id"`+ UserCollectionGroupID string `xorm:"not null default 0 BIGINT(20) user_collection_group_id"`}type CollectionSearch struct {diff --git a/internal/entity/collection_group_entity.go b/internal/entity/collection_group_entity.goindex 7c9b5d69..cbb860db 100644--- a/internal/entity/collection_group_entity.go+++ b/internal/entity/collection_group_entity.go@@ -4,12 +4,12 @@ import "time"// CollectionGroup collection grouptype CollectionGroup struct {- ID string `xorm:"not null pk autoincr comment('id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP comment('created time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP comment('updated time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 BIGINT(20) comment('user id') INDEX user_id"`- Name string `xorm:"not null default '' comment('the collection group name') VARCHAR(50) name"`- DefaultGroup int `xorm:"not null default 1 comment('mark this group is default, default 1') INT(11) default_group"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`+ Name string `xorm:"not null default '' VARCHAR(50) name"`+ DefaultGroup int `xorm:"not null default 1 INT(11) default_group"`}// TableName collection group table namediff --git a/internal/entity/comment_entity.go b/internal/entity/comment_entity.goindex caebc6c9..e657826d 100644--- a/internal/entity/comment_entity.go+++ b/internal/entity/comment_entity.go@@ -15,18 +15,18 @@ const (// Comment commenttype Comment struct {- ID string `xorm:"not null pk autoincr comment('comment id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 comment('user id') BIGINT(20) user_id"`- ReplyUserID sql.NullInt64 `xorm:"comment('reply user id') BIGINT(20) reply_user_id"`- ReplyCommentID sql.NullInt64 `xorm:"comment('reply comment id') BIGINT(20) reply_comment_id"`- ObjectID string `xorm:"not null default 0 comment('object id') BIGINT(20) INDEX object_id"`- QuestionID string `xorm:"not null default 0 comment('question id') BIGINT(20) question_id"`- VoteCount int `xorm:"not null default 0 comment('user vote amount') INT(11) vote_count"`- Status int `xorm:"not null default 0 comment('comment status(available: 1; deleted: 10)') TINYINT(4) status"`- OriginalText string `xorm:"not null comment('original comment content') MEDIUMTEXT original_text"`- ParsedText string `xorm:"not null comment('parsed comment content') MEDIUMTEXT parsed_text"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) user_id"`+ ReplyUserID sql.NullInt64 `xorm:"BIGINT(20) reply_user_id"`+ ReplyCommentID sql.NullInt64 `xorm:"BIGINT(20) reply_comment_id"`+ ObjectID string `xorm:"not null default 0 BIGINT(20) INDEX object_id"`+ QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`+ VoteCount int `xorm:"not null default 0 INT(11) vote_count"`+ Status int `xorm:"not null default 0 TINYINT(4) status"`+ OriginalText string `xorm:"not null MEDIUMTEXT original_text"`+ ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`}// TableName comment table namediff --git a/internal/entity/config_entity.go b/internal/entity/config_entity.goindex f50a4182..1d716a2d 100644--- a/internal/entity/config_entity.go+++ b/internal/entity/config_entity.go@@ -2,9 +2,9 @@ package entity// Config configtype Config struct {- ID int `xorm:"not null pk autoincr comment('config id') INT(11) id"`- Key string `xorm:"comment('the config key') unique VARCHAR(32) key"`- Value string `xorm:"comment('the config value, custom data structures and types') TEXT value"`+ ID int `xorm:"not null pk autoincr INT(11) id"`+ Key string `xorm:"unique VARCHAR(32) key"`+ Value string `xorm:"TEXT value"`}// TableName config table namediff --git a/internal/entity/meta_entity.go b/internal/entity/meta_entity.goindex 2ab3e5e3..17ff3832 100644--- a/internal/entity/meta_entity.go+++ b/internal/entity/meta_entity.go@@ -11,12 +11,12 @@ const (// Meta metatype Meta struct {- ID int `xorm:"not null pk autoincr comment('id') INT(10) id"`- CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP created comment('created time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP updated comment('updated time') TIMESTAMP updated_at"`- ObjectID string `xorm:"not null default 0 comment('object id') INDEX BIGINT(20) object_id"`- Key string `xorm:"not null comment('key') VARCHAR(100) key"`- Value string `xorm:"not null comment('value') MEDIUMTEXT value"`+ ID int `xorm:"not null pk autoincr INT(10) id"`+ CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP updated TIMESTAMP updated_at"`+ ObjectID string `xorm:"not null default 0 INDEX BIGINT(20) object_id"`+ Key string `xorm:"not null VARCHAR(100) key"`+ Value string `xorm:"not null MEDIUMTEXT value"`}// TableName meta table namediff --git a/internal/entity/notification_entity.go b/internal/entity/notification_entity.goindex 4fb18ad2..d16fa06a 100644--- a/internal/entity/notification_entity.go+++ b/internal/entity/notification_entity.go@@ -4,15 +4,15 @@ import "time"// Notification notificationtype Notification struct {- ID string `xorm:"not null pk autoincr comment('notification id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 comment('user id') BIGINT(20) INDEX user_id"`- ObjectID string `xorm:"not null default 0 comment('object id') INDEX BIGINT(20) object_id"`- Content string `xorm:"not null comment('notification content') TEXT content"`- Type int `xorm:"not null default 0 comment('notification type(1:inbox; 2:achievement)') INT(11) type"`- IsRead int `xorm:"not null default 1 comment('read status(unread: 1; read 2)') INT(11) is_read"`- Status int `xorm:"not null default 1 comment('notification status(normal: 1; delete 2)') INT(11) status"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`+ ObjectID string `xorm:"not null default 0 INDEX BIGINT(20) object_id"`+ Content string `xorm:"not null TEXT content"`+ Type int `xorm:"not null default 0 INT(11) type"`+ IsRead int `xorm:"not null default 1 INT(11) is_read"`+ Status int `xorm:"not null default 1 INT(11) status"`}// TableName notification table namediff --git a/internal/entity/question_entity.go b/internal/entity/question_entity.goindex c434ca8c..83de9520 100644--- a/internal/entity/question_entity.go+++ b/internal/entity/question_entity.go@@ -29,24 +29,24 @@ type QuestionTag struct {// Question questiontype Question struct {- ID string `xorm:"not null pk comment('question id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 comment('user id') BIGINT(20) INDEX user_id"`- Title string `xorm:"not null default '' comment('question title') VARCHAR(150) title"`- OriginalText string `xorm:"not null comment('original text') MEDIUMTEXT original_text"`- ParsedText string `xorm:"not null comment('parsed text') MEDIUMTEXT parsed_text"`- Status int `xorm:"not null default 1 comment('question status(available: 1; deleted: 10)') INT(11) status"`- ViewCount int `xorm:"not null default 0 comment('view count') INT(11) view_count"`- UniqueViewCount int `xorm:"not null default 0 comment('unique view count') INT(11) unique_view_count"`- VoteCount int `xorm:"not null default 0 comment('vote count') INT(11) vote_count"`- AnswerCount int `xorm:"not null default 0 comment('answer count') INT(11) answer_count"`- CollectionCount int `xorm:"not null default 0 comment('collection count') INT(11) collection_count"`- FollowCount int `xorm:"not null default 0 comment('follow count') INT(11) follow_count"`- AcceptedAnswerID string `xorm:"not null default 0 comment('accepted answer id') BIGINT(20) accepted_answer_id"`- LastAnswerID string `xorm:"not null default 0 comment('last answer id') BIGINT(20) last_answer_id"`- PostUpdateTime time.Time `xorm:"default CURRENT_TIMESTAMP comment('answer the last update time') TIMESTAMP post_update_time"`- RevisionID string `xorm:"not null default 0 comment('revision id') BIGINT(20) revision_id"`+ ID string `xorm:"not null pk BIGINT(20) id"`+ CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`+ Title string `xorm:"not null default '' VARCHAR(150) title"`+ OriginalText string `xorm:"not null MEDIUMTEXT original_text"`+ ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`+ Status int `xorm:"not null default 1 INT(11) status"`+ ViewCount int `xorm:"not null default 0 INT(11) view_count"`+ UniqueViewCount int `xorm:"not null default 0 INT(11) unique_view_count"`+ VoteCount int `xorm:"not null default 0 INT(11) vote_count"`+ AnswerCount int `xorm:"not null default 0 INT(11) answer_count"`+ CollectionCount int `xorm:"not null default 0 INT(11) collection_count"`+ FollowCount int `xorm:"not null default 0 INT(11) follow_count"`+ AcceptedAnswerID string `xorm:"not null default 0 BIGINT(20) accepted_answer_id"`+ LastAnswerID string `xorm:"not null default 0 BIGINT(20) last_answer_id"`+ PostUpdateTime time.Time `xorm:"default CURRENT_TIMESTAMP TIMESTAMP post_update_time"`+ RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`}// TableName question table namediff --git a/internal/entity/report_entity.go b/internal/entity/report_entity.goindex b4dde541..55820d26 100644--- a/internal/entity/report_entity.go+++ b/internal/entity/report_entity.go@@ -18,18 +18,18 @@ var (// Report reporttype Report struct {- ID string `xorm:"not null pk autoincr comment('id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null comment('reporter user id') BIGINT(20) user_id"`- ObjectID string `xorm:"not null comment('object id') BIGINT(20) object_id"`- ReportedUserID string `xorm:"not null default 0 comment('reported user id') BIGINT(20) reported_user_id"`- ObjectType int `xorm:"not null default 0 comment('revision type') INT(11) object_type"`- ReportType int `xorm:"not null default 0 comment('report type') INT(11) report_type"`- Content string `xorm:"not null comment('report content') TEXT content"`- FlaggedType int `xorm:"not null default 0 comment('flagged type') INT(11) flagged_type"`- FlaggedContent string `xorm:"comment('flagged content') TEXT flagged_content"`- Status int `xorm:"not null default 1 comment('status(normal: 1; pending:2; delete: 10)') INT(11) status"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ UserID string `xorm:"not null BIGINT(20) user_id"`+ ObjectID string `xorm:"not null BIGINT(20) object_id"`+ ReportedUserID string `xorm:"not null default 0 BIGINT(20) reported_user_id"`+ ObjectType int `xorm:"not null default 0 INT(11) object_type"`+ ReportType int `xorm:"not null default 0 INT(11) report_type"`+ Content string `xorm:"not null TEXT content"`+ FlaggedType int `xorm:"not null default 0 INT(11) flagged_type"`+ FlaggedContent string `xorm:"TEXT flagged_content"`+ Status int `xorm:"not null default 1 INT(11) status"`}// TableName report table namediff --git a/internal/entity/revision_entity.go b/internal/entity/revision_entity.goindex 7c811fb9..daf59a37 100644--- a/internal/entity/revision_entity.go+++ b/internal/entity/revision_entity.go@@ -4,16 +4,16 @@ import "time"// Revision revisiontype Revision struct {- ID string `xorm:"not null pk autoincr comment('id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- UserID string `xorm:"not null default 0 comment('user id') BIGINT(20) user_id"`- ObjectType int `xorm:"not null default 0 comment('revision type(question: 1; answer 2; tag 3)') INT(11) object_type"`- ObjectID string `xorm:"not null default 0 comment('object id') BIGINT(20) INDEX object_id"`- Title string `xorm:"not null default '' comment('title') VARCHAR(255) title"`- Content string `xorm:"not null comment('content') TEXT content"`- Log string `xorm:"comment('log') VARCHAR(255) log"`- Status int `xorm:"not null default 1 comment('revision status(normal: 1; delete 2)') INT(11) status"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ UserID string `xorm:"not null default 0 BIGINT(20) user_id"`+ ObjectType int `xorm:"not null default 0 ) INT(11) object_type"`+ ObjectID string `xorm:"not null default 0 BIGINT(20) INDEX object_id"`+ Title string `xorm:"not null default '' VARCHAR(255) title"`+ Content string `xorm:"not null TEXT content"`+ Log string `xorm:"VARCHAR(255) log"`+ Status int `xorm:"not null default 1 INT(11) status"`}// TableName revision table namediff --git a/internal/entity/site_info.go b/internal/entity/site_info.goindex 55a43150..0d8d29b0 100644--- a/internal/entity/site_info.go+++ b/internal/entity/site_info.go@@ -4,12 +4,12 @@ import "time"// SiteInfo site information settingtype SiteInfo struct {- ID string `xorm:"not null pk autoincr comment('id') INT(11) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- Type string `xorm:"not null comment('type') VARCHAR(64) type"`- Content string `xorm:"not null comment('content') MEDIUMTEXT content"`- Status int `xorm:"not null default 1 comment('site info status(available: 1; deleted: 10)') INT(11) status"`+ ID string `xorm:"not null pk autoincr INT(11) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ Type string `xorm:"not null VARCHAR(64) type"`+ Content string `xorm:"not null MEDIUMTEXT content"`+ Status int `xorm:"not null default 1 INT(11) status"`}// TableName table namediff --git a/internal/entity/tag_entity.go b/internal/entity/tag_entity.goindex 66f45dde..2bef34d0 100644--- a/internal/entity/tag_entity.go+++ b/internal/entity/tag_entity.go@@ -10,18 +10,18 @@ const (// Tag tagtype Tag struct {ID string `xorm:"not null pk comment('tag_id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- MainTagID int64 `xorm:"not null default 0 comment('main tag id') BIGINT(20) main_tag_id"`- MainTagSlugName string `xorm:"not null default '' comment('main tag slug name') VARCHAR(35) main_tag_slug_name"`- SlugName string `xorm:"not null default '' comment('slug name') unique VARCHAR(35) slug_name"`- DisplayName string `xorm:"not null default '' comment('display name') VARCHAR(35) display_name"`- OriginalText string `xorm:"not null comment('original comment content') MEDIUMTEXT original_text"`- ParsedText string `xorm:"not null comment('parsed comment content') MEDIUMTEXT parsed_text"`- FollowCount int `xorm:"not null default 0 comment('associated follow count') INT(11) follow_count"`- QuestionCount int `xorm:"not null default 0 comment('associated question count') INT(11) question_count"`- Status int `xorm:"not null default 1 comment('tag status(available: 1; deleted: 10)') INT(11) status"`- RevisionID string `xorm:"not null default 0 comment('revision id') BIGINT(20) revision_id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ MainTagID int64 `xorm:"not null default 0 BIGINT(20) main_tag_id"`+ MainTagSlugName string `xorm:"not null default '' VARCHAR(35) main_tag_slug_name"`+ SlugName string `xorm:"not null default '' unique VARCHAR(35) slug_name"`+ DisplayName string `xorm:"not null default '' VARCHAR(35) display_name"`+ OriginalText string `xorm:"not null MEDIUMTEXT original_text"`+ ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`+ FollowCount int `xorm:"not null default 0 INT(11) follow_count"`+ QuestionCount int `xorm:"not null default 0 INT(11) question_count"`+ Status int `xorm:"not null default 1 INT(11) status"`+ RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`}// TableName tag table namediff --git a/internal/entity/tag_rel_entity.go b/internal/entity/tag_rel_entity.goindex e66a5318..859f8bf7 100644--- a/internal/entity/tag_rel_entity.go+++ b/internal/entity/tag_rel_entity.go@@ -9,12 +9,12 @@ const (// TagRel tag relationtype TagRel struct {- ID int64 `xorm:"not null pk autoincr comment('tag_list_id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- ObjectID string `xorm:"not null comment('object_id') INDEX UNIQUE(s) BIGINT(20) object_id"`- TagID string `xorm:"not null comment('tag_id') INDEX UNIQUE(s) BIGINT(20) tag_id"`- Status int `xorm:"not null default 1 comment('tag_list_status(available: 1; deleted: 10)') INT(11) status"`+ ID int64 `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ ObjectID string `xorm:"not null INDEX UNIQUE(s) BIGINT(20) object_id"`+ TagID string `xorm:"not null INDEX UNIQUE(s) BIGINT(20) tag_id"`+ Status int `xorm:"not null default 1 INT(11) status"`}// TableName tag list table namediff --git a/internal/entity/uniqid_entity.go b/internal/entity/uniqid_entity.goindex f186b377..dd0e2e7b 100644--- a/internal/entity/uniqid_entity.go+++ b/internal/entity/uniqid_entity.go@@ -2,8 +2,8 @@ package entity// Uniqid uniqidtype Uniqid struct {- ID int64 `xorm:"not null pk autoincr comment('uniqid_id') BIGINT(20) id"`- UniqidType int `xorm:"not null default 0 comment('uniqid_type') INT(11) uniqid_type"`+ ID int64 `xorm:"not null pk autoincr BIGINT(20) id"`+ UniqidType int `xorm:"not null default 0 INT(11) uniqid_type"`}// TableName uniqid table namediff --git a/internal/entity/user_entity.go b/internal/entity/user_entity.goindex 981e5dd5..f87e651e 100644--- a/internal/entity/user_entity.go+++ b/internal/entity/user_entity.go@@ -19,32 +19,32 @@ const (// User usertype User struct {- ID string `xorm:"not null pk autoincr comment('user id') BIGINT(20) id"`- CreatedAt time.Time `xorm:"created comment('create time') TIMESTAMP created_at"`- UpdatedAt time.Time `xorm:"updated comment('update time') TIMESTAMP updated_at"`- SuspendedAt time.Time `xorm:"comment('suspended time') TIMESTAMP suspended_at"`- DeletedAt time.Time `xorm:"comment('delete time') TIMESTAMP deleted_at"`- LastLoginDate time.Time `xorm:"comment('last login date') TIMESTAMP last_login_date"`- Username string `xorm:"not null default '' comment('username') VARCHAR(50) UNIQUE username"`- Pass string `xorm:"not null default '' comment('password') VARCHAR(255) pass"`- EMail string `xorm:"not null comment('email') VARCHAR(100) e_mail"`- MailStatus int `xorm:"not null default 2 comment('mail status(1 pass 2 to be verified)') TINYINT(4) mail_status"`- NoticeStatus int `xorm:"not null default 2 comment('notice status(1 on 2off)') INT(11) notice_status"`- FollowCount int `xorm:"not null default 0 comment('follow count') INT(11) follow_count"`- AnswerCount int `xorm:"not null default 0 comment('answer count') INT(11) answer_count"`- QuestionCount int `xorm:"not null default 0 comment('question count') INT(11) question_count"`- Rank int `xorm:"not null default 0 comment('rank') INT(11) rank"`- Status int `xorm:"not null default 1 comment('user status(available: 1; deleted: 10)') INT(11) status"`- AuthorityGroup int `xorm:"not null default 1 comment('authority group') INT(11) authority_group"`- DisplayName string `xorm:"not null default '' comment('display name') VARCHAR(30) display_name"`- Avatar string `xorm:"not null default '' comment('avatar') VARCHAR(255) avatar"`- Mobile string `xorm:"not null comment('mobile') VARCHAR(20) mobile"`- Bio string `xorm:"not null comment('bio markdown') TEXT bio"`- BioHtml string `xorm:"not null comment('bio html') TEXT bio_html"`- Website string `xorm:"not null default '' comment('website') VARCHAR(255) website"`- Location string `xorm:"not null default '' comment('location') VARCHAR(100) location"`- IPInfo string `xorm:"not null default '' comment('ip info') VARCHAR(255) ip_info"`- IsAdmin bool `xorm:"not null default 0 comment('admin flag') INT(11) is_admin"`+ ID string `xorm:"not null pk autoincr BIGINT(20) id"`+ CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`+ UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`+ SuspendedAt time.Time `xorm:"TIMESTAMP suspended_at"`+ DeletedAt time.Time `xorm:"TIMESTAMP deleted_at"`+ LastLoginDate time.Time `xorm:"TIMESTAMP last_login_date"`+ Username string `xorm:"not null default '' VARCHAR(50) UNIQUE username"`+ Pass string `xorm:"not null default '' VARCHAR(255) pass"`+ EMail string `xorm:"not null VARCHAR(100) e_mail"`+ MailStatus int `xorm:"not null default 2 TINYINT(4) mail_status"`+ NoticeStatus int `xorm:"not null default 2 INT(11) notice_status"`+ FollowCount int `xorm:"not null default 0 INT(11) follow_count"`+ AnswerCount int `xorm:"not null default 0 INT(11) answer_count"`+ QuestionCount int `xorm:"not null default 0 INT(11) question_count"`+ Rank int `xorm:"not null default 0 INT(11) rank"`+ Status int `xorm:"not null default 1 INT(11) status"`+ AuthorityGroup int `xorm:"not null default 1 INT(11) authority_group"`+ DisplayName string `xorm:"not null default '' VARCHAR(30) display_name"`+ Avatar string `xorm:"not null default '' VARCHAR(255) avatar"`+ Mobile string `xorm:"not null VARCHAR(20) mobile"`+ Bio string `xorm:"not null TEXT bio"`+ BioHtml string `xorm:"not null TEXT bio_html"`+ Website string `xorm:"not null default '' VARCHAR(255) website"`+ Location string `xorm:"not null default '' VARCHAR(100) location"`+ IPInfo string `xorm:"not null default '' VARCHAR(255) ip_info"`+ IsAdmin bool `xorm:"not null default false BOOL is_admin"`}// TableName user table namediff --git a/internal/entity/version_entity.go b/internal/entity/version_entity.gonew file mode 100644index 00000000..21a5d87c--- /dev/null+++ b/internal/entity/version_entity.go@@ -0,0 +1,12 @@+package entity++// Version version+type Version struct {+ ID int `xorm:"not null pk autoincr INT(11) id"`+ VersionNumber int64 `xorm:"not null default 0 INT(11) version_number"`+}++// TableName config table name+func (Version) TableName() string {+ return "version"+}diff --git a/internal/migrations/init.go b/internal/migrations/init.goindex 6f94d815..26ed99b6 100644--- a/internal/migrations/init.go+++ b/internal/migrations/init.go@@ -26,7 +26,7 @@ var (&entity.TagRel{},&entity.Uniqid{},&entity.User{},- &Version{},+ &entity.Version{},})@@ -38,7 +38,7 @@ func InitDB(dataConf *data.Database) (err error) {return err}- exist, err := engine.IsTableExist(&Version{})+ exist, err := engine.IsTableExist(&entity.Version{})if err != nil {return fmt.Errorf("check table exists failed: %s", err)}diff --git a/internal/migrations/migrations.go b/internal/migrations/migrations.goindex 3c6fea1e..17176666 100644--- a/internal/migrations/migrations.go+++ b/internal/migrations/migrations.go@@ -4,6 +4,7 @@ import ("fmt""github.com/segmentfault/answer/internal/base/data"+ "github.com/segmentfault/answer/internal/entity""github.com/segmentfault/pacman/log""xorm.io/xorm")@@ -36,17 +37,6 @@ func NewMigration(desc string, fn func(*xorm.Engine) error) Migration {return &migration{description: desc, migrate: fn}}-// Version version-type Version struct {- ID int `xorm:"not null pk autoincr comment('id') INT(11) id"`- VersionNumber int64 `xorm:"not null default 0 comment('version_number') INT(11) version_number"`-}--// TableName config table name-func (Version) TableName() string {- return "version"-}-// Use noopMigration when there is a migration that has been no-opedvar noopMigration = func(_ *xorm.Engine) error { return nil }@@ -57,17 +47,17 @@ var migrations = []Migration{// GetCurrentDBVersion returns the current db versionfunc GetCurrentDBVersion(engine *xorm.Engine) (int64, error) {- if err := engine.Sync(new(Version)); err != nil {+ if err := engine.Sync(new(entity.Version)); err != nil {return -1, fmt.Errorf("sync version failed: %v", err)}- currentVersion := &Version{ID: 1}+ currentVersion := &entity.Version{ID: 1}has, err := engine.Get(currentVersion)if err != nil {return -1, fmt.Errorf("get first version failed: %v", err)}if !has {- _, err := engine.InsertOne(&Version{ID: 1, VersionNumber: 0})+ _, err := engine.InsertOne(&entity.Version{ID: 1, VersionNumber: 0})if err != nil {return -1, fmt.Errorf("insert first version failed: %v", err)}@@ -105,7 +95,7 @@ func Migrate(dataConf *data.Database) error {return err}log.Infof("[migrate] migrate to db version %d success", currentDBVersion+1)- if _, err := engine.Update(&Version{ID: 1, VersionNumber: currentDBVersion + 1}); err != nil {+ if _, err := engine.Update(&entity.Version{ID: 1, VersionNumber: currentDBVersion + 1}); err != nil {log.Errorf("[migrate] migrate to db version %d, update failed: %s", currentDBVersion+1, err.Error())return err}