CREATE TABLE IF NOT EXISTS movies_old (
    title              TEXT NOT NULL,
    year               INTEGER NOT NULL,
    size               INTEGER NOT NULL,
    hash               TEXT NOT NULL,
    tmdb_id            INTEGER NULL DEFAULT NULL,
    audio_languages    TEXT NULL DEFAULT NULL,
    subtitle_languages TEXT NULL DEFAULT NULL,
    resolution         TEXT NULL DEFAULT NULL,
    dynamic_range      TEXT NULL DEFAULT NULL,
    bitrate            INTEGER NULL DEFAULT NULL,
    user               TEXT NULL DEFAULT NULL,
    PRIMARY KEY (title, year, size, hash)
);
INSERT OR IGNORE INTO movies_old
    SELECT title, year, size, hash, tmdb_id, audio_languages, subtitle_languages,
           resolution, dynamic_range, bitrate, NULLIF(user, '')
    FROM movies;
DROP TABLE movies;
ALTER TABLE movies_old RENAME TO movies;
