From 43472a64e71ac55516cb7aada3b05c265edc06ef Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 30 Oct 2021 00:11:25 +0200 Subject: [PATCH] ALTER TABLE items --- pkg/timeline/postgres.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/timeline/postgres.go b/pkg/timeline/postgres.go index 5eed846..d57907a 100644 --- a/pkg/timeline/postgres.go +++ b/pkg/timeline/postgres.go @@ -50,13 +50,23 @@ CREATE TABLE IF NOT EXISTS "items" ( "channel_id" int references "channels" on delete cascade, "uid" varchar(512) not null unique, "is_read" int default 0, - "data" json, + "data" jsonb, "created_at" timestamp DEFAULT current_timestamp, "updated_at" timestamp, "published_at" timestamp ); `) if err != nil { + + _, err = conn.ExecContext(ctx, ` +ALTER TABLE "items" +ALTER COLUMN "data" TYPE jsonb +ALTER COLUMN "uid" TYPE varchar(1024); +); +`) + if err != nil { + return fmt.Errorf("create items table failed: %w", err) + } return fmt.Errorf("create items table failed: %w", err) }