/*
  Warnings:

  - You are about to drop the column `nameI18n` on the `Genre` table. All the data in the column will be lost.
  - You are about to drop the column `subtitleI18n` on the `Genre` table. All the data in the column will be lost.
  - You are about to alter the column `name` on the `Genre` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.
  - You are about to alter the column `subtitle` on the `Genre` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.
  - You are about to drop the column `contentI18n` on the `News` table. All the data in the column will be lost.
  - You are about to drop the column `titleI18n` on the `News` table. All the data in the column will be lost.
  - You are about to alter the column `content` on the `News` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.
  - You are about to alter the column `title` on the `News` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.
  - You are about to drop the column `nameI18n` on the `Special` table. All the data in the column will be lost.
  - You are about to drop the column `subtitleI18n` on the `Special` table. All the data in the column will be lost.
  - You are about to alter the column `name` on the `Special` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.
  - You are about to alter the column `subtitle` on the `Special` table. The data in that column could be lost. The data in that column will be cast from `String` to `Json`.

*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Genre" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "name" JSONB NOT NULL,
    "subtitle" JSONB,
    "active" BOOLEAN NOT NULL DEFAULT true
);
INSERT INTO "new_Genre" ("active", "id", "name", "subtitle") SELECT "active", "id", "nameI18n", "subtitleI18n" FROM "Genre";
DROP TABLE "Genre";
ALTER TABLE "new_Genre" RENAME TO "Genre";
CREATE TABLE "new_News" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "title" JSONB NOT NULL,
    "content" JSONB NOT NULL,
    "author" TEXT,
    "publishedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    "featured" BOOLEAN NOT NULL DEFAULT false,
    "specialId" INTEGER,
    CONSTRAINT "News_specialId_fkey" FOREIGN KEY ("specialId") REFERENCES "Special" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_News" ("author", "content", "featured", "id", "publishedAt", "specialId", "title", "updatedAt") SELECT "author", "contentI18n", "featured", "id", "publishedAt", "specialId", "titleI18n", "updatedAt" FROM "News";
DROP TABLE "News";
ALTER TABLE "new_News" RENAME TO "News";
CREATE INDEX "News_publishedAt_idx" ON "News"("publishedAt");
CREATE TABLE "new_Special" (
    "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    "name" JSONB NOT NULL,
    "subtitle" JSONB,
    "maxAttempts" INTEGER NOT NULL DEFAULT 7,
    "unlockSteps" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "launchDate" DATETIME,
    "endDate" DATETIME,
    "curator" TEXT
);
INSERT INTO "new_Special" ("createdAt", "curator", "endDate", "id", "launchDate", "maxAttempts", "name", "subtitle", "unlockSteps") SELECT "createdAt", "curator", "endDate", "id", "launchDate", "maxAttempts", "nameI18n", "subtitleI18n", "unlockSteps" FROM "Special";
DROP TABLE "Special";
ALTER TABLE "new_Special" RENAME TO "Special";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
