import kotlin.Boolean;
import kotlin.Long;

CREATE TABLE extension_repos (
    base_url TEXT NOT NULL PRIMARY KEY,
    name TEXT NOT NULL,
    short_name TEXT,
    website TEXT NOT NULL,
    signing_key_fingerprint TEXT UNIQUE NOT NULL
);

--- >> Rename hideTitle to hide_title
DROP INDEX IF EXISTS mangas_url_index;
DROP INDEX IF EXISTS library_favorite_index;

ALTER TABLE mangas RENAME TO mangas_tmp;
CREATE TABLE mangas(
    _id INTEGER NOT NULL PRIMARY KEY,
    source INTEGER NOT NULL,
    url TEXT NOT NULL,
    artist TEXT,
    author TEXT,
    description TEXT,
    genre TEXT,
    title TEXT NOT NULL,
    status INTEGER NOT NULL,
    thumbnail_url TEXT,
    favorite INTEGER NOT NULL,
    last_update INTEGER AS Long,
    initialized INTEGER AS Boolean NOT NULL,
    viewer INTEGER NOT NULL,
    hide_title INTEGER NOT NULL,
    chapter_flags INTEGER NOT NULL,
    date_added INTEGER AS Long,
    filtered_scanlators TEXT,
    update_strategy INTEGER NOT NULL DEFAULT 0
);
INSERT INTO mangas
   (_id, source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update,
    initialized, viewer, hide_title, chapter_flags, date_added, filtered_scanlators, update_strategy)
SELECT
    _id, source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update,
    initialized, viewer, hideTitle, chapter_flags, date_added, filtered_scanlators, update_strategy
FROM mangas_tmp;

CREATE INDEX mangas_url_index ON mangas(url);
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
--- << Rename hideTitle to hide_title
