-- CreateEnum
CREATE TYPE "AspectType" AS ENUM ('CONJUNCTION', 'SEXTILE', 'SQUARE', 'TRINE', 'OPPOSITION', 'QUINCUNX', 'SEMISEXTILE', 'SEMISQUARE');

-- CreateEnum
CREATE TYPE "AdminActionType" AS ENUM ('USER_APPROVED', 'USER_SUSPENDED', 'USER_DELETED', 'CHART_APPROVED', 'CHART_REJECTED', 'CONTENT_MODERATED', 'PAYMENT_REFUNDED', 'SUBSCRIPTION_UPDATED');

-- CreateEnum
CREATE TYPE "ChatMessageType" AS ENUM ('TEXT', 'VOICE', 'IMAGE', 'FILE');

-- CreateEnum
CREATE TYPE "PaymentStatus" AS ENUM ('PENDING', 'COMPLETED', 'FAILED', 'REFUNDED', 'CANCELLED');

-- CreateEnum
CREATE TYPE "ReportStatus" AS ENUM ('SUBMITTED', 'UNDER_REVIEW', 'IN_PROGRESS', 'RESOLVED', 'CLOSED', 'REJECTED');

-- CreateEnum
CREATE TYPE "Priority" AS ENUM ('LOW', 'MEDIUM', 'HIGH', 'URGENT');

-- CreateEnum
CREATE TYPE "AIChatTypes" AS ENUM ('supportive', 'analytics', 'motivational', 'girlfriend', 'boyfriend', 'emotional', 'mental', 'physical');

-- CreateEnum
CREATE TYPE "InsightType" AS ENUM ('WEEKLY', 'MONTHLY');

-- CreateEnum
CREATE TYPE "ActionTypes" AS ENUM ('CHAT', 'LOGIN', 'LOGOUT', 'SIGNUP', 'CONTACT_SUPPORT', 'ASTROLOGY_CHART');

-- CreateEnum
CREATE TYPE "ContentTypes" AS ENUM ('KEY_BENEFITS', 'PLATEFORM_HIGHLIGHTS', 'HOWITWoRKS', 'PROCESS_SIMPLIFIED', 'FREQUENTLY_ASKED_QUESTION', 'ADVANCED_EMOTIONAL');

-- CreateEnum
CREATE TYPE "MessageType" AS ENUM ('ME', 'AI');

-- CreateEnum
CREATE TYPE "OTP_FOR" AS ENUM ('VERIFICATION', 'FORGET_PASSWORD', 'REGISTRATION');

-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN', 'ALL');

-- CreateEnum
CREATE TYPE "TierTypeProps" AS ENUM ('FREE_TIER', 'HEALING', 'THERAPY');

-- CreateEnum
CREATE TYPE "ZiodicSignEnum" AS ENUM ('ARIES', 'TAURUS', 'GEMINI', 'CANCER', 'LEO', 'VIRGO', 'LIBRA', 'SCORPIO', 'SAGITTARIUS', 'CAPRICORN', 'AQUARIUS', 'PISCES', 'RISING', 'VIRGUE');

