From 9c8cbed6cdd725ed1153a260ab0844971b685fbf Mon Sep 17 00:00:00 2001
From: Masaya Tojo <masaya@tojo.tokyo>
Date: Sat, 11 Nov 2023 16:13:41 +0900
Subject: Change taken_at column type to timestamptz

---
 deploy/photos.sql | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

(limited to 'deploy/photos.sql')

diff --git a/deploy/photos.sql b/deploy/photos.sql
index a14f480..a0231ee 100644
--- a/deploy/photos.sql
+++ b/deploy/photos.sql
@@ -5,17 +5,7 @@ BEGIN;
 
 SET search_path to photos;
 
-CREATE TABLE photos(
-  id UUID PRIMARY KEY,
-  path TEXT NOT NULL UNIQUE,
-  date DATE NOT NULL,
-  is_video BOOLEAN NOT NULL,
-  is_receipt BOOLEAN NOT NULL DEFAULT FALSE,
-  note TEXT CHECK (note <> ''),
-  taken_at TIME,
-  camera_name TEXT,
-  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
-  updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
-);
+ALTER TABLE photos
+  ALTER COLUMN taken_at TYPE timestamptz USING (date + taken_at) AT TIME ZONE 'Asia/Tokyo';
 
 COMMIT;
-- 
cgit v1.2.3

