This commit is contained in:
2025-11-02 09:31:01 +01:00
commit 455e144ffb
37 changed files with 4193 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
-- Active: 1762068220033@@127.0.0.1@5432@libertas_db
CREATE TABLE users (
id UUID PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
email TEXT NOT NULL UNIQUE,
hashed_password TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

View File

@@ -0,0 +1,16 @@
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);

View File

@@ -0,0 +1,23 @@
-- Create the 'albums' table
CREATE TABLE albums (
id UUID PRIMARY KEY,
owner_id UUID NOT NULL REFERENCES users (id),
name TEXT NOT NULL,
description TEXT,
is_public BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Create the 'album_media' join table
-- This links media items to albums
CREATE TABLE album_media (
album_id UUID NOT NULL REFERENCES albums (id) ON DELETE CASCADE,
media_id UUID NOT NULL REFERENCES media (id) ON DELETE CASCADE,
PRIMARY KEY (album_id, media_id) -- Ensures no duplicates
);
-- Indexes for faster lookups
CREATE INDEX idx_albums_owner_id ON albums (owner_id);
CREATE INDEX idx_album_media_media_id ON album_media (media_id);