fix column type

This commit is contained in:
nochill 2023-09-24 15:01:46 +07:00
parent 3f18f0e1c2
commit 7100a3618f
2 changed files with 8 additions and 6 deletions

View File

@ -112,7 +112,7 @@ CREATE TABLE reviews (
"comments" text not null,
"score" smallint not null,
"is_from_critic" boolean not null,
"is_hided" boolean, -- if comments violate TOS just hide the reviews
"is_hided" boolean not null default(false), -- if comments violate TOS just hide the reviews
"location_id" integer references "locations"("id") not null,
"created_at" timestamp default(now()),
"updated_at" timestamp default(now())
@ -121,7 +121,8 @@ CREATE TABLE reviews (
CREATE TYPE comment_type AS ENUM(
'stories',
'news',
'reviews'
'reviews',
'locations'
);
CREATE TABLE comments(

View File

@ -16,9 +16,10 @@ import (
type CommentType string
const (
CommentTypeStories CommentType = "stories"
CommentTypeNews CommentType = "news"
CommentTypeReviews CommentType = "reviews"
CommentTypeStories CommentType = "stories"
CommentTypeNews CommentType = "news"
CommentTypeReviews CommentType = "reviews"
CommentTypeLocations CommentType = "locations"
)
func (e *CommentType) Scan(src interface{}) error {
@ -188,7 +189,7 @@ type Review struct {
Comments string `json:"comments"`
Score int16 `json:"score"`
IsFromCritic bool `json:"is_from_critic"`
IsHided sql.NullBool `json:"is_hided"`
IsHided bool `json:"is_hided"`
LocationID int32 `json:"location_id"`
CreatedAt sql.NullTime `json:"created_at"`
UpdatedAt sql.NullTime `json:"updated_at"`