Files
airsoftfotos.nl/migrations/20250831164112_create_albums_table.up.sql
2025-09-06 17:22:47 +02:00

32 lines
1.4 KiB
SQL

-- Add up migration script here
CREATE TABLE IF NOT EXISTS albums (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
category_id INTEGER NOT NULL,
event_date INTEGER NOT NULL,
description TEXT NULL,
created_at INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(category_id) REFERENCES categories(id)
);
-- s3://airsoftfotos/{category:1}/{event-date:3-9-2025}/{id:1}/airsoftfotos.nl_{uuid}.webp -- processed
-- s3://airsoftfotos/{category:1}/{event-date:3-9-2025}/{id:1}/{uuid}_{filename} -- original file
CREATE TABLE IF NOT EXISTS photos (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, -- might just store id as the filename in S3... or at least a folder with the og image, and a processed image (lower res and watermarked)
album_id INTEGER NOT NULL,
user_id INTEGER NOT NULL,
filename TEXT NOT NULL, -- is this the OG filename, or the filename we need to request from S3
description TEXT NULL,
visible BOOLEAN NOT NULL DEFAULT TRUE,
upvotes INTEGER NOT NULL,
downvotes INTEGER NOT NULL,
created_at INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(album_id) REFERENCES albums(id),
FOREIGN KEY(user_id) REFERENCES users(id)
);
UPDATE SQLITE_SEQUENCE SET seq = 9000 WHERE name = 'photos';