diff --git a/migrations/001_init.sql b/migrations/001_init.sql deleted file mode 100644 index f3a2932..0000000 --- a/migrations/001_init.sql +++ /dev/null @@ -1,42 +0,0 @@ -CREATE TABLE IF NOT EXISTS user ( - id TEXT PRIMARY KEY, - username TEXT NOT NULL UNIQUE, - password_hash TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS session ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - expires_at DATETIME NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS account ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - provider TEXT NOT NULL, - provider_account_id TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE(provider, provider_account_id) -); - -CREATE TABLE IF NOT EXISTS anime ( - id INTEGER PRIMARY KEY, -- Jikan ID - title TEXT NOT NULL, - image_url TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS watch_list_entry ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - anime_id INTEGER NOT NULL REFERENCES anime(id) ON DELETE CASCADE, - status TEXT NOT NULL CHECK(status IN ('completed', 'dropped', 'plan_to_watch')), - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - current_episode INTEGER DEFAULT 0, - last_episode_at DATETIME, - current_time_seconds REAL NOT NULL DEFAULT 0, - UNIQUE(user_id, anime_id) -); diff --git a/migrations/002_add_anime_titles.sql b/migrations/002_add_anime_titles.sql deleted file mode 100644 index a1f2564..0000000 --- a/migrations/002_add_anime_titles.sql +++ /dev/null @@ -1,6 +0,0 @@ --- 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; diff --git a/migrations/003_add_anime_airing.sql b/migrations/003_add_anime_airing.sql deleted file mode 100644 index 8f74ee6..0000000 --- a/migrations/003_add_anime_airing.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Add airing status column to anime table -ALTER TABLE anime ADD COLUMN airing BOOLEAN DEFAULT 0; diff --git a/migrations/004_add_notifications.sql b/migrations/004_add_notifications.sql deleted file mode 100644 index a51e1ce..0000000 --- a/migrations/004_add_notifications.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Note: watch_list_entry columns now in 001_init.sql - --- Add notification preferences -CREATE TABLE IF NOT EXISTS notification_preference ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - notify_new_episodes BOOLEAN NOT NULL DEFAULT TRUE, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE(user_id) -); diff --git a/migrations/005_add_anime_relations.sql b/migrations/005_add_anime_relations.sql deleted file mode 100644 index 11a82ee..0000000 --- a/migrations/005_add_anime_relations.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE anime ADD COLUMN status TEXT DEFAULT ''; -ALTER TABLE anime ADD COLUMN relations_synced_at DATETIME; - -CREATE TABLE IF NOT EXISTS anime_relation ( - anime_id INTEGER NOT NULL REFERENCES anime(id) ON DELETE CASCADE, - related_anime_id INTEGER NOT NULL, - relation_type TEXT NOT NULL, - PRIMARY KEY (anime_id, related_anime_id) -); diff --git a/migrations/006_add_jikan_cache.sql b/migrations/006_add_jikan_cache.sql deleted file mode 100644 index bc4852a..0000000 --- a/migrations/006_add_jikan_cache.sql +++ /dev/null @@ -1,6 +0,0 @@ -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 -); diff --git a/migrations/007_add_query_indexes.sql b/migrations/007_add_query_indexes.sql deleted file mode 100644 index 206396f..0000000 --- a/migrations/007_add_query_indexes.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE INDEX IF NOT EXISTS idx_watch_list_entry_user_status_updated_at -ON watch_list_entry(user_id, status, updated_at); - -CREATE INDEX IF NOT EXISTS idx_anime_relation_anime_id_relation_type -ON anime_relation(anime_id, relation_type); - -CREATE INDEX IF NOT EXISTS idx_anime_relations_synced_at_status -ON anime(relations_synced_at, status); - -CREATE INDEX IF NOT EXISTS idx_jikan_cache_expires_at -ON jikan_cache(expires_at); diff --git a/migrations/009_add_anime_fetch_retry.sql b/migrations/009_add_anime_fetch_retry.sql deleted file mode 100644 index ffbbe40..0000000 --- a/migrations/009_add_anime_fetch_retry.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE IF NOT EXISTS anime_fetch_retry ( - anime_id INTEGER PRIMARY KEY, - attempts INTEGER NOT NULL DEFAULT 0, - next_retry_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - last_error TEXT NOT NULL DEFAULT '', - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE INDEX IF NOT EXISTS idx_anime_fetch_retry_next_retry_at -ON anime_fetch_retry(next_retry_at); diff --git a/migrations/010_add_watch_progress_seconds.sql b/migrations/010_add_watch_progress_seconds.sql deleted file mode 100644 index c29e82b..0000000 --- a/migrations/010_add_watch_progress_seconds.sql +++ /dev/null @@ -1 +0,0 @@ --- Note: watch_list_entry columns now in 001_init.sql \ No newline at end of file diff --git a/migrations/011_add_continue_watching.sql b/migrations/011_add_continue_watching.sql deleted file mode 100644 index d12b2af..0000000 --- a/migrations/011_add_continue_watching.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE IF NOT EXISTS continue_watching_entry ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - anime_id INTEGER NOT NULL REFERENCES anime(id) ON DELETE CASCADE, - current_episode INTEGER, - current_time_seconds REAL NOT NULL DEFAULT 0, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE(user_id, anime_id) -); - -CREATE INDEX IF NOT EXISTS idx_continue_watching_user_updated -ON continue_watching_entry(user_id, updated_at DESC); diff --git a/migrations/012_remove_recovery_key.sql b/migrations/012_remove_recovery_key.sql deleted file mode 100644 index e60c060..0000000 --- a/migrations/012_remove_recovery_key.sql +++ /dev/null @@ -1,22 +0,0 @@ -PRAGMA foreign_keys = OFF; - -BEGIN TRANSACTION; - -CREATE TABLE user_new ( - id TEXT PRIMARY KEY, - username TEXT NOT NULL UNIQUE, - password_hash TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -INSERT INTO user_new (id, username, password_hash, created_at) -SELECT id, username, password_hash, created_at -FROM user; - -DROP TABLE user; - -ALTER TABLE user_new RENAME TO user; - -COMMIT; - -PRAGMA foreign_keys = ON; diff --git a/migrations/013_drop_account.sql b/migrations/013_drop_account.sql deleted file mode 100644 index 6a6cca9..0000000 --- a/migrations/013_drop_account.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TABLE IF EXISTS account; -DROP TABLE IF EXISTS notification_preference; \ No newline at end of file diff --git a/migrations/014_add_watchlist_statuses.sql b/migrations/014_add_watchlist_statuses.sql deleted file mode 100644 index b0d8bd1..0000000 --- a/migrations/014_add_watchlist_statuses.sql +++ /dev/null @@ -1,26 +0,0 @@ --- Add "watching" and "on_hold" to the valid statuses for watch_list_entry - -PRAGMA foreign_keys=OFF; - -ALTER TABLE watch_list_entry RENAME TO watch_list_entry_old; - -CREATE TABLE IF NOT EXISTS watch_list_entry ( - id TEXT PRIMARY KEY, - user_id TEXT NOT NULL REFERENCES user(id) ON DELETE CASCADE, - anime_id INTEGER NOT NULL REFERENCES anime(id) ON DELETE CASCADE, - status TEXT NOT NULL CHECK(status IN ('watching', 'completed', 'dropped', 'plan_to_watch', 'on_hold')), - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - current_episode INTEGER DEFAULT 0, - last_episode_at DATETIME, - current_time_seconds REAL NOT NULL DEFAULT 0, - UNIQUE(user_id, anime_id) -); - -INSERT OR IGNORE INTO watch_list_entry (id, user_id, anime_id, status, created_at, updated_at, current_episode, last_episode_at, current_time_seconds) -SELECT id, user_id, anime_id, status, created_at, updated_at, current_episode, last_episode_at, current_time_seconds -FROM watch_list_entry_old; - -DROP TABLE watch_list_entry_old; - -PRAGMA foreign_keys=ON; diff --git a/migrations/015_add_duration.sql b/migrations/015_add_duration.sql deleted file mode 100644 index 80057a5..0000000 --- a/migrations/015_add_duration.sql +++ /dev/null @@ -1,5 +0,0 @@ --- 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; \ No newline at end of file diff --git a/migrations/016_add_avatar_url.sql b/migrations/016_add_avatar_url.sql deleted file mode 100644 index bb153ac..0000000 --- a/migrations/016_add_avatar_url.sql +++ /dev/null @@ -1,3 +0,0 @@ -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 = ''; \ No newline at end of file