-- create `folders_v2` table
CREATE TABLE IF NOT EXISTS `folders_v2` (
    `id` INTEGER NOT NULL UNIQUE,
    `name` TEXT NOT NULL UNIQUE,
    `color_hex` TEXT NOT NULL,
    `folder_type` TEXT NOT NULL,
    `created_at` INTEGER NOT NULL,
    PRIMARY KEY(`id` AUTOINCREMENT)
);

-- create `items_v2` table
CREATE TABLE IF NOT EXISTS `items_v2` (
    `id` INTEGER NOT NULL UNIQUE,
    `folder_id` REFERENCES folders_v2(id) ON DELETE CASCADE NOT NULL,
    `site` TEXT NOT NULL,
    `post_id` INTEGER NOT NULL,
    `post_title` TEXT NOT NULL,
    `author_name` TEXT NOT NULL,
    `created_at` INTEGER NOT NULL,
    PRIMARY KEY(`id` AUTOINCREMENT)
);

-- create `randoms_v2` table
CREATE TABLE IF NOT EXISTS `randoms_v2` (
    `id` INTEGER NOT NULL UNIQUE,
    `site` TEXT NOT NULL,
    `post_type` TEXT NOT NULL,
    `post_ids` TEXT NOT NULL,
    `order_by` TEXT NOT NULL,
    PRIMARY KEY(`id` AUTOINCREMENT)
);
