This includes the patches to get from the initial version of the database to its current state - for the purpose of documentation. Beware, if you already have an existing database, running this code will likely result in an error and/or lead to some minor data loss. You need to follow these steps to fix your DB: 1. delete all *.sql files from unwind/sql/ 2. remove the .disabled suffix from unwind/sql/00000001-fix-db.sql.disabled 3. start the application once, this will fix up the database 4. revert all changes to unwind/sql/ – or leave it, it doesn't matter.
40 lines
747 B
SQL
40 lines
747 B
SQL
-- add original_title to movies table
|
|
|
|
-- see https://www.sqlite.org/lang_altertable.html#caution
|
|
-- 1. Create new table
|
|
-- 2. Copy data
|
|
-- 3. Drop old table
|
|
-- 4. Rename new into old
|
|
|
|
CREATE TABLE _migrate_movies (
|
|
id TEXT NOT NULL PRIMARY KEY,
|
|
title TEXT NOT NULL,
|
|
original_title TEXT,
|
|
release_year NUMBER NOT NULL,
|
|
media_type TEXT NOT NULL,
|
|
imdb_id TEXT NOT NULL UNIQUE,
|
|
score NUMBER,
|
|
runtime NUMBER,
|
|
genres TEXT NOT NULL,
|
|
updated TEXT NOT NULL
|
|
);;
|
|
|
|
INSERT INTO _migrate_movies
|
|
SELECT
|
|
id,
|
|
title,
|
|
NULL,
|
|
release_year,
|
|
media_type,
|
|
imdb_id,
|
|
score,
|
|
runtime,
|
|
genres,
|
|
updated
|
|
FROM movies
|
|
WHERE true;;
|
|
|
|
DROP TABLE movies;;
|
|
|
|
ALTER TABLE _migrate_movies
|
|
RENAME TO movies;;
|