From 7100a3618f76ad4268cc1d2ef5512564fab020a5 Mon Sep 17 00:00:00 2001 From: nochill Date: Sun, 24 Sep 2023 15:01:46 +0700 Subject: [PATCH] fix column type --- db/migrations/000001_init_schema.up.sql | 5 +++-- db/sqlc/models.go | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/db/migrations/000001_init_schema.up.sql b/db/migrations/000001_init_schema.up.sql index 68f6c49..ddfb34a 100644 --- a/db/migrations/000001_init_schema.up.sql +++ b/db/migrations/000001_init_schema.up.sql @@ -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( diff --git a/db/sqlc/models.go b/db/sqlc/models.go index 34b57b6..9d733bc 100644 --- a/db/sqlc/models.go +++ b/db/sqlc/models.go @@ -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"`