- 0003_tablos.sql: tablos table with user_id FK + ON DELETE CASCADE + tablos_user_id_idx - tablos.sql: 5 named queries (ListTablosByUser, GetTabloByID, InsertTablo, UpdateTablo, DeleteTablo) - UpdateTablo sets updated_at = now() explicitly (Pitfall 7) - color not editable in UpdateTablo per Phase 3 scope - sqlc generates Tablo struct with pgtype.Text for description/color (not committed per .gitignore convention)
18 lines
520 B
SQL
18 lines
520 B
SQL
-- migrations/0003_tablos.sql
|
|
-- Phase 3: Tablos CRUD
|
|
|
|
-- +goose Up
|
|
CREATE TABLE tablos (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
title text NOT NULL,
|
|
description text,
|
|
color text,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX tablos_user_id_idx ON tablos(user_id);
|
|
|
|
-- +goose Down
|
|
DROP TABLE IF EXISTS tablos;
|