from database import DB as db


def init():
    db.create_table(
        "artists",
        [
            ("id", "SERIAL", "PRIMARY KEY"),
            ("name", "TEXT", "NOT NULL"),
            ("url", "TEXT", "UNIQUE"),
            ("thumbnail", "BYTEA", ""),
            ("json", "JSON", ""),
        ],
        primary_key="id",
    )

    db.create_table(
        "albums",
        [
            ("id", "SERIAL", "PRIMARY KEY"),
            ("artist_id", "SERIAL", "REFERENCES artists(id) ON DELETE CASCADE"),
            ("name", "TEXT", "NOT NULL"),
            ("url", "TEXT", "UNIQUE"),
            ("thumbnail", "BYTEA", ""),
            ("done", "BOOLEAN", ""),
            ("json", "JSON", ""),
        ],
        primary_key="id",
    )
    return True
