|
| 1 | +-- # migrate_up |
| 2 | + |
| 3 | +CREATE TABLE IF NOT EXISTS "playlists" |
| 4 | +( |
| 5 | + "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 6 | + "backend" text NOT NULL, |
| 7 | + "backend_id" text NOT NULL, |
| 8 | + "title" text NOT NULL, |
| 9 | + "type" text NOT NULL DEFAULT 'video', |
| 10 | + "summary" text NULL, |
| 11 | + "is_editable" integer NOT NULL DEFAULT '1', |
| 12 | + "is_smart" integer NOT NULL DEFAULT '0', |
| 13 | + "is_public" integer NOT NULL DEFAULT '0', |
| 14 | + "item_count" integer NOT NULL DEFAULT '0', |
| 15 | + "sync_id" text NULL, |
| 16 | + "content_hash" text NOT NULL DEFAULT '', |
| 17 | + "remote_updated_at" integer NOT NULL DEFAULT '0', |
| 18 | + "deleted_at" integer NULL, |
| 19 | + "metadata" text NOT NULL DEFAULT '{}', |
| 20 | + "created_at" integer NOT NULL, |
| 21 | + "updated_at" integer NOT NULL, |
| 22 | + "synced_at" integer NOT NULL, |
| 23 | + UNIQUE ("backend", "backend_id") |
| 24 | +); |
| 25 | + |
| 26 | +CREATE INDEX IF NOT EXISTS "playlists_backend" ON "playlists" ("backend"); |
| 27 | +CREATE INDEX IF NOT EXISTS "playlists_title" ON "playlists" ("title"); |
| 28 | +CREATE INDEX IF NOT EXISTS "playlists_sync_id" ON "playlists" ("sync_id"); |
| 29 | +CREATE INDEX IF NOT EXISTS "playlists_remote_updated_at" ON "playlists" ("remote_updated_at"); |
| 30 | +CREATE INDEX IF NOT EXISTS "playlists_deleted_at" ON "playlists" ("deleted_at"); |
| 31 | + |
| 32 | +CREATE TABLE IF NOT EXISTS "playlist_items" |
| 33 | +( |
| 34 | + "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 35 | + "playlist_id" integer NOT NULL, |
| 36 | + "position" integer NOT NULL, |
| 37 | + "state_id" integer NULL, |
| 38 | + "backend_item_id" text NULL, |
| 39 | + "backend_entry_id" text NULL, |
| 40 | + "item_type" text NULL, |
| 41 | + "title" text NOT NULL, |
| 42 | + "metadata" text NOT NULL DEFAULT '{}', |
| 43 | + "created_at" integer NOT NULL, |
| 44 | + "updated_at" integer NOT NULL |
| 45 | +); |
| 46 | + |
| 47 | +CREATE UNIQUE INDEX IF NOT EXISTS "playlist_items_position" ON "playlist_items" ("playlist_id", "position"); |
| 48 | +CREATE INDEX IF NOT EXISTS "playlist_items_playlist_id" ON "playlist_items" ("playlist_id"); |
| 49 | +CREATE INDEX IF NOT EXISTS "playlist_items_state_id" ON "playlist_items" ("state_id"); |
| 50 | +CREATE INDEX IF NOT EXISTS "playlist_items_backend_item" ON "playlist_items" ("backend_item_id"); |
| 51 | + |
| 52 | +-- # migrate_down |
| 53 | + |
| 54 | +DROP TABLE IF EXISTS "playlist_items"; |
| 55 | +DROP TABLE IF EXISTS "playlists"; |
0 commit comments