0b73c055aa
* Added migration for metadata table used to store a song's metadata * Added comment for new table * Added endpoint to create metadata * Filling out code * Changed type of duration in request * Reorganizing code * Changing metadata table to song * Added TODO for data type discrepancy for the future * Fix migration syntax error * Added types to request * Added environment variable for root directory: * Moving keys to its own module * Moved environement related code to its own module * Added function to get root_directory * Added endpoint to create song * Minor fixes * Added test and refactored tests * Ironing out some kinks * Resolved test issue Turns out I was using the wrong id value * Added env variable in workflow * Added TODO * Updated env variable * clippy warning fixes * Making sure date_created is populated when returneD * Code cleanup * Added TODOs * Uncommenting tests * Code formatting
52 lines
1.5 KiB
SQL
52 lines
1.5 KiB
SQL
-- Add migration script here
|
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
|
|
|
-- Table to store queued songs to process
|
|
CREATE TABLE IF NOT EXISTS "songQueue" (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
filename TEXT NOT NULL,
|
|
status TEXT CHECK (status IN ('pending', 'processing', 'done')),
|
|
data BYTEA NOT NULL
|
|
);
|
|
|
|
-- Table to store queued metadata
|
|
CREATE TABLE IF NOT EXISTS "metadataQueue" (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
metadata jsonb NOT NULL,
|
|
created_at timestamptz DEFAULT now(),
|
|
song_queue_id UUID NOT NULL
|
|
);
|
|
|
|
-- Table to store queued coverart
|
|
CREATE TABLE IF NOT EXISTS "coverartQueue" (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
data BYTEA NOT NULL,
|
|
song_queue_id UUID NULL
|
|
);
|
|
|
|
-- Create an index for better query performance
|
|
CREATE INDEX metadata_queue_data_metadata ON "metadataQueue" USING gin (metadata);
|
|
|
|
-- Table to store a song's info
|
|
CREATE TABLE IF NOT EXISTS "song" (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
title TEXT NOT NULL,
|
|
artist TEXT NOT NULL,
|
|
album_artist TEXT NOT NULL,
|
|
album TEXT NOT NULL,
|
|
genre TEXT NOT NULL,
|
|
-- TODO: Address discrepancy of date and year at some point
|
|
-- date TEXT NOT NULL,
|
|
year INT NOT NULL,
|
|
track SMALLINT NOT NULL,
|
|
disc SMALLINT NOT NULL,
|
|
track_count SMALLINT NOT NULL,
|
|
disc_count SMALLINT NOT NULL,
|
|
duration INT NOT NULL,
|
|
audio_type TEXT NOT NULL,
|
|
date_created timestamptz DEFAULT now(),
|
|
filename TEXT NOT NULL,
|
|
directory TEXT NOT NULL,
|
|
user_id UUID NULL
|
|
);
|