Files
food-ai/backend/migrations/006_create_products.sql
dbastrikin ea4a6301ea feat: replace UUID v4 with UUID v7 across backend
Define uuid_generate_v7() in the first migration and switch all table
primary key defaults to it. Remove the uuid-ossp extension dependency.
Update refresh token and request ID generation in Go code to use
uuid.NewV7() from the existing google/uuid v1.6.0 library.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 13:19:55 +02:00

20 lines
758 B
SQL

-- +goose Up
CREATE TABLE products (
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
mapping_id UUID REFERENCES ingredient_mappings(id),
name TEXT NOT NULL,
quantity DECIMAL(10, 2) NOT NULL DEFAULT 1,
unit TEXT NOT NULL DEFAULT 'pcs',
category TEXT,
storage_days INT NOT NULL DEFAULT 7,
added_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- expires_at is computed as (added_at + storage_days * INTERVAL '1 day') in queries.
-- A stored generated column cannot be used because timestamptz + interval is STABLE, not IMMUTABLE.
CREATE INDEX idx_products_user_id ON products(user_id);
-- +goose Down
DROP TABLE products;