-- CreateTable
CREATE TABLE "AIChatRoom" (
    "id" TEXT NOT NULL,
    "chatType" "AIChatTypes" NOT NULL DEFAULT 'supportive',
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "chatCount" INTEGER NOT NULL DEFAULT 0,
    "userId" TEXT NOT NULL,

    CONSTRAINT "AIChatRoom_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AIChatRoomMessaages" (
    "id" TEXT NOT NULL,
    "message" TEXT NOT NULL,
    "messageType" "MessageType" NOT NULL DEFAULT 'AI',
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,
    "chatRoom" TEXT NOT NULL,

    CONSTRAINT "AIChatRoomMessaages_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ContactSuport" (
    "id" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "email" TEXT NOT NULL,
    "subject" TEXT NOT NULL,
    "message" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,

    CONSTRAINT "ContactSuport_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "NewsLetter" (
    "id" TEXT NOT NULL,
    "name" TEXT,
    "email" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "NewsLetter_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "RecentActions" (
    "id" TEXT NOT NULL,
    "email" TEXT,
    "action" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "actionType" "ActionTypes" NOT NULL DEFAULT 'LOGIN',
    "userId" TEXT NOT NULL,

    CONSTRAINT "RecentActions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Session" (
    "id" TEXT NOT NULL,
    "token" TEXT,
    "expiresAt" TIMESTAMP(3) NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,
    "browser" TEXT,
    "deviceType" TEXT,
    "ip" TEXT,
    "isRevoked" BOOLEAN NOT NULL DEFAULT false,
    "platform" TEXT,
    "userAgent" TEXT,

    CONSTRAINT "Session_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Subscriptions" (
    "id" TEXT NOT NULL,
    "subscriptionId" TEXT NOT NULL,
    "productId" TEXT NOT NULL,
    "status" TEXT NOT NULL,
    "orderId" TEXT NOT NULL,
    "startDate" TIMESTAMP(3) NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,

    CONSTRAINT "Subscriptions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Testimonial" (
    "id" TEXT NOT NULL,
    "testimonial" TEXT NOT NULL,
    "testinomailAuthor" TEXT NOT NULL,
    "testimonialType" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "Testimonial_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "users" (
    "id" TEXT NOT NULL,
    "email" TEXT,
    "password" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "image_id" TEXT,
    "is_active" BOOLEAN NOT NULL DEFAULT true,
    "is_deleted" BOOLEAN NOT NULL DEFAULT false,
    "is_profile_completed" BOOLEAN NOT NULL DEFAULT false,
    "notification_on" BOOLEAN NOT NULL DEFAULT true,
    "otp_id" TEXT,
    "user_type" "Role" NOT NULL DEFAULT 'USER',
    "isSubscribe" BOOLEAN NOT NULL DEFAULT false,
    "is_verified" BOOLEAN NOT NULL DEFAULT false,
    "full_name" TEXT,
    "subscriptionTier" "TierTypeProps" NOT NULL DEFAULT 'FREE_TIER',

    CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AstrologyInsightContent" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "currentInsights" JSONB,
    "personalAspects" JSONB,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "AstrologyInsightContent_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "astrology_charts" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "birthDate" TIMESTAMP(3) NOT NULL,
    "birthTime" TEXT,
    "birthLocation" TEXT NOT NULL,
    "latitude" DOUBLE PRECISION,
    "longitude" DOUBLE PRECISION,
    "timezone" TEXT,
    "sunSign" TEXT NOT NULL,
    "sunDescription" TEXT,
    "moonSign" TEXT,
    "moonDescription" TEXT,
    "risingSign" TEXT,
    "ascendantDescription" TEXT,
    "chartInterpretation" TEXT,
    "astrologerNotes" TEXT,
    "isApproved" BOOLEAN NOT NULL DEFAULT true,
    "moderationNotes" TEXT,
    "moderatedBy" TEXT,
    "moderatedAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "astrology_charts_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "planetary_positions" (
    "id" TEXT NOT NULL,
    "chartId" TEXT NOT NULL,
    "planet" TEXT NOT NULL,
    "sign" TEXT NOT NULL,
    "degree" DOUBLE PRECISION NOT NULL,
    "house" INTEGER,
    "isRetrograde" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "planetary_positions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "house_cusps" (
    "id" TEXT NOT NULL,
    "chartId" TEXT NOT NULL,
    "houseNumber" INTEGER NOT NULL,
    "sign" TEXT NOT NULL,
    "degree" DOUBLE PRECISION NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "house_cusps_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "aspects" (
    "id" TEXT NOT NULL,
    "planetId" TEXT NOT NULL,
    "targetPlanet" TEXT NOT NULL,
    "aspectType" "AspectType" NOT NULL,
    "orb" DOUBLE PRECISION NOT NULL,
    "isExact" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "aspects_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "chat_messages" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "message" TEXT NOT NULL,
    "response" TEXT,
    "isFromUser" BOOLEAN NOT NULL,
    "messageType" "ChatMessageType" NOT NULL DEFAULT 'TEXT',
    "metadata" JSONB,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "aICompanionSessionId" TEXT,

    CONSTRAINT "chat_messages_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "ai_companion_sessions" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "sessionName" TEXT,
    "mode" TEXT,
    "isActive" BOOLEAN NOT NULL DEFAULT true,
    "startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "endedAt" TIMESTAMP(3),

    CONSTRAINT "ai_companion_sessions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "meditation_sessions" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "sessionType" TEXT NOT NULL,
    "duration" INTEGER NOT NULL,
    "isCompleted" BOOLEAN NOT NULL DEFAULT false,
    "notes" TEXT,
    "startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "endedAt" TIMESTAMP(3),

    CONSTRAINT "meditation_sessions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "payments" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "amount" DOUBLE PRECISION NOT NULL,
    "currency" TEXT NOT NULL DEFAULT 'USD',
    "paymentMethod" TEXT NOT NULL,
    "status" "PaymentStatus" NOT NULL DEFAULT 'PENDING',
    "transactionId" TEXT,
    "subscriptionId" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "payments_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "domestic_violence_reports" (
    "id" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "incidentDate" TIMESTAMP(3) NOT NULL,
    "incidentTime" TEXT NOT NULL,
    "location" TEXT NOT NULL,
    "description" TEXT NOT NULL,
    "witnesses" TEXT,
    "policeReport" BOOLEAN NOT NULL DEFAULT false,
    "userId" TEXT NOT NULL,
    "violenceTypes" TEXT[],
    "notes" TEXT,

    CONSTRAINT "domestic_violence_reports_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "documents" (
    "id" TEXT NOT NULL,
    "lastModifiedDate" TIMESTAMP(3),
    "fileName" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "size" INTEGER,
    "filePath" TEXT NOT NULL,
    "type" INTEGER NOT NULL,
    "webkitRelativePath" TEXT,
    "uploadedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "reportId" TEXT NOT NULL,

    CONSTRAINT "documents_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "system_config" (
    "id" TEXT NOT NULL,
    "key" TEXT NOT NULL,
    "value" TEXT NOT NULL,
    "description" TEXT,
    "isPublic" BOOLEAN NOT NULL DEFAULT false,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "system_config_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "subscription_plans" (
    "id" TEXT NOT NULL,
    "name" TEXT NOT NULL,
    "price" TEXT NOT NULL,
    "period" TEXT,
    "product_id" TEXT NOT NULL,
    "orderId" TEXT,
    "paypal_plan_id" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,

    CONSTRAINT "subscription_plans_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AstrologyContent" (
    "id" TEXT NOT NULL,
    "planet" TEXT NOT NULL,
    "description" TEXT,
    "Tags" TEXT[],
    "Qualities" TEXT[],
    "ZiodicSign" "ZiodicSignEnum" NOT NULL DEFAULT 'AQUARIUS',
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "isDelete" BOOLEAN NOT NULL DEFAULT false,
    "userId" TEXT NOT NULL,

    CONSTRAINT "AstrologyContent_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AstrologyCalculation" (
    "id" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "date" TEXT NOT NULL,
    "time" TEXT NOT NULL,
    "timezone" TEXT NOT NULL,
    "latitude" DOUBLE PRECISION NOT NULL,
    "longitude" DOUBLE PRECISION NOT NULL,
    "utc" TEXT NOT NULL,
    "julianDayUT" DOUBLE PRECISION NOT NULL,
    "sunLongitude" DOUBLE PRECISION NOT NULL,
    "sunSign" "ZiodicSignEnum" NOT NULL,
    "sunDegree" DOUBLE PRECISION NOT NULL,
    "sunFormatted" TEXT NOT NULL,
    "moonLongitude" DOUBLE PRECISION NOT NULL,
    "moonSign" "ZiodicSignEnum" NOT NULL,
    "moonDegree" DOUBLE PRECISION NOT NULL,
    "moonFormatted" TEXT NOT NULL,
    "ascendantLongitude" DOUBLE PRECISION NOT NULL,
    "ascendantSign" "ZiodicSignEnum" NOT NULL,
    "ascendantDegree" DOUBLE PRECISION NOT NULL,
    "ascendantFormatted" TEXT NOT NULL,
    "note" TEXT,
    "userId" TEXT NOT NULL,
    "isDeleted" BOOLEAN NOT NULL DEFAULT false,

    CONSTRAINT "AstrologyCalculation_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AstrologyCalculationResponse" (
    "id" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "requestedDate" TEXT NOT NULL,
    "requestedTime" TEXT NOT NULL,
    "requestedTimezone" TEXT NOT NULL,
    "requestedLatitude" DOUBLE PRECISION NOT NULL,
    "requestedLongitude" DOUBLE PRECISION NOT NULL,
    "utc" TEXT NOT NULL,
    "julianDayUT" DOUBLE PRECISION NOT NULL,
    "sunLongitude" DOUBLE PRECISION NOT NULL,
    "sunSign" TEXT NOT NULL,
    "sunDegree" DOUBLE PRECISION NOT NULL,
    "sunFormatted" TEXT NOT NULL,
    "moonLongitude" DOUBLE PRECISION NOT NULL,
    "moonSign" TEXT NOT NULL,
    "moonDegree" DOUBLE PRECISION NOT NULL,
    "moonFormatted" TEXT NOT NULL,
    "ascendantLongitude" DOUBLE PRECISION NOT NULL,
    "ascendantSign" TEXT NOT NULL,
    "ascendantDegree" DOUBLE PRECISION NOT NULL,
    "ascendantFormatted" TEXT NOT NULL,
    "note" TEXT,
    "sunInfo" JSONB,
    "moonInfo" JSONB,
    "ascendantInfo" JSONB,
    "userId" TEXT NOT NULL,
    "isDeleted" BOOLEAN NOT NULL DEFAULT false,

    CONSTRAINT "AstrologyCalculationResponse_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "SystemPrompt" (
    "id" TEXT NOT NULL,
    "chatTypes" "AIChatTypes" NOT NULL DEFAULT 'supportive',
    "description" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,

    CONSTRAINT "SystemPrompt_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "AstrologyInsight" (
    "id" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    "userId" TEXT NOT NULL,
    "insightType" "InsightType" NOT NULL,
    "weeklyTitle" TEXT,
    "weeklyPeriod" TEXT,
    "weeklyOverview" TEXT,
    "weeklyEnergy" TEXT,
    "weeklyKeyThemes" TEXT[],
    "weeklyLuckyDays" TEXT[],
    "weeklyChallenges" TEXT,
    "monthlyTitle" TEXT,
    "monthlyPeriod" TEXT,
    "monthlyOverview" TEXT,
    "monthlyEnergy" TEXT,
    "monthlyKeyThemes" TEXT[],
    "monthlyLuckyDays" TEXT[],
    "monthlyChallenges" TEXT,
    "personalAspects" JSONB,
    "generatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "expiresAt" TIMESTAMP(3) NOT NULL,
    "isDeleted" BOOLEAN NOT NULL DEFAULT false,

    CONSTRAINT "AstrologyInsight_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "AIChatRoom_chatType_idx" ON "AIChatRoom"("chatType");

-- CreateIndex
CREATE INDEX "AIChatRoom_createdAt_idx" ON "AIChatRoom"("createdAt");

-- CreateIndex
CREATE UNIQUE INDEX "AIChatRoom_userId_chatType_key" ON "AIChatRoom"("userId", "chatType");

-- CreateIndex
CREATE INDEX "AIChatRoomMessaages_createdAt_idx" ON "AIChatRoomMessaages"("createdAt");

-- CreateIndex
CREATE INDEX "AIChatRoomMessaages_message_idx" ON "AIChatRoomMessaages"("message");

-- CreateIndex
CREATE INDEX "ContactSuport_createdAt_idx" ON "ContactSuport"("createdAt");

-- CreateIndex
CREATE INDEX "ContactSuport_email_idx" ON "ContactSuport"("email");

-- CreateIndex
CREATE INDEX "ContactSuport_subject_idx" ON "ContactSuport"("subject");

-- CreateIndex
CREATE INDEX "ContactSuport_message_idx" ON "ContactSuport"("message");

-- CreateIndex
CREATE INDEX "ContactSuport_name_idx" ON "ContactSuport"("name");

-- CreateIndex
CREATE UNIQUE INDEX "NewsLetter_email_key" ON "NewsLetter"("email");

-- CreateIndex
CREATE INDEX "NewsLetter_createdAt_idx" ON "NewsLetter"("createdAt");

-- CreateIndex
CREATE INDEX "NewsLetter_email_idx" ON "NewsLetter"("email");

-- CreateIndex
CREATE INDEX "NewsLetter_name_idx" ON "NewsLetter"("name");

-- CreateIndex
CREATE INDEX "RecentActions_email_idx" ON "RecentActions"("email");

-- CreateIndex
CREATE INDEX "RecentActions_action_idx" ON "RecentActions"("action");

-- CreateIndex
CREATE INDEX "RecentActions_actionType_idx" ON "RecentActions"("actionType");

-- CreateIndex
CREATE UNIQUE INDEX "Session_expiresAt_key" ON "Session"("expiresAt");

-- CreateIndex
CREATE INDEX "Session_id_idx" ON "Session"("id");

-- CreateIndex
CREATE INDEX "Subscriptions_createdAt_idx" ON "Subscriptions"("createdAt");

-- CreateIndex
CREATE INDEX "Subscriptions_subscriptionId_idx" ON "Subscriptions"("subscriptionId");

-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");

-- CreateIndex
CREATE UNIQUE INDEX "users_image_id_key" ON "users"("image_id");

-- CreateIndex
CREATE UNIQUE INDEX "users_otp_id_key" ON "users"("otp_id");

-- CreateIndex
CREATE INDEX "users_user_type_idx" ON "users"("user_type");

-- CreateIndex
CREATE INDEX "users_email_idx" ON "users"("email");

-- CreateIndex
CREATE UNIQUE INDEX "AstrologyInsightContent_userId_key" ON "AstrologyInsightContent"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "system_config_key_key" ON "system_config"("key");

-- CreateIndex
CREATE INDEX "subscription_plans_createdAt_idx" ON "subscription_plans"("createdAt");

-- CreateIndex
CREATE INDEX "subscription_plans_name_idx" ON "subscription_plans"("name");

-- CreateIndex
CREATE INDEX "subscription_plans_price_idx" ON "subscription_plans"("price");

-- CreateIndex
CREATE INDEX "subscription_plans_period_idx" ON "subscription_plans"("period");

-- CreateIndex
CREATE INDEX "subscription_plans_product_id_idx" ON "subscription_plans"("product_id");

-- CreateIndex
CREATE INDEX "subscription_plans_paypal_plan_id_idx" ON "subscription_plans"("paypal_plan_id");

-- CreateIndex
CREATE INDEX "AstrologyCalculation_userId_idx" ON "AstrologyCalculation"("userId");

-- CreateIndex
CREATE INDEX "AstrologyCalculation_createdAt_idx" ON "AstrologyCalculation"("createdAt");

-- CreateIndex
CREATE INDEX "AstrologyCalculation_userId_isDeleted_idx" ON "AstrologyCalculation"("userId", "isDeleted");

-- CreateIndex
CREATE INDEX "AstrologyCalculation_userId_isDeleted_createdAt_idx" ON "AstrologyCalculation"("userId", "isDeleted", "createdAt");

-- CreateIndex
CREATE INDEX "AstrologyCalculation_isDeleted_createdAt_idx" ON "AstrologyCalculation"("isDeleted", "createdAt");

-- CreateIndex
CREATE INDEX "AstrologyCalculationResponse_userId_idx" ON "AstrologyCalculationResponse"("userId");

-- CreateIndex
CREATE INDEX "AstrologyCalculationResponse_createdAt_idx" ON "AstrologyCalculationResponse"("createdAt");

-- CreateIndex
CREATE INDEX "AstrologyCalculationResponse_sunSign_idx" ON "AstrologyCalculationResponse"("sunSign");

-- CreateIndex
CREATE INDEX "AstrologyCalculationResponse_moonSign_idx" ON "AstrologyCalculationResponse"("moonSign");

-- CreateIndex
CREATE INDEX "AstrologyCalculationResponse_ascendantSign_idx" ON "AstrologyCalculationResponse"("ascendantSign");

-- CreateIndex
CREATE INDEX "SystemPrompt_chatTypes_idx" ON "SystemPrompt"("chatTypes");

-- CreateIndex
CREATE INDEX "SystemPrompt_description_idx" ON "SystemPrompt"("description");

-- CreateIndex
CREATE INDEX "SystemPrompt_userId_idx" ON "SystemPrompt"("userId");

-- CreateIndex
CREATE INDEX "AstrologyInsight_userId_idx" ON "AstrologyInsight"("userId");

-- CreateIndex
CREATE INDEX "AstrologyInsight_insightType_idx" ON "AstrologyInsight"("insightType");

-- CreateIndex
CREATE INDEX "AstrologyInsight_generatedAt_idx" ON "AstrologyInsight"("generatedAt");

-- CreateIndex
CREATE INDEX "AstrologyInsight_expiresAt_idx" ON "AstrologyInsight"("expiresAt");

-- CreateIndex
CREATE INDEX "AstrologyInsight_isDeleted_idx" ON "AstrologyInsight"("isDeleted");

-- AddForeignKey
ALTER TABLE "AIChatRoom" ADD CONSTRAINT "AIChatRoom_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AIChatRoomMessaages" ADD CONSTRAINT "AIChatRoomMessaages_chatRoom_fkey" FOREIGN KEY ("chatRoom") REFERENCES "AIChatRoom"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AIChatRoomMessaages" ADD CONSTRAINT "AIChatRoomMessaages_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ContactSuport" ADD CONSTRAINT "ContactSuport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "RecentActions" ADD CONSTRAINT "RecentActions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Subscriptions" ADD CONSTRAINT "Subscriptions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AstrologyInsightContent" ADD CONSTRAINT "AstrologyInsightContent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "astrology_charts" ADD CONSTRAINT "astrology_charts_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "planetary_positions" ADD CONSTRAINT "planetary_positions_chartId_fkey" FOREIGN KEY ("chartId") REFERENCES "astrology_charts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "house_cusps" ADD CONSTRAINT "house_cusps_chartId_fkey" FOREIGN KEY ("chartId") REFERENCES "astrology_charts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "aspects" ADD CONSTRAINT "aspects_planetId_fkey" FOREIGN KEY ("planetId") REFERENCES "planetary_positions"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "chat_messages" ADD CONSTRAINT "chat_messages_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "chat_messages" ADD CONSTRAINT "chat_messages_aICompanionSessionId_fkey" FOREIGN KEY ("aICompanionSessionId") REFERENCES "ai_companion_sessions"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ai_companion_sessions" ADD CONSTRAINT "ai_companion_sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "meditation_sessions" ADD CONSTRAINT "meditation_sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "payments" ADD CONSTRAINT "payments_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "domestic_violence_reports" ADD CONSTRAINT "domestic_violence_reports_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "documents" ADD CONSTRAINT "documents_reportId_fkey" FOREIGN KEY ("reportId") REFERENCES "domestic_violence_reports"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "subscription_plans" ADD CONSTRAINT "subscription_plans_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AstrologyContent" ADD CONSTRAINT "AstrologyContent_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AstrologyCalculation" ADD CONSTRAINT "AstrologyCalculation_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AstrologyCalculationResponse" ADD CONSTRAINT "AstrologyCalculationResponse_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "SystemPrompt" ADD CONSTRAINT "SystemPrompt_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "AstrologyInsight" ADD CONSTRAINT "AstrologyInsight_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

