Files
libertas/libertas_api/migrations/20251102073606_create_media_table.sql
2025-11-02 09:31:01 +01:00

16 lines
523 B
SQL

CREATE TABLE media (
id UUID PRIMARY KEY,
owner_id UUID NOT NULL REFERENCES users(id),
storage_path TEXT NOT NULL,
original_filename TEXT NOT NULL,
mime_type TEXT NOT NULL,
hash TEXT NOT NULL UNIQUE, -- For duplicate checking
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
-- Optional fields from the model
extracted_location TEXT, width INTEGER, height INTEGER );
-- Indexes for faster lookups
CREATE INDEX idx_media_owner_id ON media (owner_id);
CREATE INDEX idx_media_hash ON media (hash);