/*
  Warnings:

  - You are about to drop the column `action` on the `Notification` table. All the data in the column will be lost.
  - You are about to drop the column `actionUrl` on the `Notification` table. All the data in the column will be lost.
  - You are about to drop the column `secureHtml` on the `Notification` table. All the data in the column will be lost.
  - You are about to drop the column `secureText` on the `Notification` table. All the data in the column will be lost.
  - Added the required column `smsText` to the `Notification` table without a default value. This is not possible if the table is not empty.
  - Added the required column `type` to the `Notification` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "NotificationType" AS ENUM ('Auth', 'Transactional', 'Invite', 'Marketing');

-- AlterEnum
ALTER TYPE "ChannelNotificationStatus" ADD VALUE 'Sending';

-- AlterTable
ALTER TABLE "Notification" DROP COLUMN "action",
DROP COLUMN "actionUrl",
DROP COLUMN "secureHtml",
DROP COLUMN "secureText",
-- Add these columns but temporarily make these columns nullable
ADD COLUMN     "smsText" TEXT,
ADD COLUMN     "type" "NotificationType";

-- Backfill every single Notification empty SMS text and a type.
UPDATE "Notification" SET "smsText" = '',
"type" = 'Transactional';

-- Require the two new columns.
ALTER TABLE "Notification" ALTER COLUMN "smsText" SET NOT NULL,
ALTER COLUMN "type" SET NOT NULL;

-- CreateIndex
CREATE INDEX "ChannelNotification_toPhone_idx" ON "ChannelNotification"("toPhone");
