CREATE TABLE IF NOT EXISTS "folders" (
    "id" INTEGER NOT NULL UNIQUE,
    "name" TEXT,
    "color_hex" TEXT,
    "is_expanded" INTEGER,
    "created_at" INTEGER,
    PRIMARY KEY("id" AUTOINCREMENT)
);

-- folder items
CREATE TABLE IF NOT EXISTS "items" (
    "id" INTEGER NOT NULL UNIQUE,
    "folder_id" INTEGER NOT NULL,
    "post_title" TEXT,
    "author_name" TEXT,
    "post_id" INTEGER NOT NULL,
    "created_at" INTEGER,
    PRIMARY KEY("id" AUTOINCREMENT)
);

-- randoms
CREATE TABLE IF NOT EXISTS "randoms" (
    "id" INTEGER NOT NULL UNIQUE,
    "post_type" TEXT NOT NULL,
    "random" TEXT,
    "order_by" TEXT,
    PRIMARY KEY("id" AUTOINCREMENT)
);

ALTER TABLE folders
ADD COLUMN folder_type TEXT DEFAULT 'multiple';