refactor: general architectural cleanup and bug fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS user (
|
||||
id TEXT PRIMARY KEY,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
@@ -40,3 +41,10 @@ CREATE TABLE IF NOT EXISTS watch_list_entry (
|
||||
current_time_seconds REAL NOT NULL DEFAULT 0,
|
||||
UNIQUE(user_id, anime_id)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS watch_list_entry;
|
||||
DROP TABLE IF EXISTS anime;
|
||||
DROP TABLE IF EXISTS account;
|
||||
DROP TABLE IF EXISTS session;
|
||||
DROP TABLE IF EXISTS user;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
-- +goose Up
|
||||
-- Add English and Japanese title columns to anime table
|
||||
ALTER TABLE anime ADD COLUMN title_english TEXT;
|
||||
ALTER TABLE anime ADD COLUMN title_japanese TEXT;
|
||||
|
||||
-- Rename existing title to title_original for clarity
|
||||
ALTER TABLE anime RENAME COLUMN title TO title_original;
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
-- +goose Up
|
||||
-- Add airing status column to anime table
|
||||
ALTER TABLE anime ADD COLUMN airing BOOLEAN DEFAULT 0;
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
-- Note: watch_list_entry columns now in 001_init.sql
|
||||
|
||||
-- Add notification preferences
|
||||
@@ -8,3 +9,5 @@ CREATE TABLE IF NOT EXISTS notification_preference (
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE(user_id)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE anime ADD COLUMN status TEXT DEFAULT '';
|
||||
ALTER TABLE anime ADD COLUMN relations_synced_at DATETIME;
|
||||
|
||||
@@ -7,3 +8,5 @@ CREATE TABLE IF NOT EXISTS anime_relation (
|
||||
relation_type TEXT NOT NULL,
|
||||
PRIMARY KEY (anime_id, related_anime_id)
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS jikan_cache (
|
||||
key TEXT PRIMARY KEY,
|
||||
data TEXT NOT NULL,
|
||||
expires_at DATETIME NOT NULL,
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE INDEX IF NOT EXISTS idx_watch_list_entry_user_status_updated_at
|
||||
ON watch_list_entry(user_id, status, updated_at);
|
||||
|
||||
@@ -9,3 +10,5 @@ ON anime(relations_synced_at, status);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_jikan_cache_expires_at
|
||||
ON jikan_cache(expires_at);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS anime_fetch_retry (
|
||||
anime_id INTEGER PRIMARY KEY,
|
||||
attempts INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -9,3 +10,5 @@ CREATE TABLE IF NOT EXISTS anime_fetch_retry (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_anime_fetch_retry_next_retry_at
|
||||
ON anime_fetch_retry(next_retry_at);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
-- Note: watch_list_entry columns now in 001_init.sql
|
||||
-- +goose Up
|
||||
-- Note: watch_list_entry columns now in 001_init.sql
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE IF NOT EXISTS continue_watching_entry (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE,
|
||||
@@ -11,3 +12,5 @@ CREATE TABLE IF NOT EXISTS continue_watching_entry (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_continue_watching_user_updated
|
||||
ON continue_watching_entry(user_id, updated_at DESC);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
@@ -20,3 +21,5 @@ ALTER TABLE user_new RENAME TO user;
|
||||
COMMIT;
|
||||
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
-- +goose Up
|
||||
DROP TABLE IF EXISTS account;
|
||||
DROP TABLE IF EXISTS notification_preference;
|
||||
DROP TABLE IF EXISTS notification_preference;
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
-- +goose Up
|
||||
-- Add "watching" and "on_hold" to the valid statuses for watch_list_entry
|
||||
|
||||
PRAGMA foreign_keys=OFF;
|
||||
@@ -24,3 +25,5 @@ FROM watch_list_entry_old;
|
||||
DROP TABLE watch_list_entry_old;
|
||||
|
||||
PRAGMA foreign_keys=ON;
|
||||
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
-- +goose Up
|
||||
-- Add duration column to anime table to store episode duration in seconds
|
||||
ALTER TABLE anime ADD COLUMN duration_seconds REAL;
|
||||
|
||||
-- Add duration_seconds column to continue_watching_entry to track episode duration
|
||||
ALTER TABLE continue_watching_entry ADD COLUMN duration_seconds REAL;
|
||||
ALTER TABLE continue_watching_entry ADD COLUMN duration_seconds REAL;
|
||||
-- +goose Down
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE user ADD COLUMN avatar_url TEXT NOT NULL DEFAULT '';
|
||||
|
||||
UPDATE user SET avatar_url = 'https://api.dicebear.com/9.x/dylan/svg?seed=' || username WHERE avatar_url = '';
|
||||
UPDATE user SET avatar_url = 'https://api.dicebear.com/9.x/dylan/svg?seed=' || username WHERE avatar_url = '';
|
||||
-- +goose Down
|
||||
|
||||
Reference in New Issue
Block a user