diff --git a/docker-compose.yml b/docker-compose.yml index e156f777..c5b8eb68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -275,7 +275,7 @@ services: AITM_API_URL: http://aitm-api:3001 GITNEXUS_URL: http://gitnexus:3010 AITM_GITNEXUS_ENABLED: "0" - CONTEXT7_URL: http://context7:3100 + CONTEXT7_URL: http://context7:8080 AITM_CONTEXT7_ENABLED: "0" depends_on: aitm-api: @@ -324,25 +324,25 @@ services: # --------------------------------------------------------------------------- context7: - image: node:20-alpine + build: + # Build from the context7 monorepo root so the package's pnpm workspace + + # tsconfig resolve (the upstream Dockerfile uses pnpm --frozen-lockfile). + context: ./aitimemachine/context7 + dockerfile: packages/mcp/Dockerfile container_name: context7 - working_dir: /app networks: - gitgram-net - volumes: - - ./aitimemachine/context7/packages/mcp:/app:ro - command: sh -c "npm install --if-present && node dist/index.js" + # The image serves StreamableHTTP transport on container port 8080. ports: - - "3100:3100" + - "3100:8080" environment: - NODE_ENV: development - PORT: "3100" + NODE_ENV: production healthcheck: - test: ["CMD-SHELL", "node -e \"require('http').get('http://localhost:3100/health', (r) => { process.exit(r.statusCode < 500 ? 0 : 1) }).on('error', () => process.exit(0))\""] + test: ["CMD-SHELL", "node -e \"require('http').get('http://localhost:8080/health', (r) => { process.exit(r.statusCode < 500 ? 0 : 1) }).on('error', () => process.exit(0))\""] interval: 20s timeout: 5s retries: 5 - start_period: 20s + start_period: 30s profiles: - tools restart: unless-stopped diff --git a/gitgram/backend/prisma/migrations/00000000000000_init/migration.sql b/gitgram/backend/prisma/migrations/00000000000000_init/migration.sql new file mode 100644 index 00000000..01204f3f --- /dev/null +++ b/gitgram/backend/prisma/migrations/00000000000000_init/migration.sql @@ -0,0 +1,2660 @@ +-- CreateEnum +CREATE TYPE "AccountType" AS ENUM ('USER', 'REPOSITORY', 'ORGANIZATION'); + +-- CreateEnum +CREATE TYPE "UserRole" AS ENUM ('USER', 'MODERATOR', 'ADMIN', 'SUPER_ADMIN'); + +-- CreateEnum +CREATE TYPE "ManagerRole" AS ENUM ('OWNER', 'ADMIN', 'EDITOR', 'VIEWER'); + +-- CreateEnum +CREATE TYPE "OrgRole" AS ENUM ('OWNER', 'ADMIN', 'MEMBER'); + +-- CreateEnum +CREATE TYPE "PostType" AS ENUM ('POST', 'TEXT', 'IMAGE', 'VIDEO', 'REEL', 'STORY', 'REPOSITORY', 'CHANGE_STORY'); + +-- CreateEnum +CREATE TYPE "NotificationType" AS ENUM ('LIKE', 'COMMENT', 'FOLLOW', 'MENTION', 'MESSAGE', 'REPO_UPDATE', 'STORY_REPLY'); + +-- CreateEnum +CREATE TYPE "RecurrenceType" AS ENUM ('NONE', 'DAILY', 'WEEKLY', 'MONTHLY'); + +-- CreateEnum +CREATE TYPE "ContentType" AS ENUM ('POST', 'REPOSITORY', 'REEL', 'STORY', 'SNIPPET', 'ACTIVITY'); + +-- CreateEnum +CREATE TYPE "GitHubEventType" AS ENUM ('PUSH', 'PULL_REQUEST', 'ISSUES', 'RELEASE', 'STAR', 'FORK', 'WATCH', 'CREATE', 'DELETE'); + +-- CreateEnum +CREATE TYPE "DevicePlatform" AS ENUM ('IOS', 'ANDROID', 'WEB'); + +-- CreateEnum +CREATE TYPE "ReportTargetType" AS ENUM ('POST', 'COMMENT', 'USER', 'REEL', 'STORY'); + +-- CreateEnum +CREATE TYPE "ReportReason" AS ENUM ('SPAM', 'HARASSMENT', 'INAPPROPRIATE', 'MISINFORMATION', 'OTHER'); + +-- CreateEnum +CREATE TYPE "ReportStatus" AS ENUM ('PENDING', 'REVIEWING', 'RESOLVED', 'DISMISSED'); + +-- CreateEnum +CREATE TYPE "ProfileVisitSource" AS ENUM ('SEARCH', 'POST', 'COMMENT', 'MENTION', 'SUGGESTION', 'DIRECT', 'FOLLOWERS', 'FOLLOWING', 'REPOSITORY'); + +-- CreateEnum +CREATE TYPE "TrendingTier" AS ENUM ('HOT_NOW', 'TRENDING_TODAY', 'THIS_WEEK', 'RISING_STARS'); + +-- CreateEnum +CREATE TYPE "TrendingEntityType" AS ENUM ('POST', 'REPOSITORY', 'USER'); + +-- CreateEnum +CREATE TYPE "MediaType" AS ENUM ('IMAGE', 'VIDEO'); + +-- CreateEnum +CREATE TYPE "MediaStatus" AS ENUM ('PENDING', 'PROCESSING', 'READY', 'FAILED', 'SOFT_DELETED', 'EXPIRED'); + +-- CreateEnum +CREATE TYPE "TranscodeJobStatus" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'RETRYING'); + +-- CreateTable +CREATE TABLE "Account" ( + "id" TEXT NOT NULL, + "type" "AccountType" NOT NULL, + "username" TEXT NOT NULL, + "displayName" TEXT, + "avatar" TEXT, + "bio" TEXT, + "verified" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "userId" TEXT, + "repositoryId" TEXT, + "organizationId" TEXT, + + CONSTRAINT "Account_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "email" TEXT NOT NULL, + "password" TEXT, + "username" TEXT, + "displayName" TEXT, + "avatar" TEXT, + "avatarUrl" TEXT, + "bio" TEXT, + "role" "UserRole" NOT NULL DEFAULT 'USER', + "githubId" TEXT, + "githubUsername" TEXT, + "githubAccessToken" TEXT, + "googleId" TEXT, + "emailVerified" BOOLEAN NOT NULL DEFAULT false, + "verified" BOOLEAN NOT NULL DEFAULT false, + "isPrivate" BOOLEAN NOT NULL DEFAULT false, + "adultContentEnabled" BOOLEAN NOT NULL DEFAULT false, + "isBanned" BOOLEAN NOT NULL DEFAULT false, + "bannedAt" TIMESTAMP(3), + "bannedReason" TEXT, + "isSuspended" BOOLEAN NOT NULL DEFAULT false, + "suspendedUntil" TIMESTAMP(3), + "suspendedReason" TEXT, + "warningCount" INTEGER NOT NULL DEFAULT 0, + "twoFactorEnabled" BOOLEAN NOT NULL DEFAULT false, + "twoFactorSecret" TEXT, + "interests" TEXT[] DEFAULT ARRAY[]::TEXT[], + "location" TEXT, + "latitude" DOUBLE PRECISION, + "longitude" DOUBLE PRECISION, + "lastLoginAt" TIMESTAMP(3), + "lastLoginIp" TEXT, + "lastActiveAt" TIMESTAMP(3), + "scheduledDeletion" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Session" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "refreshToken" TEXT NOT NULL, + "expiresAt" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Session_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AccountSwitchGrant" ( + "id" TEXT NOT NULL, + "ownerUserId" TEXT NOT NULL, + "targetUserId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "revokedAt" TIMESTAMP(3), + + CONSTRAINT "AccountSwitchGrant_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Repository" ( + "id" TEXT NOT NULL, + "owner" TEXT NOT NULL, + "name" TEXT NOT NULL, + "fullName" TEXT NOT NULL, + "description" TEXT, + "stars" INTEGER NOT NULL DEFAULT 0, + "forks" INTEGER NOT NULL DEFAULT 0, + "watchers" INTEGER NOT NULL DEFAULT 0, + "language" TEXT, + "topics" TEXT[], + "htmlUrl" TEXT NOT NULL, + "isPrivate" BOOLEAN NOT NULL DEFAULT false, + "ownerAvatar" TEXT, + "openIssues" INTEGER NOT NULL DEFAULT 0, + "lastFetched" TIMESTAMP(3), + "score" DOUBLE PRECISION NOT NULL DEFAULT 0, + "trendingScore" DOUBLE PRECISION NOT NULL DEFAULT 0, + "trending" BOOLEAN NOT NULL DEFAULT false, + "status" TEXT NOT NULL DEFAULT 'active', + "reactionsCount" INTEGER NOT NULL DEFAULT 0, + "commentsCount" INTEGER NOT NULL DEFAULT 0, + "postsCount" INTEGER NOT NULL DEFAULT 0, + "followersCount" INTEGER NOT NULL DEFAULT 0, + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "claimedBy" TEXT, + "claimedAt" TIMESTAMP(3), + "repositoryId" TEXT, + "organizationId" TEXT, + "lastSynced" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Repository_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RepositoryManager" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "role" "ManagerRole" NOT NULL DEFAULT 'EDITOR', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "RepositoryManager_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Organization" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "slug" TEXT NOT NULL, + "description" TEXT, + "website" TEXT, + "location" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Organization_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "OrganizationMember" ( + "id" TEXT NOT NULL, + "organizationId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "role" "OrgRole" NOT NULL DEFAULT 'MEMBER', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "OrganizationMember_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Post" ( + "id" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "projectId" TEXT, + "repositoryId" TEXT, + "content" TEXT NOT NULL, + "mediaUrls" TEXT[], + "repoUrl" TEXT, + "checkpointRef" TEXT, + "aitm_checkpoint_id" TEXT, + "aitm_project_id" TEXT, + "aitm_checkpoint_ref" JSONB, + "type" "PostType" NOT NULL DEFAULT 'POST', + "status" TEXT NOT NULL DEFAULT 'PUBLISHED', + "isArchived" BOOLEAN NOT NULL DEFAULT false, + "archivedAt" TIMESTAMP(3), + "selfLabels" TEXT[] DEFAULT ARRAY[]::TEXT[], + "contentWarning" TEXT, + "contentLanguage" TEXT, + "location" TEXT, + "latitude" DOUBLE PRECISION, + "longitude" DOUBLE PRECISION, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "commentsCount" INTEGER NOT NULL DEFAULT 0, + "sharesCount" INTEGER NOT NULL DEFAULT 0, + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Post_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Comment" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "parentId" TEXT, + "content" TEXT NOT NULL, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "isPinned" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Comment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Like" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Like_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Story" ( + "id" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "repositoryId" TEXT, + "mediaUrl" TEXT NOT NULL, + "mediaType" TEXT NOT NULL, + "caption" TEXT, + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "expiresAt" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Story_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Reel" ( + "id" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "repositoryId" TEXT, + "title" TEXT NOT NULL, + "description" TEXT, + "videoUrl" TEXT NOT NULL, + "thumbnailUrl" TEXT NOT NULL, + "duration" INTEGER NOT NULL, + "musicTrackId" TEXT, + "musicTitle" TEXT, + "musicArtist" TEXT, + "musicPreviewUrl" TEXT, + "musicArtworkUrl" TEXT, + "musicStartTime" INTEGER, + "effectId" TEXT, + "trimStart" DOUBLE PRECISION, + "trimEnd" DOUBLE PRECISION, + "thumbnailTime" DOUBLE PRECISION, + "isArchived" BOOLEAN NOT NULL DEFAULT false, + "archivedAt" TIMESTAMP(3), + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "commentsCount" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Reel_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Follow" ( + "id" TEXT NOT NULL, + "followerId" TEXT NOT NULL, + "followingId" TEXT NOT NULL, + "followerUserId" TEXT, + "followingUserId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Follow_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Message" ( + "id" TEXT NOT NULL, + "senderId" TEXT NOT NULL, + "receiverId" TEXT NOT NULL, + "chatId" TEXT, + "content" TEXT NOT NULL, + "mediaUrl" TEXT, + "read" BOOLEAN NOT NULL DEFAULT false, + "readAt" TIMESTAMP(3), + "deliveredAt" TIMESTAMP(3), + "editedAt" TIMESTAMP(3), + "deletedForSender" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Message_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MessageReaction" ( + "id" TEXT NOT NULL, + "messageId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "emoji" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "MessageReaction_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Notification" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "type" "NotificationType" NOT NULL, + "actorId" TEXT, + "postId" TEXT, + "content" TEXT NOT NULL, + "read" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Notification_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Subscription" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "tier" TEXT NOT NULL DEFAULT 'free', + "plan" TEXT, + "status" TEXT NOT NULL DEFAULT 'active', + "polarCustomerId" TEXT, + "polarSubscriptionId" TEXT, + "currentPeriodEnd" TIMESTAMP(3), + "expiresAt" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Subscription_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TwoFactorAuth" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "secret" TEXT NOT NULL, + "enabled" BOOLEAN NOT NULL DEFAULT false, + "backupCodes" TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "TwoFactorAuth_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "CodeSnippet" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "repositoryId" TEXT, + "title" TEXT NOT NULL, + "description" TEXT, + "code" TEXT NOT NULL, + "language" TEXT NOT NULL, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "CodeSnippet_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Hashtag" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Hashtag_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PostHashtag" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "hashtagId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "PostHashtag_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "SavedCollection" ( + "id" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "name" TEXT NOT NULL, + "description" TEXT, + "coverImage" TEXT, + "isPrivate" BOOLEAN NOT NULL DEFAULT false, + "isDefault" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "SavedCollection_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "SavedPost" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "postId" TEXT NOT NULL, + "collectionId" TEXT, + "savedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "SavedPost_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "SavedPostCollection" ( + "id" TEXT NOT NULL, + "savedPostId" TEXT NOT NULL, + "collectionId" TEXT NOT NULL, + "addedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "SavedPostCollection_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ScheduledPost" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "content" TEXT NOT NULL, + "mediaUrls" TEXT[], + "scheduledFor" TIMESTAMP(3) NOT NULL, + "published" BOOLEAN NOT NULL DEFAULT false, + "publishedAt" TIMESTAMP(3), + "status" TEXT NOT NULL DEFAULT 'pending', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "timezone" TEXT NOT NULL DEFAULT 'UTC', + "recurrenceType" "RecurrenceType" NOT NULL DEFAULT 'NONE', + "recurrenceEndDate" TIMESTAMP(3), + "parentPostId" TEXT, + "publishedPostId" TEXT, + + CONSTRAINT "ScheduledPost_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Advertisement" ( + "id" TEXT NOT NULL, + "advertiserId" TEXT NOT NULL, + "campaignId" TEXT, + "title" TEXT NOT NULL, + "content" TEXT NOT NULL, + "mediaUrl" TEXT, + "targetUrl" TEXT NOT NULL, + "callToAction" TEXT, + "placement" TEXT[] DEFAULT ARRAY[]::TEXT[], + "priority" INTEGER NOT NULL DEFAULT 0, + "targetAudience" TEXT, + "budget" DOUBLE PRECISION NOT NULL DEFAULT 0, + "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, + "impressions" INTEGER NOT NULL DEFAULT 0, + "clicks" INTEGER NOT NULL DEFAULT 0, + "conversions" INTEGER NOT NULL DEFAULT 0, + "status" TEXT NOT NULL DEFAULT 'draft', + "type" TEXT NOT NULL DEFAULT 'banner', + "startDate" TIMESTAMP(3), + "endDate" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Advertisement_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ModerationLog" ( + "id" TEXT NOT NULL, + "moderatorId" TEXT NOT NULL, + "action" TEXT NOT NULL, + "targetType" TEXT NOT NULL, + "targetId" TEXT NOT NULL, + "reason" TEXT, + "metadata" TEXT, + "automated" BOOLEAN NOT NULL DEFAULT false, + "appealable" BOOLEAN NOT NULL DEFAULT true, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ModerationLog_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UserBlock" ( + "id" TEXT NOT NULL, + "blockerId" TEXT NOT NULL, + "blockedId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "UserBlock_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RepositoryFollow" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "repositoryId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "RepositoryFollow_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "GitHubWebhook" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "webhookId" INTEGER, + "secret" TEXT NOT NULL, + "events" "GitHubEventType"[], + "active" BOOLEAN NOT NULL DEFAULT true, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "GitHubWebhook_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RepositoryActivity" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "eventType" "GitHubEventType" NOT NULL, + "eventId" TEXT NOT NULL, + "action" TEXT, + "actorLogin" TEXT NOT NULL, + "actorAvatar" TEXT, + "actorUrl" TEXT, + "title" TEXT, + "body" TEXT, + "url" TEXT, + "ref" TEXT, + "sha" TEXT, + "metadata" JSONB, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "commentsCount" INTEGER NOT NULL DEFAULT 0, + "occurredAt" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "RepositoryActivity_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Interaction" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "contentType" "ContentType" NOT NULL, + "contentId" TEXT NOT NULL, + "type" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Interaction_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UnifiedComment" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "contentType" "ContentType" NOT NULL, + "contentId" TEXT NOT NULL, + "content" TEXT NOT NULL, + "parentId" TEXT, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "UnifiedComment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Project" ( + "id" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "userId" TEXT, + "githubId" TEXT, + "owner" TEXT, + "name" TEXT NOT NULL, + "fullName" TEXT, + "url" TEXT, + "description" TEXT, + "repoUrl" TEXT, + "demoUrl" TEXT, + "imageUrl" TEXT, + "language" TEXT, + "tags" TEXT[], + "stars" INTEGER NOT NULL DEFAULT 0, + "forks" INTEGER NOT NULL DEFAULT 0, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "viewsCount" INTEGER NOT NULL DEFAULT 0, + "location" TEXT, + "latitude" DOUBLE PRECISION, + "longitude" DOUBLE PRECISION, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Project_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Analytics" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "views" INTEGER NOT NULL DEFAULT 0, + "likes" INTEGER NOT NULL DEFAULT 0, + "comments" INTEGER NOT NULL DEFAULT 0, + "shares" INTEGER NOT NULL DEFAULT 0, + "followers" INTEGER NOT NULL DEFAULT 0, + "reach" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "Analytics_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Chat" ( + "id" TEXT NOT NULL, + "name" TEXT, + "isGroup" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Chat_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ChatMember" ( + "id" TEXT NOT NULL, + "chatId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "role" TEXT NOT NULL DEFAULT 'member', + "joinedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ChatMember_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "NotificationPreferences" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "likes" BOOLEAN NOT NULL DEFAULT true, + "comments" BOOLEAN NOT NULL DEFAULT true, + "follows" BOOLEAN NOT NULL DEFAULT true, + "mentions" BOOLEAN NOT NULL DEFAULT true, + "messages" BOOLEAN NOT NULL DEFAULT true, + "posts" BOOLEAN NOT NULL DEFAULT true, + "emailDigest" BOOLEAN NOT NULL DEFAULT false, + "pushEnabled" BOOLEAN NOT NULL DEFAULT true, + + CONSTRAINT "NotificationPreferences_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PushDevice" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "pushToken" TEXT NOT NULL, + "platform" "DevicePlatform" NOT NULL, + "deviceName" TEXT, + "webPushSubscription" TEXT, + "active" BOOLEAN NOT NULL DEFAULT true, + "lastUsed" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "PushDevice_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PostReport" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "reporterId" TEXT, + "userId" TEXT, + "reason" TEXT NOT NULL, + "description" TEXT, + "status" TEXT NOT NULL DEFAULT 'pending', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "PostReport_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PostShare" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "PostShare_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ReelComment" ( + "id" TEXT NOT NULL, + "reelId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "content" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ReelComment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ReelLike" ( + "id" TEXT NOT NULL, + "reelId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ReelLike_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ReelView" ( + "id" TEXT NOT NULL, + "reelId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "viewedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ReelView_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RepositoryBookmark" ( + "id" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "repositoryId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "RepositoryBookmark_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoryView" ( + "id" TEXT NOT NULL, + "storyId" TEXT NOT NULL, + "accountId" TEXT, + "userId" TEXT, + "viewedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "duration" INTEGER, + "completed" BOOLEAN NOT NULL DEFAULT false, + "source" TEXT, + "deviceType" TEXT, + + CONSTRAINT "StoryView_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoryReaction" ( + "id" TEXT NOT NULL, + "storyId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "type" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "StoryReaction_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoryReply" ( + "id" TEXT NOT NULL, + "storyId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "content" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "StoryReply_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UserLanguagePreference" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "language" TEXT NOT NULL, + "weight" DOUBLE PRECISION NOT NULL DEFAULT 1.0, + "score" DOUBLE PRECISION NOT NULL DEFAULT 0, + + CONSTRAINT "UserLanguagePreference_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UserTopicInterest" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "topic" TEXT NOT NULL, + "weight" DOUBLE PRECISION NOT NULL DEFAULT 1.0, + "score" DOUBLE PRECISION NOT NULL DEFAULT 0, + + CONSTRAINT "UserTopicInterest_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "LinkedAccount" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "provider" TEXT NOT NULL, + "providerId" TEXT NOT NULL, + "email" TEXT, + "username" TEXT, + "avatar" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "LinkedAccount_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "CommentLike" ( + "id" TEXT NOT NULL, + "commentId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "CommentLike_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "FollowRequest" ( + "id" TEXT NOT NULL, + "requesterId" TEXT NOT NULL, + "targetId" TEXT NOT NULL, + "status" TEXT NOT NULL DEFAULT 'pending', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "FollowRequest_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PasswordResetToken" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "token" TEXT NOT NULL, + "expiresAt" TIMESTAMP(3) NOT NULL, + "used" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "PasswordResetToken_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "EmailVerificationToken" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "token" TEXT NOT NULL, + "expiresAt" TIMESTAMP(3) NOT NULL, + "used" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "EmailVerificationToken_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoryArchive" ( + "id" TEXT NOT NULL, + "storyId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "mediaUrl" TEXT NOT NULL, + "mediaType" TEXT NOT NULL, + "caption" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "StoryArchive_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StorySettings" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "allowReplies" BOOLEAN NOT NULL DEFAULT true, + "hideFrom" TEXT[] DEFAULT ARRAY[]::TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "StorySettings_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoryHighlight" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "coverImage" TEXT, + "archiveIds" TEXT[] DEFAULT ARRAY[]::TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "StoryHighlight_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PostDraft" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "content" TEXT, + "mediaUrls" TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "PostDraft_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UserWebhook" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "url" TEXT NOT NULL, + "secret" TEXT, + "events" TEXT[], + "active" BOOLEAN NOT NULL DEFAULT true, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "UserWebhook_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "WebhookDelivery" ( + "id" TEXT NOT NULL, + "webhookId" TEXT NOT NULL, + "event" TEXT NOT NULL, + "payload" JSONB NOT NULL, + "statusCode" INTEGER, + "response" TEXT, + "success" BOOLEAN NOT NULL DEFAULT false, + "error" TEXT, + "duration" INTEGER, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "WebhookDelivery_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ABTestConversion" ( + "id" TEXT NOT NULL, + "experimentId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "variant" TEXT NOT NULL, + "metric" TEXT NOT NULL, + "value" DOUBLE PRECISION NOT NULL DEFAULT 1, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "ABTestConversion_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Report" ( + "id" TEXT NOT NULL, + "reporterId" TEXT NOT NULL, + "targetType" "ReportTargetType" NOT NULL, + "targetId" TEXT NOT NULL, + "reason" "ReportReason" NOT NULL, + "description" TEXT, + "status" "ReportStatus" NOT NULL DEFAULT 'PENDING', + "priority" INTEGER NOT NULL DEFAULT 0, + "escalated" BOOLEAN NOT NULL DEFAULT false, + "autoFlagged" BOOLEAN NOT NULL DEFAULT false, + "resolvedAt" TIMESTAMP(3), + "resolvedBy" TEXT, + "resolution" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Report_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ModerationAppeal" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "moderationLogId" TEXT NOT NULL, + "appealText" TEXT NOT NULL, + "status" TEXT NOT NULL DEFAULT 'PENDING', + "reviewedBy" TEXT, + "reviewedAt" TIMESTAMP(3), + "reviewNotes" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "ModerationAppeal_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "EmailPreferences" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "marketingEmails" BOOLEAN NOT NULL DEFAULT true, + "newFollowerEmails" BOOLEAN NOT NULL DEFAULT true, + "commentEmails" BOOLEAN NOT NULL DEFAULT true, + "likeEmails" BOOLEAN NOT NULL DEFAULT false, + "mentionEmails" BOOLEAN NOT NULL DEFAULT true, + "weeklyDigest" BOOLEAN NOT NULL DEFAULT true, + "securityAlerts" BOOLEAN NOT NULL DEFAULT true, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "EmailPreferences_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "LinkPreview" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "url" TEXT NOT NULL, + "title" TEXT, + "description" TEXT, + "image" TEXT, + "siteName" TEXT, + "favicon" TEXT, + "domain" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "LinkPreview_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ProfileVisit" ( + "id" TEXT NOT NULL, + "visitorId" TEXT, + "visitedUserId" TEXT NOT NULL, + "visitedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "source" "ProfileVisitSource" NOT NULL DEFAULT 'DIRECT', + + CONSTRAINT "ProfileVisit_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "ProfilePrivacySettings" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "profileVisitsEnabled" BOOLEAN NOT NULL DEFAULT true, + "showProfileVisitors" BOOLEAN NOT NULL DEFAULT true, + + CONSTRAINT "ProfilePrivacySettings_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PostView" ( + "id" TEXT NOT NULL, + "postId" TEXT NOT NULL, + "viewerId" TEXT, + "sessionId" TEXT, + "ipHash" TEXT, + "country" TEXT, + "city" TEXT, + "deviceType" TEXT, + "source" TEXT, + "referrer" TEXT, + "isFollower" BOOLEAN NOT NULL DEFAULT false, + "duration" INTEGER, + "profileVisit" BOOLEAN NOT NULL DEFAULT false, + "viewedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "PostView_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TrendingEntry" ( + "id" TEXT NOT NULL, + "entityType" "TrendingEntityType" NOT NULL, + "entityId" TEXT NOT NULL, + "tier" "TrendingTier" NOT NULL, + "score" DOUBLE PRECISION NOT NULL DEFAULT 0, + "rawScore" DOUBLE PRECISION NOT NULL DEFAULT 0, + "gamingPenalty" DOUBLE PRECISION NOT NULL DEFAULT 0, + "language" TEXT, + "topic" TEXT, + "rank" INTEGER NOT NULL DEFAULT 0, + "metadata" JSONB, + "periodStart" TIMESTAMP(3) NOT NULL, + "periodEnd" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "TrendingEntry_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TrendingHistory" ( + "id" TEXT NOT NULL, + "entityType" "TrendingEntityType" NOT NULL, + "entityId" TEXT NOT NULL, + "tier" "TrendingTier" NOT NULL, + "score" DOUBLE PRECISION NOT NULL, + "rank" INTEGER NOT NULL, + "snapshotAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "TrendingHistory_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "EngagementAnomaly" ( + "id" TEXT NOT NULL, + "entityType" TEXT NOT NULL, + "entityId" TEXT NOT NULL, + "anomalyType" TEXT NOT NULL, + "severity" DOUBLE PRECISION NOT NULL DEFAULT 0, + "details" JSONB, + "actorIds" TEXT[], + "resolved" BOOLEAN NOT NULL DEFAULT false, + "resolvedAt" TIMESTAMP(3), + "resolvedBy" TEXT, + "detectedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "EngagementAnomaly_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TrendingSignalWeight" ( + "id" TEXT NOT NULL, + "signalName" TEXT NOT NULL, + "weight" DOUBLE PRECISION NOT NULL DEFAULT 1.0, + "category" TEXT NOT NULL, + "description" TEXT, + "active" BOOLEAN NOT NULL DEFAULT true, + "updatedAt" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "TrendingSignalWeight_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Media" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "type" "MediaType" NOT NULL, + "status" "MediaStatus" NOT NULL DEFAULT 'PENDING', + "originalUrl" TEXT NOT NULL, + "processedUrl" TEXT, + "thumbnailUrl" TEXT, + "webpUrl" TEXT, + "originalFilename" TEXT NOT NULL, + "mimeType" TEXT NOT NULL, + "fileSize" INTEGER NOT NULL, + "fileHash" TEXT NOT NULL, + "width" INTEGER, + "height" INTEGER, + "duration" INTEGER, + "postId" TEXT, + "reelId" TEXT, + "storyId" TEXT, + "contentType" TEXT, + "nsfwScore" DOUBLE PRECISION, + "nsfwChecked" BOOLEAN NOT NULL DEFAULT false, + "flagged" BOOLEAN NOT NULL DEFAULT false, + "flagReason" TEXT, + "isPublic" BOOLEAN NOT NULL DEFAULT false, + "softDeletedAt" TIMESTAMP(3), + "retentionDays" INTEGER NOT NULL DEFAULT 30, + "expiresAt" TIMESTAMP(3), + "resolutions" JSONB, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Media_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "TranscodeJob" ( + "id" TEXT NOT NULL, + "mediaId" TEXT NOT NULL, + "status" "TranscodeJobStatus" NOT NULL DEFAULT 'QUEUED', + "resolution" TEXT NOT NULL, + "format" TEXT NOT NULL, + "inputUrl" TEXT NOT NULL, + "outputUrl" TEXT, + "outputSize" INTEGER, + "errorMessage" TEXT, + "attempts" INTEGER NOT NULL DEFAULT 0, + "maxAttempts" INTEGER NOT NULL DEFAULT 3, + "startedAt" TIMESTAMP(3), + "completedAt" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "TranscodeJob_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MediaUploadQuota" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "date" DATE NOT NULL, + "imageCount" INTEGER NOT NULL DEFAULT 0, + "videoCount" INTEGER NOT NULL DEFAULT 0, + "totalBytes" BIGINT NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "MediaUploadQuota_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MediaFingerprint" ( + "id" TEXT NOT NULL, + "hash" TEXT NOT NULL, + "hashType" TEXT NOT NULL DEFAULT 'sha256', + "reason" TEXT, + "isBlocked" BOOLEAN NOT NULL DEFAULT false, + "reportCount" INTEGER NOT NULL DEFAULT 0, + "firstSeenAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "lastSeenAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "MediaFingerprint_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "UnfollowLog" ( + "id" TEXT NOT NULL, + "unfollowerId" TEXT NOT NULL, + "unfollowedId" TEXT NOT NULL, + "followedAt" TIMESTAMP(3), + "unfollowedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "followDuration" INTEGER, + + CONSTRAINT "UnfollowLog_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "RepositoryAitmSettings" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "aitmProjectId" TEXT NOT NULL, + "encryptedApiKey" TEXT NOT NULL, + "autoGenerateStories" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "RepositoryAitmSettings_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "stars" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "stars_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "repository_referrers" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "source" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + "uniqueCount" INTEGER NOT NULL DEFAULT 0, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "repository_referrers_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "repository_path_views" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "path" TEXT NOT NULL, + "views" INTEGER NOT NULL DEFAULT 0, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "repository_path_views_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "repository_clones" ( + "id" TEXT NOT NULL, + "repositoryId" TEXT NOT NULL, + "count" INTEGER NOT NULL DEFAULT 0, + "uniqueCount" INTEGER NOT NULL DEFAULT 0, + "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "repository_clones_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "audit_logs" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "action" TEXT NOT NULL, + "metadata" JSONB, + "ipAddress" TEXT, + "userAgent" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "audit_logs_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StoreItem" ( + "id" TEXT NOT NULL, + "sellerId" TEXT NOT NULL, + "title" TEXT NOT NULL, + "description" TEXT, + "price" DOUBLE PRECISION NOT NULL DEFAULT 0, + "category" TEXT NOT NULL DEFAULT 'other', + "images" TEXT[] DEFAULT ARRAY[]::TEXT[], + "status" TEXT NOT NULL DEFAULT 'active', + "polarProductId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "StoreItem_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "StorePurchase" ( + "id" TEXT NOT NULL, + "itemId" TEXT NOT NULL, + "buyerId" TEXT NOT NULL, + "sellerId" TEXT NOT NULL, + "amount" DOUBLE PRECISION NOT NULL DEFAULT 0, + "status" TEXT NOT NULL DEFAULT 'pending', + "provider" TEXT NOT NULL DEFAULT 'internal', + "checkoutId" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "completedAt" TIMESTAMP(3), + + CONSTRAINT "StorePurchase_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Moment" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "screenshotUrl" TEXT NOT NULL, + "selfieUrl" TEXT NOT NULL, + "caption" TEXT, + "location" TEXT, + "likesCount" INTEGER NOT NULL DEFAULT 0, + "commentsCount" INTEGER NOT NULL DEFAULT 0, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "expiresAt" TIMESTAMP(3), + + CONSTRAINT "Moment_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MomentLike" ( + "id" TEXT NOT NULL, + "momentId" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "MomentLike_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Feedback" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "type" TEXT NOT NULL DEFAULT 'other', + "title" TEXT NOT NULL, + "content" TEXT NOT NULL, + "screenshotUrl" TEXT, + "status" TEXT NOT NULL DEFAULT 'open', + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Feedback_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AdCampaign" ( + "id" TEXT NOT NULL, + "advertiserId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "description" TEXT, + "type" TEXT NOT NULL DEFAULT 'post', + "budget" DOUBLE PRECISION NOT NULL DEFAULT 0, + "dailyBudget" DOUBLE PRECISION, + "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, + "billingType" TEXT NOT NULL DEFAULT 'cpc', + "status" TEXT NOT NULL DEFAULT 'active', + "targetAudience" TEXT, + "startDate" TIMESTAMP(3), + "endDate" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "AdCampaign_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "AdPreferences" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "personalizedAds" BOOLEAN NOT NULL DEFAULT true, + "interestCategories" TEXT[] DEFAULT ARRAY[]::TEXT[], + "optOut" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "AdPreferences_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "MutedWord" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "value" TEXT NOT NULL, + "targets" TEXT[] DEFAULT ARRAY['content']::TEXT[], + "actorTarget" TEXT NOT NULL DEFAULT 'all', + "expiresAt" TIMESTAMP(3), + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "MutedWord_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_username_key" ON "Account"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_userId_key" ON "Account"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_repositoryId_key" ON "Account"("repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_organizationId_key" ON "Account"("organizationId"); + +-- CreateIndex +CREATE INDEX "Account_type_idx" ON "Account"("type"); + +-- CreateIndex +CREATE INDEX "Account_username_idx" ON "Account"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_githubId_key" ON "User"("githubId"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_googleId_key" ON "User"("googleId"); + +-- CreateIndex +CREATE INDEX "User_email_idx" ON "User"("email"); + +-- CreateIndex +CREATE INDEX "User_githubId_idx" ON "User"("githubId"); + +-- CreateIndex +CREATE INDEX "User_username_idx" ON "User"("username"); + +-- CreateIndex +CREATE UNIQUE INDEX "Session_refreshToken_key" ON "Session"("refreshToken"); + +-- CreateIndex +CREATE INDEX "Session_userId_idx" ON "Session"("userId"); + +-- CreateIndex +CREATE INDEX "AccountSwitchGrant_ownerUserId_idx" ON "AccountSwitchGrant"("ownerUserId"); + +-- CreateIndex +CREATE INDEX "AccountSwitchGrant_targetUserId_idx" ON "AccountSwitchGrant"("targetUserId"); + +-- CreateIndex +CREATE UNIQUE INDEX "AccountSwitchGrant_ownerUserId_targetUserId_key" ON "AccountSwitchGrant"("ownerUserId", "targetUserId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Repository_fullName_key" ON "Repository"("fullName"); + +-- CreateIndex +CREATE INDEX "Repository_owner_idx" ON "Repository"("owner"); + +-- CreateIndex +CREATE INDEX "Repository_claimedBy_idx" ON "Repository"("claimedBy"); + +-- CreateIndex +CREATE INDEX "Repository_organizationId_idx" ON "Repository"("organizationId"); + +-- CreateIndex +CREATE INDEX "Repository_trending_idx" ON "Repository"("trending"); + +-- CreateIndex +CREATE UNIQUE INDEX "Repository_owner_name_key" ON "Repository"("owner", "name"); + +-- CreateIndex +CREATE INDEX "RepositoryManager_userId_idx" ON "RepositoryManager"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryManager_repositoryId_userId_key" ON "RepositoryManager"("repositoryId", "userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Organization_slug_key" ON "Organization"("slug"); + +-- CreateIndex +CREATE INDEX "Organization_slug_idx" ON "Organization"("slug"); + +-- CreateIndex +CREATE INDEX "OrganizationMember_userId_idx" ON "OrganizationMember"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "OrganizationMember_organizationId_userId_key" ON "OrganizationMember"("organizationId", "userId"); + +-- CreateIndex +CREATE INDEX "Post_accountId_idx" ON "Post"("accountId"); + +-- CreateIndex +CREATE INDEX "Post_userId_idx" ON "Post"("userId"); + +-- CreateIndex +CREATE INDEX "Post_repositoryId_idx" ON "Post"("repositoryId"); + +-- CreateIndex +CREATE INDEX "Post_checkpointRef_idx" ON "Post"("checkpointRef"); + +-- CreateIndex +CREATE INDEX "Post_aitm_checkpoint_id_idx" ON "Post"("aitm_checkpoint_id"); + +-- CreateIndex +CREATE INDEX "Post_aitm_project_id_idx" ON "Post"("aitm_project_id"); + +-- CreateIndex +CREATE INDEX "Post_createdAt_idx" ON "Post"("createdAt"); + +-- CreateIndex +CREATE INDEX "Post_isArchived_idx" ON "Post"("isArchived"); + +-- CreateIndex +CREATE INDEX "Post_contentLanguage_idx" ON "Post"("contentLanguage"); + +-- CreateIndex +CREATE INDEX "Comment_postId_idx" ON "Comment"("postId"); + +-- CreateIndex +CREATE INDEX "Comment_parentId_idx" ON "Comment"("parentId"); + +-- CreateIndex +CREATE INDEX "Comment_accountId_idx" ON "Comment"("accountId"); + +-- CreateIndex +CREATE INDEX "Comment_userId_idx" ON "Comment"("userId"); + +-- CreateIndex +CREATE INDEX "Like_postId_idx" ON "Like"("postId"); + +-- CreateIndex +CREATE INDEX "Like_accountId_idx" ON "Like"("accountId"); + +-- CreateIndex +CREATE INDEX "Like_userId_idx" ON "Like"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Like_postId_accountId_key" ON "Like"("postId", "accountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Like_postId_userId_key" ON "Like"("postId", "userId"); + +-- CreateIndex +CREATE INDEX "Story_accountId_idx" ON "Story"("accountId"); + +-- CreateIndex +CREATE INDEX "Story_userId_idx" ON "Story"("userId"); + +-- CreateIndex +CREATE INDEX "Story_repositoryId_idx" ON "Story"("repositoryId"); + +-- CreateIndex +CREATE INDEX "Story_expiresAt_idx" ON "Story"("expiresAt"); + +-- CreateIndex +CREATE INDEX "Reel_accountId_idx" ON "Reel"("accountId"); + +-- CreateIndex +CREATE INDEX "Reel_userId_idx" ON "Reel"("userId"); + +-- CreateIndex +CREATE INDEX "Reel_repositoryId_idx" ON "Reel"("repositoryId"); + +-- CreateIndex +CREATE INDEX "Reel_createdAt_idx" ON "Reel"("createdAt"); + +-- CreateIndex +CREATE INDEX "Reel_isArchived_idx" ON "Reel"("isArchived"); + +-- CreateIndex +CREATE INDEX "Follow_followerId_idx" ON "Follow"("followerId"); + +-- CreateIndex +CREATE INDEX "Follow_followingId_idx" ON "Follow"("followingId"); + +-- CreateIndex +CREATE INDEX "Follow_followerUserId_idx" ON "Follow"("followerUserId"); + +-- CreateIndex +CREATE INDEX "Follow_followingUserId_idx" ON "Follow"("followingUserId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Follow_followerId_followingId_key" ON "Follow"("followerId", "followingId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Follow_followerUserId_followingUserId_key" ON "Follow"("followerUserId", "followingUserId"); + +-- CreateIndex +CREATE INDEX "Message_senderId_idx" ON "Message"("senderId"); + +-- CreateIndex +CREATE INDEX "Message_receiverId_idx" ON "Message"("receiverId"); + +-- CreateIndex +CREATE INDEX "Message_chatId_idx" ON "Message"("chatId"); + +-- CreateIndex +CREATE INDEX "Message_createdAt_idx" ON "Message"("createdAt"); + +-- CreateIndex +CREATE INDEX "Message_read_idx" ON "Message"("read"); + +-- CreateIndex +CREATE INDEX "MessageReaction_messageId_idx" ON "MessageReaction"("messageId"); + +-- CreateIndex +CREATE INDEX "MessageReaction_userId_idx" ON "MessageReaction"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "MessageReaction_messageId_userId_emoji_key" ON "MessageReaction"("messageId", "userId", "emoji"); + +-- CreateIndex +CREATE INDEX "Notification_accountId_idx" ON "Notification"("accountId"); + +-- CreateIndex +CREATE INDEX "Notification_userId_idx" ON "Notification"("userId"); + +-- CreateIndex +CREATE INDEX "Notification_read_idx" ON "Notification"("read"); + +-- CreateIndex +CREATE INDEX "Notification_createdAt_idx" ON "Notification"("createdAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "Notification_userId_id_key" ON "Notification"("userId", "id"); + +-- CreateIndex +CREATE UNIQUE INDEX "Subscription_userId_key" ON "Subscription"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Subscription_polarCustomerId_key" ON "Subscription"("polarCustomerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Subscription_polarSubscriptionId_key" ON "Subscription"("polarSubscriptionId"); + +-- CreateIndex +CREATE INDEX "Subscription_userId_idx" ON "Subscription"("userId"); + +-- CreateIndex +CREATE INDEX "Subscription_polarCustomerId_idx" ON "Subscription"("polarCustomerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "TwoFactorAuth_userId_key" ON "TwoFactorAuth"("userId"); + +-- CreateIndex +CREATE INDEX "CodeSnippet_accountId_idx" ON "CodeSnippet"("accountId"); + +-- CreateIndex +CREATE INDEX "CodeSnippet_userId_idx" ON "CodeSnippet"("userId"); + +-- CreateIndex +CREATE INDEX "CodeSnippet_repositoryId_idx" ON "CodeSnippet"("repositoryId"); + +-- CreateIndex +CREATE INDEX "CodeSnippet_language_idx" ON "CodeSnippet"("language"); + +-- CreateIndex +CREATE UNIQUE INDEX "Hashtag_name_key" ON "Hashtag"("name"); + +-- CreateIndex +CREATE INDEX "Hashtag_count_idx" ON "Hashtag"("count"); + +-- CreateIndex +CREATE INDEX "PostHashtag_postId_idx" ON "PostHashtag"("postId"); + +-- CreateIndex +CREATE UNIQUE INDEX "PostHashtag_postId_hashtagId_key" ON "PostHashtag"("postId", "hashtagId"); + +-- CreateIndex +CREATE INDEX "SavedCollection_accountId_idx" ON "SavedCollection"("accountId"); + +-- CreateIndex +CREATE INDEX "SavedCollection_userId_idx" ON "SavedCollection"("userId"); + +-- CreateIndex +CREATE INDEX "SavedCollection_isDefault_idx" ON "SavedCollection"("isDefault"); + +-- CreateIndex +CREATE UNIQUE INDEX "SavedCollection_userId_name_key" ON "SavedCollection"("userId", "name"); + +-- CreateIndex +CREATE INDEX "SavedPost_accountId_idx" ON "SavedPost"("accountId"); + +-- CreateIndex +CREATE INDEX "SavedPost_userId_idx" ON "SavedPost"("userId"); + +-- CreateIndex +CREATE INDEX "SavedPost_postId_idx" ON "SavedPost"("postId"); + +-- CreateIndex +CREATE INDEX "SavedPost_savedAt_idx" ON "SavedPost"("savedAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "SavedPost_accountId_postId_key" ON "SavedPost"("accountId", "postId"); + +-- CreateIndex +CREATE UNIQUE INDEX "SavedPost_userId_postId_key" ON "SavedPost"("userId", "postId"); + +-- CreateIndex +CREATE INDEX "SavedPostCollection_savedPostId_idx" ON "SavedPostCollection"("savedPostId"); + +-- CreateIndex +CREATE INDEX "SavedPostCollection_collectionId_idx" ON "SavedPostCollection"("collectionId"); + +-- CreateIndex +CREATE UNIQUE INDEX "SavedPostCollection_savedPostId_collectionId_key" ON "SavedPostCollection"("savedPostId", "collectionId"); + +-- CreateIndex +CREATE INDEX "ScheduledPost_accountId_idx" ON "ScheduledPost"("accountId"); + +-- CreateIndex +CREATE INDEX "ScheduledPost_userId_idx" ON "ScheduledPost"("userId"); + +-- CreateIndex +CREATE INDEX "ScheduledPost_scheduledFor_idx" ON "ScheduledPost"("scheduledFor"); + +-- CreateIndex +CREATE INDEX "ScheduledPost_status_idx" ON "ScheduledPost"("status"); + +-- CreateIndex +CREATE INDEX "ScheduledPost_parentPostId_idx" ON "ScheduledPost"("parentPostId"); + +-- CreateIndex +CREATE INDEX "Advertisement_advertiserId_idx" ON "Advertisement"("advertiserId"); + +-- CreateIndex +CREATE INDEX "Advertisement_campaignId_idx" ON "Advertisement"("campaignId"); + +-- CreateIndex +CREATE INDEX "Advertisement_status_idx" ON "Advertisement"("status"); + +-- CreateIndex +CREATE INDEX "ModerationLog_moderatorId_idx" ON "ModerationLog"("moderatorId"); + +-- CreateIndex +CREATE INDEX "ModerationLog_targetType_targetId_idx" ON "ModerationLog"("targetType", "targetId"); + +-- CreateIndex +CREATE INDEX "ModerationLog_action_idx" ON "ModerationLog"("action"); + +-- CreateIndex +CREATE INDEX "ModerationLog_createdAt_idx" ON "ModerationLog"("createdAt"); + +-- CreateIndex +CREATE INDEX "UserBlock_blockerId_idx" ON "UserBlock"("blockerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "UserBlock_blockerId_blockedId_key" ON "UserBlock"("blockerId", "blockedId"); + +-- CreateIndex +CREATE INDEX "RepositoryFollow_accountId_idx" ON "RepositoryFollow"("accountId"); + +-- CreateIndex +CREATE INDEX "RepositoryFollow_userId_idx" ON "RepositoryFollow"("userId"); + +-- CreateIndex +CREATE INDEX "RepositoryFollow_repositoryId_idx" ON "RepositoryFollow"("repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryFollow_accountId_repositoryId_key" ON "RepositoryFollow"("accountId", "repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryFollow_userId_repositoryId_key" ON "RepositoryFollow"("userId", "repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "GitHubWebhook_repositoryId_key" ON "GitHubWebhook"("repositoryId"); + +-- CreateIndex +CREATE INDEX "GitHubWebhook_repositoryId_idx" ON "GitHubWebhook"("repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryActivity_eventId_key" ON "RepositoryActivity"("eventId"); + +-- CreateIndex +CREATE INDEX "RepositoryActivity_repositoryId_idx" ON "RepositoryActivity"("repositoryId"); + +-- CreateIndex +CREATE INDEX "RepositoryActivity_eventType_idx" ON "RepositoryActivity"("eventType"); + +-- CreateIndex +CREATE INDEX "RepositoryActivity_createdAt_idx" ON "RepositoryActivity"("createdAt"); + +-- CreateIndex +CREATE INDEX "RepositoryActivity_occurredAt_idx" ON "RepositoryActivity"("occurredAt"); + +-- CreateIndex +CREATE INDEX "Interaction_contentType_contentId_idx" ON "Interaction"("contentType", "contentId"); + +-- CreateIndex +CREATE INDEX "Interaction_userId_idx" ON "Interaction"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Interaction_accountId_contentType_contentId_type_key" ON "Interaction"("accountId", "contentType", "contentId", "type"); + +-- CreateIndex +CREATE UNIQUE INDEX "Interaction_userId_contentType_contentId_type_key" ON "Interaction"("userId", "contentType", "contentId", "type"); + +-- CreateIndex +CREATE INDEX "UnifiedComment_contentType_contentId_idx" ON "UnifiedComment"("contentType", "contentId"); + +-- CreateIndex +CREATE INDEX "UnifiedComment_parentId_idx" ON "UnifiedComment"("parentId"); + +-- CreateIndex +CREATE INDEX "UnifiedComment_userId_idx" ON "UnifiedComment"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Project_githubId_key" ON "Project"("githubId"); + +-- CreateIndex +CREATE INDEX "Project_accountId_idx" ON "Project"("accountId"); + +-- CreateIndex +CREATE INDEX "Project_userId_idx" ON "Project"("userId"); + +-- CreateIndex +CREATE INDEX "Project_owner_idx" ON "Project"("owner"); + +-- CreateIndex +CREATE INDEX "Analytics_accountId_idx" ON "Analytics"("accountId"); + +-- CreateIndex +CREATE INDEX "Analytics_userId_idx" ON "Analytics"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Analytics_accountId_date_key" ON "Analytics"("accountId", "date"); + +-- CreateIndex +CREATE UNIQUE INDEX "Analytics_userId_date_key" ON "Analytics"("userId", "date"); + +-- CreateIndex +CREATE INDEX "ChatMember_userId_idx" ON "ChatMember"("userId"); + +-- CreateIndex +CREATE INDEX "ChatMember_chatId_idx" ON "ChatMember"("chatId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ChatMember_chatId_accountId_key" ON "ChatMember"("chatId", "accountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ChatMember_chatId_userId_key" ON "ChatMember"("chatId", "userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "NotificationPreferences_accountId_key" ON "NotificationPreferences"("accountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "NotificationPreferences_userId_key" ON "NotificationPreferences"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "PushDevice_pushToken_key" ON "PushDevice"("pushToken"); + +-- CreateIndex +CREATE INDEX "PushDevice_userId_idx" ON "PushDevice"("userId"); + +-- CreateIndex +CREATE INDEX "PushDevice_active_idx" ON "PushDevice"("active"); + +-- CreateIndex +CREATE INDEX "PostReport_postId_idx" ON "PostReport"("postId"); + +-- CreateIndex +CREATE INDEX "PostReport_userId_idx" ON "PostReport"("userId"); + +-- CreateIndex +CREATE INDEX "PostReport_status_idx" ON "PostReport"("status"); + +-- CreateIndex +CREATE INDEX "PostShare_postId_idx" ON "PostShare"("postId"); + +-- CreateIndex +CREATE INDEX "PostShare_userId_idx" ON "PostShare"("userId"); + +-- CreateIndex +CREATE INDEX "ReelComment_reelId_idx" ON "ReelComment"("reelId"); + +-- CreateIndex +CREATE INDEX "ReelComment_userId_idx" ON "ReelComment"("userId"); + +-- CreateIndex +CREATE INDEX "ReelLike_reelId_idx" ON "ReelLike"("reelId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ReelLike_reelId_accountId_key" ON "ReelLike"("reelId", "accountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ReelLike_reelId_userId_key" ON "ReelLike"("reelId", "userId"); + +-- CreateIndex +CREATE INDEX "ReelView_reelId_idx" ON "ReelView"("reelId"); + +-- CreateIndex +CREATE INDEX "RepositoryBookmark_userId_idx" ON "RepositoryBookmark"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryBookmark_accountId_repositoryId_key" ON "RepositoryBookmark"("accountId", "repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryBookmark_userId_repositoryId_key" ON "RepositoryBookmark"("userId", "repositoryId"); + +-- CreateIndex +CREATE INDEX "StoryView_storyId_idx" ON "StoryView"("storyId"); + +-- CreateIndex +CREATE INDEX "StoryView_viewedAt_idx" ON "StoryView"("viewedAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "StoryView_storyId_accountId_key" ON "StoryView"("storyId", "accountId"); + +-- CreateIndex +CREATE UNIQUE INDEX "StoryView_storyId_userId_key" ON "StoryView"("storyId", "userId"); + +-- CreateIndex +CREATE INDEX "StoryReaction_storyId_idx" ON "StoryReaction"("storyId"); + +-- CreateIndex +CREATE UNIQUE INDEX "StoryReaction_storyId_userId_key" ON "StoryReaction"("storyId", "userId"); + +-- CreateIndex +CREATE INDEX "StoryReply_storyId_idx" ON "StoryReply"("storyId"); + +-- CreateIndex +CREATE INDEX "StoryReply_userId_idx" ON "StoryReply"("userId"); + +-- CreateIndex +CREATE INDEX "UserLanguagePreference_userId_idx" ON "UserLanguagePreference"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "UserLanguagePreference_userId_language_key" ON "UserLanguagePreference"("userId", "language"); + +-- CreateIndex +CREATE INDEX "UserTopicInterest_userId_idx" ON "UserTopicInterest"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "UserTopicInterest_userId_topic_key" ON "UserTopicInterest"("userId", "topic"); + +-- CreateIndex +CREATE INDEX "LinkedAccount_userId_idx" ON "LinkedAccount"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "LinkedAccount_provider_providerId_key" ON "LinkedAccount"("provider", "providerId"); + +-- CreateIndex +CREATE INDEX "CommentLike_commentId_idx" ON "CommentLike"("commentId"); + +-- CreateIndex +CREATE INDEX "CommentLike_userId_idx" ON "CommentLike"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "CommentLike_commentId_userId_key" ON "CommentLike"("commentId", "userId"); + +-- CreateIndex +CREATE INDEX "FollowRequest_requesterId_idx" ON "FollowRequest"("requesterId"); + +-- CreateIndex +CREATE INDEX "FollowRequest_targetId_idx" ON "FollowRequest"("targetId"); + +-- CreateIndex +CREATE INDEX "FollowRequest_status_idx" ON "FollowRequest"("status"); + +-- CreateIndex +CREATE UNIQUE INDEX "FollowRequest_requesterId_targetId_key" ON "FollowRequest"("requesterId", "targetId"); + +-- CreateIndex +CREATE UNIQUE INDEX "PasswordResetToken_token_key" ON "PasswordResetToken"("token"); + +-- CreateIndex +CREATE INDEX "PasswordResetToken_userId_idx" ON "PasswordResetToken"("userId"); + +-- CreateIndex +CREATE INDEX "PasswordResetToken_token_idx" ON "PasswordResetToken"("token"); + +-- CreateIndex +CREATE UNIQUE INDEX "EmailVerificationToken_token_key" ON "EmailVerificationToken"("token"); + +-- CreateIndex +CREATE INDEX "EmailVerificationToken_userId_idx" ON "EmailVerificationToken"("userId"); + +-- CreateIndex +CREATE INDEX "EmailVerificationToken_token_idx" ON "EmailVerificationToken"("token"); + +-- CreateIndex +CREATE UNIQUE INDEX "StoryArchive_storyId_key" ON "StoryArchive"("storyId"); + +-- CreateIndex +CREATE INDEX "StoryArchive_userId_idx" ON "StoryArchive"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "StorySettings_userId_key" ON "StorySettings"("userId"); + +-- CreateIndex +CREATE INDEX "StorySettings_userId_idx" ON "StorySettings"("userId"); + +-- CreateIndex +CREATE INDEX "StoryHighlight_userId_idx" ON "StoryHighlight"("userId"); + +-- CreateIndex +CREATE INDEX "PostDraft_userId_idx" ON "PostDraft"("userId"); + +-- CreateIndex +CREATE INDEX "UserWebhook_userId_idx" ON "UserWebhook"("userId"); + +-- CreateIndex +CREATE INDEX "UserWebhook_active_idx" ON "UserWebhook"("active"); + +-- CreateIndex +CREATE INDEX "WebhookDelivery_webhookId_idx" ON "WebhookDelivery"("webhookId"); + +-- CreateIndex +CREATE INDEX "WebhookDelivery_createdAt_idx" ON "WebhookDelivery"("createdAt"); + +-- CreateIndex +CREATE INDEX "ABTestConversion_experimentId_idx" ON "ABTestConversion"("experimentId"); + +-- CreateIndex +CREATE INDEX "ABTestConversion_userId_idx" ON "ABTestConversion"("userId"); + +-- CreateIndex +CREATE INDEX "ABTestConversion_variant_idx" ON "ABTestConversion"("variant"); + +-- CreateIndex +CREATE INDEX "ABTestConversion_createdAt_idx" ON "ABTestConversion"("createdAt"); + +-- CreateIndex +CREATE INDEX "Report_reporterId_idx" ON "Report"("reporterId"); + +-- CreateIndex +CREATE INDEX "Report_targetType_targetId_idx" ON "Report"("targetType", "targetId"); + +-- CreateIndex +CREATE INDEX "Report_status_idx" ON "Report"("status"); + +-- CreateIndex +CREATE INDEX "Report_createdAt_idx" ON "Report"("createdAt"); + +-- CreateIndex +CREATE INDEX "Report_priority_idx" ON "Report"("priority"); + +-- CreateIndex +CREATE INDEX "Report_escalated_idx" ON "Report"("escalated"); + +-- CreateIndex +CREATE INDEX "ModerationAppeal_userId_idx" ON "ModerationAppeal"("userId"); + +-- CreateIndex +CREATE INDEX "ModerationAppeal_moderationLogId_idx" ON "ModerationAppeal"("moderationLogId"); + +-- CreateIndex +CREATE INDEX "ModerationAppeal_status_idx" ON "ModerationAppeal"("status"); + +-- CreateIndex +CREATE UNIQUE INDEX "EmailPreferences_userId_key" ON "EmailPreferences"("userId"); + +-- CreateIndex +CREATE INDEX "EmailPreferences_userId_idx" ON "EmailPreferences"("userId"); + +-- CreateIndex +CREATE INDEX "LinkPreview_postId_idx" ON "LinkPreview"("postId"); + +-- CreateIndex +CREATE INDEX "LinkPreview_domain_idx" ON "LinkPreview"("domain"); + +-- CreateIndex +CREATE UNIQUE INDEX "LinkPreview_postId_url_key" ON "LinkPreview"("postId", "url"); + +-- CreateIndex +CREATE INDEX "ProfileVisit_visitedUserId_idx" ON "ProfileVisit"("visitedUserId"); + +-- CreateIndex +CREATE INDEX "ProfileVisit_visitorId_idx" ON "ProfileVisit"("visitorId"); + +-- CreateIndex +CREATE INDEX "ProfileVisit_visitedAt_idx" ON "ProfileVisit"("visitedAt"); + +-- CreateIndex +CREATE INDEX "ProfileVisit_visitedUserId_visitedAt_idx" ON "ProfileVisit"("visitedUserId", "visitedAt"); + +-- CreateIndex +CREATE INDEX "ProfileVisit_visitedUserId_visitorId_idx" ON "ProfileVisit"("visitedUserId", "visitorId"); + +-- CreateIndex +CREATE UNIQUE INDEX "ProfilePrivacySettings_userId_key" ON "ProfilePrivacySettings"("userId"); + +-- CreateIndex +CREATE INDEX "ProfilePrivacySettings_userId_idx" ON "ProfilePrivacySettings"("userId"); + +-- CreateIndex +CREATE INDEX "PostView_postId_idx" ON "PostView"("postId"); + +-- CreateIndex +CREATE INDEX "PostView_viewerId_idx" ON "PostView"("viewerId"); + +-- CreateIndex +CREATE INDEX "PostView_viewedAt_idx" ON "PostView"("viewedAt"); + +-- CreateIndex +CREATE INDEX "PostView_postId_viewedAt_idx" ON "PostView"("postId", "viewedAt"); + +-- CreateIndex +CREATE INDEX "PostView_postId_isFollower_idx" ON "PostView"("postId", "isFollower"); + +-- CreateIndex +CREATE INDEX "PostView_postId_country_idx" ON "PostView"("postId", "country"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_tier_score_idx" ON "TrendingEntry"("tier", "score"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_tier_language_idx" ON "TrendingEntry"("tier", "language"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_tier_topic_idx" ON "TrendingEntry"("tier", "topic"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_entityType_tier_idx" ON "TrendingEntry"("entityType", "tier"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_createdAt_idx" ON "TrendingEntry"("createdAt"); + +-- CreateIndex +CREATE INDEX "TrendingEntry_rank_idx" ON "TrendingEntry"("rank"); + +-- CreateIndex +CREATE UNIQUE INDEX "TrendingEntry_entityType_entityId_tier_periodStart_key" ON "TrendingEntry"("entityType", "entityId", "tier", "periodStart"); + +-- CreateIndex +CREATE INDEX "TrendingHistory_entityType_entityId_idx" ON "TrendingHistory"("entityType", "entityId"); + +-- CreateIndex +CREATE INDEX "TrendingHistory_tier_snapshotAt_idx" ON "TrendingHistory"("tier", "snapshotAt"); + +-- CreateIndex +CREATE INDEX "TrendingHistory_snapshotAt_idx" ON "TrendingHistory"("snapshotAt"); + +-- CreateIndex +CREATE INDEX "EngagementAnomaly_entityType_entityId_idx" ON "EngagementAnomaly"("entityType", "entityId"); + +-- CreateIndex +CREATE INDEX "EngagementAnomaly_anomalyType_idx" ON "EngagementAnomaly"("anomalyType"); + +-- CreateIndex +CREATE INDEX "EngagementAnomaly_resolved_idx" ON "EngagementAnomaly"("resolved"); + +-- CreateIndex +CREATE INDEX "EngagementAnomaly_detectedAt_idx" ON "EngagementAnomaly"("detectedAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "TrendingSignalWeight_signalName_key" ON "TrendingSignalWeight"("signalName"); + +-- CreateIndex +CREATE INDEX "TrendingSignalWeight_category_idx" ON "TrendingSignalWeight"("category"); + +-- CreateIndex +CREATE INDEX "TrendingSignalWeight_active_idx" ON "TrendingSignalWeight"("active"); + +-- CreateIndex +CREATE INDEX "Media_userId_idx" ON "Media"("userId"); + +-- CreateIndex +CREATE INDEX "Media_fileHash_idx" ON "Media"("fileHash"); + +-- CreateIndex +CREATE INDEX "Media_status_idx" ON "Media"("status"); + +-- CreateIndex +CREATE INDEX "Media_postId_idx" ON "Media"("postId"); + +-- CreateIndex +CREATE INDEX "Media_reelId_idx" ON "Media"("reelId"); + +-- CreateIndex +CREATE INDEX "Media_storyId_idx" ON "Media"("storyId"); + +-- CreateIndex +CREATE INDEX "Media_softDeletedAt_idx" ON "Media"("softDeletedAt"); + +-- CreateIndex +CREATE INDEX "Media_expiresAt_idx" ON "Media"("expiresAt"); + +-- CreateIndex +CREATE INDEX "Media_createdAt_idx" ON "Media"("createdAt"); + +-- CreateIndex +CREATE INDEX "Media_userId_type_createdAt_idx" ON "Media"("userId", "type", "createdAt"); + +-- CreateIndex +CREATE INDEX "TranscodeJob_mediaId_idx" ON "TranscodeJob"("mediaId"); + +-- CreateIndex +CREATE INDEX "TranscodeJob_status_idx" ON "TranscodeJob"("status"); + +-- CreateIndex +CREATE INDEX "TranscodeJob_createdAt_idx" ON "TranscodeJob"("createdAt"); + +-- CreateIndex +CREATE INDEX "MediaUploadQuota_userId_idx" ON "MediaUploadQuota"("userId"); + +-- CreateIndex +CREATE INDEX "MediaUploadQuota_date_idx" ON "MediaUploadQuota"("date"); + +-- CreateIndex +CREATE UNIQUE INDEX "MediaUploadQuota_userId_date_key" ON "MediaUploadQuota"("userId", "date"); + +-- CreateIndex +CREATE UNIQUE INDEX "MediaFingerprint_hash_key" ON "MediaFingerprint"("hash"); + +-- CreateIndex +CREATE INDEX "MediaFingerprint_hash_idx" ON "MediaFingerprint"("hash"); + +-- CreateIndex +CREATE INDEX "MediaFingerprint_isBlocked_idx" ON "MediaFingerprint"("isBlocked"); + +-- CreateIndex +CREATE INDEX "UnfollowLog_unfollowedId_idx" ON "UnfollowLog"("unfollowedId"); + +-- CreateIndex +CREATE INDEX "UnfollowLog_unfollowerId_idx" ON "UnfollowLog"("unfollowerId"); + +-- CreateIndex +CREATE INDEX "UnfollowLog_unfollowedAt_idx" ON "UnfollowLog"("unfollowedAt"); + +-- CreateIndex +CREATE INDEX "UnfollowLog_unfollowedId_unfollowedAt_idx" ON "UnfollowLog"("unfollowedId", "unfollowedAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "RepositoryAitmSettings_repositoryId_key" ON "RepositoryAitmSettings"("repositoryId"); + +-- CreateIndex +CREATE INDEX "RepositoryAitmSettings_aitmProjectId_idx" ON "RepositoryAitmSettings"("aitmProjectId"); + +-- CreateIndex +CREATE INDEX "stars_repositoryId_idx" ON "stars"("repositoryId"); + +-- CreateIndex +CREATE UNIQUE INDEX "stars_userId_repositoryId_key" ON "stars"("userId", "repositoryId"); + +-- CreateIndex +CREATE INDEX "repository_referrers_repositoryId_date_idx" ON "repository_referrers"("repositoryId", "date"); + +-- CreateIndex +CREATE UNIQUE INDEX "repository_referrers_repositoryId_source_key" ON "repository_referrers"("repositoryId", "source"); + +-- CreateIndex +CREATE INDEX "repository_path_views_repositoryId_idx" ON "repository_path_views"("repositoryId"); + +-- CreateIndex +CREATE INDEX "repository_path_views_repositoryId_date_idx" ON "repository_path_views"("repositoryId", "date"); + +-- CreateIndex +CREATE INDEX "repository_clones_repositoryId_date_idx" ON "repository_clones"("repositoryId", "date"); + +-- CreateIndex +CREATE UNIQUE INDEX "repository_clones_repositoryId_date_key" ON "repository_clones"("repositoryId", "date"); + +-- CreateIndex +CREATE INDEX "audit_logs_userId_createdAt_idx" ON "audit_logs"("userId", "createdAt"); + +-- CreateIndex +CREATE INDEX "audit_logs_action_idx" ON "audit_logs"("action"); + +-- CreateIndex +CREATE INDEX "StoreItem_sellerId_idx" ON "StoreItem"("sellerId"); + +-- CreateIndex +CREATE INDEX "StoreItem_status_idx" ON "StoreItem"("status"); + +-- CreateIndex +CREATE INDEX "StoreItem_category_idx" ON "StoreItem"("category"); + +-- CreateIndex +CREATE INDEX "StoreItem_createdAt_idx" ON "StoreItem"("createdAt"); + +-- CreateIndex +CREATE INDEX "StorePurchase_itemId_idx" ON "StorePurchase"("itemId"); + +-- CreateIndex +CREATE INDEX "StorePurchase_buyerId_idx" ON "StorePurchase"("buyerId"); + +-- CreateIndex +CREATE INDEX "StorePurchase_sellerId_idx" ON "StorePurchase"("sellerId"); + +-- CreateIndex +CREATE INDEX "StorePurchase_status_idx" ON "StorePurchase"("status"); + +-- CreateIndex +CREATE INDEX "Moment_userId_idx" ON "Moment"("userId"); + +-- CreateIndex +CREATE INDEX "Moment_createdAt_idx" ON "Moment"("createdAt"); + +-- CreateIndex +CREATE INDEX "MomentLike_momentId_idx" ON "MomentLike"("momentId"); + +-- CreateIndex +CREATE INDEX "MomentLike_userId_idx" ON "MomentLike"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "MomentLike_momentId_userId_key" ON "MomentLike"("momentId", "userId"); + +-- CreateIndex +CREATE INDEX "Feedback_userId_idx" ON "Feedback"("userId"); + +-- CreateIndex +CREATE INDEX "Feedback_status_idx" ON "Feedback"("status"); + +-- CreateIndex +CREATE INDEX "Feedback_type_idx" ON "Feedback"("type"); + +-- CreateIndex +CREATE INDEX "Feedback_createdAt_idx" ON "Feedback"("createdAt"); + +-- CreateIndex +CREATE INDEX "AdCampaign_advertiserId_idx" ON "AdCampaign"("advertiserId"); + +-- CreateIndex +CREATE INDEX "AdCampaign_status_idx" ON "AdCampaign"("status"); + +-- CreateIndex +CREATE UNIQUE INDEX "AdPreferences_userId_key" ON "AdPreferences"("userId"); + +-- CreateIndex +CREATE INDEX "AdPreferences_userId_idx" ON "AdPreferences"("userId"); + +-- CreateIndex +CREATE INDEX "MutedWord_userId_idx" ON "MutedWord"("userId"); + +-- CreateIndex +CREATE INDEX "MutedWord_expiresAt_idx" ON "MutedWord"("expiresAt"); + +-- CreateIndex +CREATE UNIQUE INDEX "MutedWord_userId_value_key" ON "MutedWord"("userId", "value"); + +-- AddForeignKey +ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Account" ADD CONSTRAINT "Account_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Account" ADD CONSTRAINT "Account_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "AccountSwitchGrant" ADD CONSTRAINT "AccountSwitchGrant_ownerUserId_fkey" FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "AccountSwitchGrant" ADD CONSTRAINT "AccountSwitchGrant_targetUserId_fkey" FOREIGN KEY ("targetUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Repository" ADD CONSTRAINT "Repository_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RepositoryManager" ADD CONSTRAINT "RepositoryManager_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RepositoryManager" ADD CONSTRAINT "RepositoryManager_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "OrganizationMember" ADD CONSTRAINT "OrganizationMember_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "OrganizationMember" ADD CONSTRAINT "OrganizationMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Post" ADD CONSTRAINT "Post_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Post" ADD CONSTRAINT "Post_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Post" ADD CONSTRAINT "Post_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Comment" ADD CONSTRAINT "Comment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Comment"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Like" ADD CONSTRAINT "Like_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Like" ADD CONSTRAINT "Like_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Like" ADD CONSTRAINT "Like_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Story" ADD CONSTRAINT "Story_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Story" ADD CONSTRAINT "Story_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Story" ADD CONSTRAINT "Story_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reel" ADD CONSTRAINT "Reel_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reel" ADD CONSTRAINT "Reel_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Reel" ADD CONSTRAINT "Reel_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followerId_fkey" FOREIGN KEY ("followerId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followingId_fkey" FOREIGN KEY ("followingId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followerUserId_fkey" FOREIGN KEY ("followerUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followingUserId_fkey" FOREIGN KEY ("followingUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Message" ADD CONSTRAINT "Message_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Message" ADD CONSTRAINT "Message_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Message" ADD CONSTRAINT "Message_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "MessageReaction" ADD CONSTRAINT "MessageReaction_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "Message"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "MessageReaction" ADD CONSTRAINT "MessageReaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "TwoFactorAuth" ADD CONSTRAINT "TwoFactorAuth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CodeSnippet" ADD CONSTRAINT "CodeSnippet_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CodeSnippet" ADD CONSTRAINT "CodeSnippet_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_hashtagId_fkey" FOREIGN KEY ("hashtagId") REFERENCES "Hashtag"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_savedCollection_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SavedPostCollection" ADD CONSTRAINT "SavedPostCollection_savedPostId_fkey" FOREIGN KEY ("savedPostId") REFERENCES "SavedPost"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "SavedPostCollection" ADD CONSTRAINT "SavedPostCollection_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RepositoryFollow" ADD CONSTRAINT "RepositoryFollow_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "GitHubWebhook" ADD CONSTRAINT "GitHubWebhook_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RepositoryActivity" ADD CONSTRAINT "RepositoryActivity_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "UnifiedComment" ADD CONSTRAINT "UnifiedComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "UnifiedComment" ADD CONSTRAINT "UnifiedComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "UnifiedComment"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ChatMember" ADD CONSTRAINT "ChatMember_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ReelLike" ADD CONSTRAINT "ReelLike_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "ReelView" ADD CONSTRAINT "ReelView_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StoryView" ADD CONSTRAINT "StoryView_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StoryReaction" ADD CONSTRAINT "StoryReaction_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StoryReply" ADD CONSTRAINT "StoryReply_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StoryReply" ADD CONSTRAINT "StoryReply_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "LinkedAccount" ADD CONSTRAINT "LinkedAccount_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CommentLike" ADD CONSTRAINT "CommentLike_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "Comment"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StorySettings" ADD CONSTRAINT "StorySettings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StoryHighlight" ADD CONSTRAINT "StoryHighlight_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "WebhookDelivery" ADD CONSTRAINT "WebhookDelivery_webhookId_fkey" FOREIGN KEY ("webhookId") REFERENCES "UserWebhook"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "LinkPreview" ADD CONSTRAINT "LinkPreview_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PostView" ADD CONSTRAINT "PostView_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "TranscodeJob" ADD CONSTRAINT "TranscodeJob_mediaId_fkey" FOREIGN KEY ("mediaId") REFERENCES "Media"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "RepositoryAitmSettings" ADD CONSTRAINT "RepositoryAitmSettings_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "stars" ADD CONSTRAINT "stars_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "stars" ADD CONSTRAINT "stars_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "repository_referrers" ADD CONSTRAINT "repository_referrers_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "repository_path_views" ADD CONSTRAINT "repository_path_views_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "repository_clones" ADD CONSTRAINT "repository_clones_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "audit_logs" ADD CONSTRAINT "audit_logs_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "StorePurchase" ADD CONSTRAINT "StorePurchase_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "StoreItem"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "MomentLike" ADD CONSTRAINT "MomentLike_momentId_fkey" FOREIGN KEY ("momentId") REFERENCES "Moment"("id") ON DELETE CASCADE ON UPDATE CASCADE; + diff --git a/gitgram/backend/prisma/migrations/20251127223529_init/migration.sql b/gitgram/backend/prisma/migrations/20251127223529_init/migration.sql deleted file mode 100644 index 6cf6f712..00000000 --- a/gitgram/backend/prisma/migrations/20251127223529_init/migration.sql +++ /dev/null @@ -1,1298 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL, - "username" TEXT NOT NULL, - "email" TEXT NOT NULL, - "password" TEXT, - "avatar" TEXT, - "bio" TEXT, - "githubId" TEXT, - "githubUsername" TEXT, - "githubToken" TEXT, - "isVerified" BOOLEAN NOT NULL DEFAULT false, - "isGoldenVerified" BOOLEAN NOT NULL DEFAULT false, - "role" TEXT NOT NULL DEFAULT 'user', - "interests" TEXT[] DEFAULT ARRAY[]::TEXT[], - "latitude" DOUBLE PRECISION, - "longitude" DOUBLE PRECISION, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "User_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Post" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT, - "mediaType" TEXT NOT NULL, - "mediaUrl" TEXT, - "codeSnippet" TEXT, - "language" TEXT, - "hashtags" TEXT[] DEFAULT ARRAY[]::TEXT[], - "mentions" TEXT[] DEFAULT ARRAY[]::TEXT[], - "location" TEXT, - "latitude" DOUBLE PRECISION, - "longitude" DOUBLE PRECISION, - "githubRepoId" TEXT, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "commentsCount" INTEGER NOT NULL DEFAULT 0, - "isArchived" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Post_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Reel" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "videoUrl" TEXT NOT NULL, - "thumbnailUrl" TEXT, - "caption" TEXT, - "hashtags" TEXT[] DEFAULT ARRAY[]::TEXT[], - "mentions" TEXT[] DEFAULT ARRAY[]::TEXT[], - "duration" INTEGER, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "commentsCount" INTEGER NOT NULL DEFAULT 0, - "viewsCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Reel_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Story" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "mediaType" TEXT NOT NULL, - "mediaUrl" TEXT NOT NULL, - "expiresAt" TIMESTAMP(3) NOT NULL, - "viewsCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Story_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryView" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "viewedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryView_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Comment" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT, - "reelId" TEXT, - "momentId" TEXT, - "content" TEXT NOT NULL, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Comment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Like" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT, - "reelId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Like_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Follow" ( - "id" TEXT NOT NULL, - "followerId" TEXT NOT NULL, - "followingId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Follow_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Message" ( - "id" TEXT NOT NULL, - "senderId" TEXT NOT NULL, - "recipientId" TEXT, - "groupId" TEXT, - "content" TEXT, - "mediaType" TEXT, - "mediaUrl" TEXT, - "isRead" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Message_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "MessageRequest" ( - "id" TEXT NOT NULL, - "senderId" TEXT NOT NULL, - "recipientId" TEXT NOT NULL, - "message" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "MessageRequest_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "GroupChat" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "creatorId" TEXT NOT NULL, - "avatar" TEXT, - "isPrivate" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "GroupChat_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "GroupChatMember" ( - "id" TEXT NOT NULL, - "groupId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "role" TEXT NOT NULL DEFAULT 'member', - "joinedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "GroupChatMember_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Notification" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "title" TEXT NOT NULL, - "body" TEXT NOT NULL, - "data" JSONB, - "isRead" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Notification_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedPost" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SavedPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "GitHubProject" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repoId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "fullName" TEXT NOT NULL, - "description" TEXT, - "url" TEXT NOT NULL, - "language" TEXT, - "stars" INTEGER NOT NULL DEFAULT 0, - "forks" INTEGER NOT NULL DEFAULT 0, - "readme" TEXT, - "screenshots" TEXT[] DEFAULT ARRAY[]::TEXT[], - "location" TEXT, - "latitude" DOUBLE PRECISION, - "longitude" DOUBLE PRECISION, - "lastSyncedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "GitHubProject_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedProject" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "projectId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SavedProject_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "LinkedAccount" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "linkedUserId" TEXT NOT NULL, - "isPrimary" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "LinkedAccount_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "GitHubSync" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "status" TEXT NOT NULL, - "reposCount" INTEGER NOT NULL DEFAULT 0, - "syncedCount" INTEGER NOT NULL DEFAULT 0, - "error" TEXT, - "startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "completedAt" TIMESTAMP(3), - - CONSTRAINT "GitHubSync_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RefreshToken" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expiresAt" TIMESTAMP(3) NOT NULL, - "isRevoked" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RefreshToken_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Moment" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "screenshotUrl" TEXT NOT NULL, - "selfieUrl" TEXT NOT NULL, - "caption" TEXT, - "location" TEXT, - "latitude" DOUBLE PRECISION, - "longitude" DOUBLE PRECISION, - "expiresAt" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Moment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "MomentLike" ( - "momentId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "MomentLike_pkey" PRIMARY KEY ("momentId","userId") -); - --- CreateTable -CREATE TABLE "StoreItem" ( - "id" TEXT NOT NULL, - "sellerId" TEXT NOT NULL, - "title" TEXT NOT NULL, - "description" TEXT NOT NULL, - "price" DOUBLE PRECISION NOT NULL, - "category" TEXT NOT NULL, - "images" TEXT[], - "codeFiles" TEXT[], - "projectId" TEXT, - "rating" DOUBLE PRECISION NOT NULL DEFAULT 0, - "salesCount" INTEGER NOT NULL DEFAULT 0, - "isActive" BOOLEAN NOT NULL DEFAULT true, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "StoreItem_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Transaction" ( - "id" TEXT NOT NULL, - "buyerId" TEXT NOT NULL, - "itemId" TEXT NOT NULL, - "amount" DOUBLE PRECISION NOT NULL, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "completedAt" TIMESTAMP(3), - - CONSTRAINT "Transaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PostShare" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "comment" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "PostShare_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PostReport" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "reason" TEXT NOT NULL, - "details" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "PostReport_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "UserBlock" ( - "id" TEXT NOT NULL, - "blockerId" TEXT NOT NULL, - "blockedId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "UserBlock_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "NotificationPreference" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "likes" BOOLEAN NOT NULL DEFAULT true, - "comments" BOOLEAN NOT NULL DEFAULT true, - "follows" BOOLEAN NOT NULL DEFAULT true, - "messages" BOOLEAN NOT NULL DEFAULT true, - "mentions" BOOLEAN NOT NULL DEFAULT true, - "storyReactions" BOOLEAN NOT NULL DEFAULT true, - "postShares" BOOLEAN NOT NULL DEFAULT true, - "reelShares" BOOLEAN NOT NULL DEFAULT true, - "pushEnabled" BOOLEAN NOT NULL DEFAULT true, - "emailEnabled" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "NotificationPreference_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdPreference" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "showAds" BOOLEAN NOT NULL DEFAULT true, - "personalizedAds" BOOLEAN NOT NULL DEFAULT true, - "allowDataCollection" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "AdPreference_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdReport" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "adId" TEXT NOT NULL, - "reason" TEXT NOT NULL, - "details" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "AdReport_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Feedback" ( - "id" TEXT NOT NULL, - "userId" TEXT, - "type" TEXT NOT NULL, - "title" TEXT NOT NULL, - "content" TEXT NOT NULL, - "status" TEXT NOT NULL DEFAULT 'open', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Feedback_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "UserSession" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "deviceId" TEXT, - "deviceName" TEXT, - "ipAddress" TEXT, - "userAgent" TEXT, - "isActive" BOOLEAN NOT NULL DEFAULT true, - "lastActiveAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "UserSession_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AccountSettings" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "isFrozen" BOOLEAN NOT NULL DEFAULT false, - "frozenAt" TIMESTAMP(3), - "twoFactorEnabled" BOOLEAN NOT NULL DEFAULT false, - "twoFactorSecret" TEXT, - "backupCodes" TEXT[] DEFAULT ARRAY[]::TEXT[], - "privacySettings" JSONB, - "appearanceSettings" JSONB, - "languageSettings" JSONB, - "dataRetentionDays" INTEGER, - "autoDeleteAfterDays" INTEGER, - "messageSettings" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "AccountSettings_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PasswordResetToken" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expiresAt" TIMESTAMP(3) NOT NULL, - "used" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "PasswordResetToken_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "EmailVerificationToken" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expiresAt" TIMESTAMP(3) NOT NULL, - "used" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "EmailVerificationToken_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "VerificationRequest" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "reason" TEXT NOT NULL, - "evidence" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "reviewedBy" TEXT, - "reviewedAt" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "VerificationRequest_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Collection" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "isPrivate" BOOLEAN NOT NULL DEFAULT false, - "coverImage" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Collection_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "CollectionPost" ( - "id" TEXT NOT NULL, - "collectionId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "addedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "CollectionPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Subscription" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "subscriptionId" TEXT NOT NULL, - "productId" TEXT NOT NULL, - "productName" TEXT, - "status" TEXT NOT NULL, - "quantity" INTEGER NOT NULL DEFAULT 1, - "currentPeriodStart" TIMESTAMP(3), - "currentPeriodEnd" TIMESTAMP(3), - "trialStart" TIMESTAMP(3), - "trialEnd" TIMESTAMP(3), - "cancelAtPeriodEnd" BOOLEAN NOT NULL DEFAULT false, - "cancelledAt" TIMESTAMP(3), - "onHoldAt" TIMESTAMP(3), - "paymentMethodId" TEXT, - "metadata" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Subscription_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SubscriptionHistory" ( - "id" TEXT NOT NULL, - "subscriptionId" TEXT NOT NULL, - "eventType" TEXT NOT NULL, - "previousPlan" TEXT, - "newPlan" TEXT, - "amount" DOUBLE PRECISION, - "currency" TEXT, - "invoiceId" TEXT, - "paymentId" TEXT, - "metadata" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SubscriptionHistory_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "VerificationPurchase" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "subscriptionId" TEXT, - "status" TEXT NOT NULL, - "amount" DOUBLE PRECISION NOT NULL, - "currency" TEXT NOT NULL DEFAULT 'USD', - "billingPeriod" TEXT NOT NULL DEFAULT 'monthly', - "currentPeriodStart" TIMESTAMP(3), - "currentPeriodEnd" TIMESTAMP(3), - "cancelledAt" TIMESTAMP(3), - "expiresAt" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "VerificationPurchase_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdCampaign" ( - "id" TEXT NOT NULL, - "advertiserId" TEXT NOT NULL, - "advertiserType" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "type" TEXT NOT NULL, - "status" TEXT NOT NULL DEFAULT 'draft', - "budget" DOUBLE PRECISION NOT NULL, - "dailyBudget" DOUBLE PRECISION, - "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, - "startDate" TIMESTAMP(3), - "endDate" TIMESTAMP(3), - "targetAudience" JSONB, - "billingType" TEXT NOT NULL DEFAULT 'cpc', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "AdCampaign_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Ad" ( - "id" TEXT NOT NULL, - "campaignId" TEXT NOT NULL, - "postId" TEXT, - "reelId" TEXT, - "storyId" TEXT, - "title" TEXT, - "content" TEXT, - "mediaUrl" TEXT, - "mediaType" TEXT, - "callToAction" TEXT, - "destinationUrl" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "priority" INTEGER NOT NULL DEFAULT 0, - "impressions" INTEGER NOT NULL DEFAULT 0, - "clicks" INTEGER NOT NULL DEFAULT 0, - "conversions" INTEGER NOT NULL DEFAULT 0, - "spend" DOUBLE PRECISION NOT NULL DEFAULT 0, - "targetAudience" JSONB, - "placement" TEXT[], - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "approvedAt" TIMESTAMP(3), - "rejectedAt" TIMESTAMP(3), - "rejectionReason" TEXT, - - CONSTRAINT "Ad_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdPayment" ( - "id" TEXT NOT NULL, - "campaignId" TEXT NOT NULL, - "amount" DOUBLE PRECISION NOT NULL, - "currency" TEXT NOT NULL DEFAULT 'USD', - "paymentId" TEXT, - "status" TEXT NOT NULL, - "paymentMethod" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "completedAt" TIMESTAMP(3), - - CONSTRAINT "AdPayment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdInteraction" ( - "id" TEXT NOT NULL, - "adId" TEXT NOT NULL, - "userId" TEXT, - "type" TEXT NOT NULL, - "metadata" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "AdInteraction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "AdTargeting" ( - "id" TEXT NOT NULL, - "campaignId" TEXT NOT NULL, - "ageMin" INTEGER, - "ageMax" INTEGER, - "genders" TEXT[], - "locations" TEXT[], - "languages" TEXT[], - "interests" TEXT[], - "behaviors" TEXT[], - "deviceTypes" TEXT[], - "operatingSystems" TEXT[], - "customAudience" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "AdTargeting_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "User_githubId_key" ON "User"("githubId"); - --- CreateIndex -CREATE INDEX "User_createdAt_idx" ON "User"("createdAt"); - --- CreateIndex -CREATE INDEX "User_email_idx" ON "User"("email"); - --- CreateIndex -CREATE INDEX "User_username_idx" ON "User"("username"); - --- CreateIndex -CREATE INDEX "Post_userId_idx" ON "Post"("userId"); - --- CreateIndex -CREATE INDEX "Post_createdAt_idx" ON "Post"("createdAt"); - --- CreateIndex -CREATE INDEX "Post_userId_createdAt_idx" ON "Post"("userId", "createdAt"); - --- CreateIndex -CREATE INDEX "Post_isArchived_idx" ON "Post"("isArchived"); - --- CreateIndex -CREATE INDEX "Reel_userId_idx" ON "Reel"("userId"); - --- CreateIndex -CREATE INDEX "Reel_createdAt_idx" ON "Reel"("createdAt"); - --- CreateIndex -CREATE INDEX "Reel_userId_createdAt_idx" ON "Reel"("userId", "createdAt"); - --- CreateIndex -CREATE INDEX "Story_userId_idx" ON "Story"("userId"); - --- CreateIndex -CREATE INDEX "Story_expiresAt_idx" ON "Story"("expiresAt"); - --- CreateIndex -CREATE INDEX "Story_userId_expiresAt_idx" ON "Story"("userId", "expiresAt"); - --- CreateIndex -CREATE UNIQUE INDEX "StoryView_storyId_userId_key" ON "StoryView"("storyId", "userId"); - --- CreateIndex -CREATE INDEX "Comment_postId_idx" ON "Comment"("postId"); - --- CreateIndex -CREATE INDEX "Comment_reelId_idx" ON "Comment"("reelId"); - --- CreateIndex -CREATE INDEX "Comment_momentId_idx" ON "Comment"("momentId"); - --- CreateIndex -CREATE INDEX "Comment_userId_idx" ON "Comment"("userId"); - --- CreateIndex -CREATE INDEX "Comment_createdAt_idx" ON "Comment"("createdAt"); - --- CreateIndex -CREATE INDEX "Like_postId_idx" ON "Like"("postId"); - --- CreateIndex -CREATE INDEX "Like_reelId_idx" ON "Like"("reelId"); - --- CreateIndex -CREATE UNIQUE INDEX "Like_userId_postId_key" ON "Like"("userId", "postId"); - --- CreateIndex -CREATE UNIQUE INDEX "Like_userId_reelId_key" ON "Like"("userId", "reelId"); - --- CreateIndex -CREATE INDEX "Follow_followerId_idx" ON "Follow"("followerId"); - --- CreateIndex -CREATE INDEX "Follow_followingId_idx" ON "Follow"("followingId"); - --- CreateIndex -CREATE UNIQUE INDEX "Follow_followerId_followingId_key" ON "Follow"("followerId", "followingId"); - --- CreateIndex -CREATE INDEX "Message_senderId_recipientId_idx" ON "Message"("senderId", "recipientId"); - --- CreateIndex -CREATE INDEX "Message_recipientId_idx" ON "Message"("recipientId"); - --- CreateIndex -CREATE INDEX "Message_groupId_idx" ON "Message"("groupId"); - --- CreateIndex -CREATE INDEX "Message_createdAt_idx" ON "Message"("createdAt"); - --- CreateIndex -CREATE INDEX "Message_isRead_idx" ON "Message"("isRead"); - --- CreateIndex -CREATE INDEX "MessageRequest_recipientId_idx" ON "MessageRequest"("recipientId"); - --- CreateIndex -CREATE INDEX "MessageRequest_status_idx" ON "MessageRequest"("status"); - --- CreateIndex -CREATE INDEX "MessageRequest_createdAt_idx" ON "MessageRequest"("createdAt"); - --- CreateIndex -CREATE UNIQUE INDEX "MessageRequest_senderId_recipientId_key" ON "MessageRequest"("senderId", "recipientId"); - --- CreateIndex -CREATE INDEX "GroupChat_creatorId_idx" ON "GroupChat"("creatorId"); - --- CreateIndex -CREATE INDEX "GroupChat_createdAt_idx" ON "GroupChat"("createdAt"); - --- CreateIndex -CREATE INDEX "GroupChatMember_groupId_idx" ON "GroupChatMember"("groupId"); - --- CreateIndex -CREATE INDEX "GroupChatMember_userId_idx" ON "GroupChatMember"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "GroupChatMember_groupId_userId_key" ON "GroupChatMember"("groupId", "userId"); - --- CreateIndex -CREATE INDEX "Notification_userId_isRead_idx" ON "Notification"("userId", "isRead"); - --- CreateIndex -CREATE INDEX "Notification_createdAt_idx" ON "Notification"("createdAt"); - --- CreateIndex -CREATE INDEX "Notification_type_idx" ON "Notification"("type"); - --- CreateIndex -CREATE UNIQUE INDEX "SavedPost_userId_postId_key" ON "SavedPost"("userId", "postId"); - --- CreateIndex -CREATE UNIQUE INDEX "GitHubProject_repoId_key" ON "GitHubProject"("repoId"); - --- CreateIndex -CREATE INDEX "GitHubProject_userId_idx" ON "GitHubProject"("userId"); - --- CreateIndex -CREATE INDEX "SavedProject_userId_idx" ON "SavedProject"("userId"); - --- CreateIndex -CREATE INDEX "SavedProject_projectId_idx" ON "SavedProject"("projectId"); - --- CreateIndex -CREATE UNIQUE INDEX "SavedProject_userId_projectId_key" ON "SavedProject"("userId", "projectId"); - --- CreateIndex -CREATE INDEX "LinkedAccount_userId_idx" ON "LinkedAccount"("userId"); - --- CreateIndex -CREATE INDEX "LinkedAccount_linkedUserId_idx" ON "LinkedAccount"("linkedUserId"); - --- CreateIndex -CREATE INDEX "LinkedAccount_isPrimary_idx" ON "LinkedAccount"("isPrimary"); - --- CreateIndex -CREATE UNIQUE INDEX "LinkedAccount_userId_linkedUserId_key" ON "LinkedAccount"("userId", "linkedUserId"); - --- CreateIndex -CREATE INDEX "GitHubSync_userId_idx" ON "GitHubSync"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "RefreshToken_token_key" ON "RefreshToken"("token"); - --- CreateIndex -CREATE INDEX "RefreshToken_userId_idx" ON "RefreshToken"("userId"); - --- CreateIndex -CREATE INDEX "RefreshToken_token_idx" ON "RefreshToken"("token"); - --- CreateIndex -CREATE INDEX "Moment_userId_idx" ON "Moment"("userId"); - --- CreateIndex -CREATE INDEX "Moment_createdAt_idx" ON "Moment"("createdAt"); - --- CreateIndex -CREATE INDEX "Moment_expiresAt_idx" ON "Moment"("expiresAt"); - --- CreateIndex -CREATE INDEX "MomentLike_userId_idx" ON "MomentLike"("userId"); - --- CreateIndex -CREATE INDEX "StoreItem_sellerId_idx" ON "StoreItem"("sellerId"); - --- CreateIndex -CREATE INDEX "StoreItem_category_idx" ON "StoreItem"("category"); - --- CreateIndex -CREATE INDEX "StoreItem_isActive_idx" ON "StoreItem"("isActive"); - --- CreateIndex -CREATE INDEX "StoreItem_createdAt_idx" ON "StoreItem"("createdAt"); - --- CreateIndex -CREATE INDEX "Transaction_buyerId_idx" ON "Transaction"("buyerId"); - --- CreateIndex -CREATE INDEX "Transaction_itemId_idx" ON "Transaction"("itemId"); - --- CreateIndex -CREATE INDEX "Transaction_status_idx" ON "Transaction"("status"); - --- CreateIndex -CREATE INDEX "Transaction_createdAt_idx" ON "Transaction"("createdAt"); - --- CreateIndex -CREATE INDEX "PostShare_postId_idx" ON "PostShare"("postId"); - --- CreateIndex -CREATE INDEX "PostShare_userId_idx" ON "PostShare"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "PostShare_userId_postId_key" ON "PostShare"("userId", "postId"); - --- CreateIndex -CREATE INDEX "PostReport_postId_idx" ON "PostReport"("postId"); - --- CreateIndex -CREATE INDEX "PostReport_userId_idx" ON "PostReport"("userId"); - --- CreateIndex -CREATE INDEX "PostReport_status_idx" ON "PostReport"("status"); - --- CreateIndex -CREATE INDEX "UserBlock_blockerId_idx" ON "UserBlock"("blockerId"); - --- CreateIndex -CREATE INDEX "UserBlock_blockedId_idx" ON "UserBlock"("blockedId"); - --- CreateIndex -CREATE UNIQUE INDEX "UserBlock_blockerId_blockedId_key" ON "UserBlock"("blockerId", "blockedId"); - --- CreateIndex -CREATE UNIQUE INDEX "NotificationPreference_userId_key" ON "NotificationPreference"("userId"); - --- CreateIndex -CREATE INDEX "NotificationPreference_userId_idx" ON "NotificationPreference"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "AdPreference_userId_key" ON "AdPreference"("userId"); - --- CreateIndex -CREATE INDEX "AdPreference_userId_idx" ON "AdPreference"("userId"); - --- CreateIndex -CREATE INDEX "AdReport_adId_idx" ON "AdReport"("adId"); - --- CreateIndex -CREATE INDEX "AdReport_userId_idx" ON "AdReport"("userId"); - --- CreateIndex -CREATE INDEX "AdReport_status_idx" ON "AdReport"("status"); - --- CreateIndex -CREATE INDEX "Feedback_userId_idx" ON "Feedback"("userId"); - --- CreateIndex -CREATE INDEX "Feedback_status_idx" ON "Feedback"("status"); - --- CreateIndex -CREATE INDEX "Feedback_createdAt_idx" ON "Feedback"("createdAt"); - --- CreateIndex -CREATE INDEX "UserSession_userId_idx" ON "UserSession"("userId"); - --- CreateIndex -CREATE INDEX "UserSession_isActive_idx" ON "UserSession"("isActive"); - --- CreateIndex -CREATE UNIQUE INDEX "AccountSettings_userId_key" ON "AccountSettings"("userId"); - --- CreateIndex -CREATE INDEX "AccountSettings_userId_idx" ON "AccountSettings"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "PasswordResetToken_token_key" ON "PasswordResetToken"("token"); - --- CreateIndex -CREATE INDEX "PasswordResetToken_userId_idx" ON "PasswordResetToken"("userId"); - --- CreateIndex -CREATE INDEX "PasswordResetToken_token_idx" ON "PasswordResetToken"("token"); - --- CreateIndex -CREATE INDEX "PasswordResetToken_expiresAt_idx" ON "PasswordResetToken"("expiresAt"); - --- CreateIndex -CREATE UNIQUE INDEX "EmailVerificationToken_token_key" ON "EmailVerificationToken"("token"); - --- CreateIndex -CREATE INDEX "EmailVerificationToken_userId_idx" ON "EmailVerificationToken"("userId"); - --- CreateIndex -CREATE INDEX "EmailVerificationToken_token_idx" ON "EmailVerificationToken"("token"); - --- CreateIndex -CREATE INDEX "EmailVerificationToken_expiresAt_idx" ON "EmailVerificationToken"("expiresAt"); - --- CreateIndex -CREATE INDEX "VerificationRequest_userId_idx" ON "VerificationRequest"("userId"); - --- CreateIndex -CREATE INDEX "VerificationRequest_status_idx" ON "VerificationRequest"("status"); - --- CreateIndex -CREATE INDEX "VerificationRequest_createdAt_idx" ON "VerificationRequest"("createdAt"); - --- CreateIndex -CREATE INDEX "Collection_userId_idx" ON "Collection"("userId"); - --- CreateIndex -CREATE INDEX "Collection_createdAt_idx" ON "Collection"("createdAt"); - --- CreateIndex -CREATE INDEX "CollectionPost_collectionId_idx" ON "CollectionPost"("collectionId"); - --- CreateIndex -CREATE INDEX "CollectionPost_postId_idx" ON "CollectionPost"("postId"); - --- CreateIndex -CREATE UNIQUE INDEX "CollectionPost_collectionId_postId_key" ON "CollectionPost"("collectionId", "postId"); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_subscriptionId_key" ON "Subscription"("subscriptionId"); - --- CreateIndex -CREATE INDEX "Subscription_userId_idx" ON "Subscription"("userId"); - --- CreateIndex -CREATE INDEX "Subscription_subscriptionId_idx" ON "Subscription"("subscriptionId"); - --- CreateIndex -CREATE INDEX "Subscription_status_idx" ON "Subscription"("status"); - --- CreateIndex -CREATE INDEX "Subscription_currentPeriodEnd_idx" ON "Subscription"("currentPeriodEnd"); - --- CreateIndex -CREATE INDEX "SubscriptionHistory_subscriptionId_idx" ON "SubscriptionHistory"("subscriptionId"); - --- CreateIndex -CREATE INDEX "SubscriptionHistory_eventType_idx" ON "SubscriptionHistory"("eventType"); - --- CreateIndex -CREATE INDEX "SubscriptionHistory_createdAt_idx" ON "SubscriptionHistory"("createdAt"); - --- CreateIndex -CREATE UNIQUE INDEX "VerificationPurchase_subscriptionId_key" ON "VerificationPurchase"("subscriptionId"); - --- CreateIndex -CREATE INDEX "VerificationPurchase_userId_idx" ON "VerificationPurchase"("userId"); - --- CreateIndex -CREATE INDEX "VerificationPurchase_subscriptionId_idx" ON "VerificationPurchase"("subscriptionId"); - --- CreateIndex -CREATE INDEX "VerificationPurchase_status_idx" ON "VerificationPurchase"("status"); - --- CreateIndex -CREATE INDEX "VerificationPurchase_currentPeriodEnd_idx" ON "VerificationPurchase"("currentPeriodEnd"); - --- CreateIndex -CREATE INDEX "AdCampaign_advertiserId_idx" ON "AdCampaign"("advertiserId"); - --- CreateIndex -CREATE INDEX "AdCampaign_status_idx" ON "AdCampaign"("status"); - --- CreateIndex -CREATE INDEX "AdCampaign_startDate_endDate_idx" ON "AdCampaign"("startDate", "endDate"); - --- CreateIndex -CREATE INDEX "Ad_campaignId_idx" ON "Ad"("campaignId"); - --- CreateIndex -CREATE INDEX "Ad_status_idx" ON "Ad"("status"); - --- CreateIndex -CREATE INDEX "Ad_postId_idx" ON "Ad"("postId"); - --- CreateIndex -CREATE INDEX "Ad_reelId_idx" ON "Ad"("reelId"); - --- CreateIndex -CREATE INDEX "Ad_storyId_idx" ON "Ad"("storyId"); - --- CreateIndex -CREATE INDEX "Ad_priority_status_idx" ON "Ad"("priority", "status"); - --- CreateIndex -CREATE INDEX "AdPayment_campaignId_idx" ON "AdPayment"("campaignId"); - --- CreateIndex -CREATE INDEX "AdPayment_status_idx" ON "AdPayment"("status"); - --- CreateIndex -CREATE INDEX "AdPayment_paymentId_idx" ON "AdPayment"("paymentId"); - --- CreateIndex -CREATE INDEX "AdInteraction_adId_idx" ON "AdInteraction"("adId"); - --- CreateIndex -CREATE INDEX "AdInteraction_userId_idx" ON "AdInteraction"("userId"); - --- CreateIndex -CREATE INDEX "AdInteraction_type_idx" ON "AdInteraction"("type"); - --- CreateIndex -CREATE INDEX "AdInteraction_createdAt_idx" ON "AdInteraction"("createdAt"); - --- CreateIndex -CREATE UNIQUE INDEX "AdTargeting_campaignId_key" ON "AdTargeting"("campaignId"); - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_githubRepoId_fkey" FOREIGN KEY ("githubRepoId") REFERENCES "GitHubProject"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Reel" ADD CONSTRAINT "Reel_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Story" ADD CONSTRAINT "Story_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryView" ADD CONSTRAINT "StoryView_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_momentId_fkey" FOREIGN KEY ("momentId") REFERENCES "Moment"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Like" ADD CONSTRAINT "Like_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Like" ADD CONSTRAINT "Like_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Like" ADD CONSTRAINT "Like_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followerId_fkey" FOREIGN KEY ("followerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followingId_fkey" FOREIGN KEY ("followingId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "GroupChat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "MessageRequest" ADD CONSTRAINT "MessageRequest_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "MessageRequest" ADD CONSTRAINT "MessageRequest_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "GroupChat" ADD CONSTRAINT "GroupChat_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "GroupChatMember" ADD CONSTRAINT "GroupChatMember_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "GroupChat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "GroupChatMember" ADD CONSTRAINT "GroupChatMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "GitHubProject" ADD CONSTRAINT "GitHubProject_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedProject" ADD CONSTRAINT "SavedProject_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedProject" ADD CONSTRAINT "SavedProject_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "GitHubProject"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "LinkedAccount" ADD CONSTRAINT "LinkedAccount_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "LinkedAccount" ADD CONSTRAINT "LinkedAccount_linkedUserId_fkey" FOREIGN KEY ("linkedUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Moment" ADD CONSTRAINT "Moment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "MomentLike" ADD CONSTRAINT "MomentLike_momentId_fkey" FOREIGN KEY ("momentId") REFERENCES "Moment"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "MomentLike" ADD CONSTRAINT "MomentLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoreItem" ADD CONSTRAINT "StoreItem_sellerId_fkey" FOREIGN KEY ("sellerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "StoreItem"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_buyerId_fkey" FOREIGN KEY ("buyerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostShare" ADD CONSTRAINT "PostShare_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostShare" ADD CONSTRAINT "PostShare_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostReport" ADD CONSTRAINT "PostReport_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostReport" ADD CONSTRAINT "PostReport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "UserBlock" ADD CONSTRAINT "UserBlock_blockerId_fkey" FOREIGN KEY ("blockerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "UserBlock" ADD CONSTRAINT "UserBlock_blockedId_fkey" FOREIGN KEY ("blockedId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "NotificationPreference" ADD CONSTRAINT "NotificationPreference_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdPreference" ADD CONSTRAINT "AdPreference_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdReport" ADD CONSTRAINT "AdReport_adId_fkey" FOREIGN KEY ("adId") REFERENCES "Ad"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdReport" ADD CONSTRAINT "AdReport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "UserSession" ADD CONSTRAINT "UserSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AccountSettings" ADD CONSTRAINT "AccountSettings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Collection" ADD CONSTRAINT "Collection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CollectionPost" ADD CONSTRAINT "CollectionPost_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CollectionPost" ADD CONSTRAINT "CollectionPost_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SubscriptionHistory" ADD CONSTRAINT "SubscriptionHistory_subscriptionId_fkey" FOREIGN KEY ("subscriptionId") REFERENCES "Subscription"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "VerificationPurchase" ADD CONSTRAINT "VerificationPurchase_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdCampaign" ADD CONSTRAINT "AdCampaign_advertiserId_fkey" FOREIGN KEY ("advertiserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Ad" ADD CONSTRAINT "Ad_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "AdCampaign"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Ad" ADD CONSTRAINT "Ad_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Ad" ADD CONSTRAINT "Ad_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Ad" ADD CONSTRAINT "Ad_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdPayment" ADD CONSTRAINT "AdPayment_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "AdCampaign"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdInteraction" ADD CONSTRAINT "AdInteraction_adId_fkey" FOREIGN KEY ("adId") REFERENCES "Ad"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdInteraction" ADD CONSTRAINT "AdInteraction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "AdTargeting" ADD CONSTRAINT "AdTargeting_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "AdCampaign"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251130070252_add_phase3_features/migration.sql b/gitgram/backend/prisma/migrations/20251130070252_add_phase3_features/migration.sql deleted file mode 100644 index bc477275..00000000 --- a/gitgram/backend/prisma/migrations/20251130070252_add_phase3_features/migration.sql +++ /dev/null @@ -1,762 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `likesCount` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `momentId` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `reelId` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `reelId` on the `Like` table. All the data in the column will be lost. - - You are about to drop the column `groupId` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `isRead` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `mediaType` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `recipientId` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `body` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `data` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `isRead` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `title` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `codeSnippet` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `githubRepoId` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `hashtags` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `isArchived` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `language` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `latitude` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `location` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `longitude` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `mediaType` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `mediaUrl` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `mentions` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `details` on the `PostReport` table. All the data in the column will be lost. - - You are about to drop the column `status` on the `PostReport` table. All the data in the column will be lost. - - You are about to drop the column `mediaType` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `viewedAt` on the `StoryView` table. All the data in the column will be lost. - - You are about to drop the column `githubToken` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `interests` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `isGoldenVerified` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `isVerified` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `latitude` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `longitude` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `role` on the `User` table. All the data in the column will be lost. - - You are about to drop the `AccountSettings` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Ad` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdCampaign` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdInteraction` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdPayment` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdPreference` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdReport` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `AdTargeting` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Collection` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `CollectionPost` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `EmailVerificationToken` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Feedback` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `GitHubProject` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `GitHubSync` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `GroupChat` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `GroupChatMember` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `LinkedAccount` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `MessageRequest` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Moment` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `MomentLike` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `NotificationPreference` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PasswordResetToken` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Reel` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `RefreshToken` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedProject` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `StoreItem` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Subscription` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SubscriptionHistory` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Transaction` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `UserSession` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `VerificationPurchase` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `VerificationRequest` table. If the table is not empty, all the data it contains will be lost. - - A unique constraint covering the columns `[postId,userId]` on the table `Like` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[googleId]` on the table `User` will be added. If there are existing duplicate values, this will fail. - - Made the column `postId` on table `Comment` required. This step will fail if there are existing NULL values in that column. - - Made the column `postId` on table `Like` required. This step will fail if there are existing NULL values in that column. - - Made the column `content` on table `Message` required. This step will fail if there are existing NULL values in that column. - - Added the required column `content` to the `Notification` table without a default value. This is not possible if the table is not empty. - - Changed the type of `type` on the `Notification` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. - - Made the column `content` on table `Post` required. This step will fail if there are existing NULL values in that column. - -*/ --- CreateEnum -CREATE TYPE "ChatRole" AS ENUM ('ADMIN', 'MEMBER'); - --- CreateEnum -CREATE TYPE "PostType" AS ENUM ('POST', 'REEL', 'STORY'); - --- CreateEnum -CREATE TYPE "NotificationType" AS ENUM ('LIKE', 'COMMENT', 'FOLLOW', 'MENTION', 'MESSAGE'); - --- DropForeignKey -ALTER TABLE "AccountSettings" DROP CONSTRAINT "AccountSettings_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Ad" DROP CONSTRAINT "Ad_campaignId_fkey"; - --- DropForeignKey -ALTER TABLE "Ad" DROP CONSTRAINT "Ad_postId_fkey"; - --- DropForeignKey -ALTER TABLE "Ad" DROP CONSTRAINT "Ad_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "Ad" DROP CONSTRAINT "Ad_storyId_fkey"; - --- DropForeignKey -ALTER TABLE "AdCampaign" DROP CONSTRAINT "AdCampaign_advertiserId_fkey"; - --- DropForeignKey -ALTER TABLE "AdInteraction" DROP CONSTRAINT "AdInteraction_adId_fkey"; - --- DropForeignKey -ALTER TABLE "AdInteraction" DROP CONSTRAINT "AdInteraction_userId_fkey"; - --- DropForeignKey -ALTER TABLE "AdPayment" DROP CONSTRAINT "AdPayment_campaignId_fkey"; - --- DropForeignKey -ALTER TABLE "AdPreference" DROP CONSTRAINT "AdPreference_userId_fkey"; - --- DropForeignKey -ALTER TABLE "AdReport" DROP CONSTRAINT "AdReport_adId_fkey"; - --- DropForeignKey -ALTER TABLE "AdReport" DROP CONSTRAINT "AdReport_userId_fkey"; - --- DropForeignKey -ALTER TABLE "AdTargeting" DROP CONSTRAINT "AdTargeting_campaignId_fkey"; - --- DropForeignKey -ALTER TABLE "Collection" DROP CONSTRAINT "Collection_userId_fkey"; - --- DropForeignKey -ALTER TABLE "CollectionPost" DROP CONSTRAINT "CollectionPost_collectionId_fkey"; - --- DropForeignKey -ALTER TABLE "CollectionPost" DROP CONSTRAINT "CollectionPost_postId_fkey"; - --- DropForeignKey -ALTER TABLE "Comment" DROP CONSTRAINT "Comment_momentId_fkey"; - --- DropForeignKey -ALTER TABLE "Comment" DROP CONSTRAINT "Comment_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "GitHubProject" DROP CONSTRAINT "GitHubProject_userId_fkey"; - --- DropForeignKey -ALTER TABLE "GroupChat" DROP CONSTRAINT "GroupChat_creatorId_fkey"; - --- DropForeignKey -ALTER TABLE "GroupChatMember" DROP CONSTRAINT "GroupChatMember_groupId_fkey"; - --- DropForeignKey -ALTER TABLE "GroupChatMember" DROP CONSTRAINT "GroupChatMember_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Like" DROP CONSTRAINT "Like_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "LinkedAccount" DROP CONSTRAINT "LinkedAccount_linkedUserId_fkey"; - --- DropForeignKey -ALTER TABLE "LinkedAccount" DROP CONSTRAINT "LinkedAccount_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_groupId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_recipientId_fkey"; - --- DropForeignKey -ALTER TABLE "MessageRequest" DROP CONSTRAINT "MessageRequest_recipientId_fkey"; - --- DropForeignKey -ALTER TABLE "MessageRequest" DROP CONSTRAINT "MessageRequest_senderId_fkey"; - --- DropForeignKey -ALTER TABLE "Moment" DROP CONSTRAINT "Moment_userId_fkey"; - --- DropForeignKey -ALTER TABLE "MomentLike" DROP CONSTRAINT "MomentLike_momentId_fkey"; - --- DropForeignKey -ALTER TABLE "MomentLike" DROP CONSTRAINT "MomentLike_userId_fkey"; - --- DropForeignKey -ALTER TABLE "NotificationPreference" DROP CONSTRAINT "NotificationPreference_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Post" DROP CONSTRAINT "Post_githubRepoId_fkey"; - --- DropForeignKey -ALTER TABLE "PostReport" DROP CONSTRAINT "PostReport_postId_fkey"; - --- DropForeignKey -ALTER TABLE "PostReport" DROP CONSTRAINT "PostReport_userId_fkey"; - --- DropForeignKey -ALTER TABLE "PostShare" DROP CONSTRAINT "PostShare_postId_fkey"; - --- DropForeignKey -ALTER TABLE "PostShare" DROP CONSTRAINT "PostShare_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Reel" DROP CONSTRAINT "Reel_userId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedPost" DROP CONSTRAINT "SavedPost_userId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedProject" DROP CONSTRAINT "SavedProject_projectId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedProject" DROP CONSTRAINT "SavedProject_userId_fkey"; - --- DropForeignKey -ALTER TABLE "StoreItem" DROP CONSTRAINT "StoreItem_sellerId_fkey"; - --- DropForeignKey -ALTER TABLE "Subscription" DROP CONSTRAINT "Subscription_userId_fkey"; - --- DropForeignKey -ALTER TABLE "SubscriptionHistory" DROP CONSTRAINT "SubscriptionHistory_subscriptionId_fkey"; - --- DropForeignKey -ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_buyerId_fkey"; - --- DropForeignKey -ALTER TABLE "Transaction" DROP CONSTRAINT "Transaction_itemId_fkey"; - --- DropForeignKey -ALTER TABLE "UserBlock" DROP CONSTRAINT "UserBlock_blockedId_fkey"; - --- DropForeignKey -ALTER TABLE "UserBlock" DROP CONSTRAINT "UserBlock_blockerId_fkey"; - --- DropForeignKey -ALTER TABLE "UserSession" DROP CONSTRAINT "UserSession_userId_fkey"; - --- DropForeignKey -ALTER TABLE "VerificationPurchase" DROP CONSTRAINT "VerificationPurchase_userId_fkey"; - --- DropIndex -DROP INDEX "Comment_createdAt_idx"; - --- DropIndex -DROP INDEX "Comment_momentId_idx"; - --- DropIndex -DROP INDEX "Comment_reelId_idx"; - --- DropIndex -DROP INDEX "Like_reelId_idx"; - --- DropIndex -DROP INDEX "Like_userId_postId_key"; - --- DropIndex -DROP INDEX "Like_userId_reelId_key"; - --- DropIndex -DROP INDEX "Message_groupId_idx"; - --- DropIndex -DROP INDEX "Message_isRead_idx"; - --- DropIndex -DROP INDEX "Message_recipientId_idx"; - --- DropIndex -DROP INDEX "Message_senderId_recipientId_idx"; - --- DropIndex -DROP INDEX "Notification_type_idx"; - --- DropIndex -DROP INDEX "Notification_userId_isRead_idx"; - --- DropIndex -DROP INDEX "Post_isArchived_idx"; - --- DropIndex -DROP INDEX "Post_userId_createdAt_idx"; - --- DropIndex -DROP INDEX "PostReport_status_idx"; - --- DropIndex -DROP INDEX "Story_userId_expiresAt_idx"; - --- DropIndex -DROP INDEX "User_createdAt_idx"; - --- AlterTable -ALTER TABLE "Comment" DROP COLUMN "likesCount", -DROP COLUMN "momentId", -DROP COLUMN "reelId", -ALTER COLUMN "postId" SET NOT NULL; - --- AlterTable -ALTER TABLE "Like" DROP COLUMN "reelId", -ALTER COLUMN "postId" SET NOT NULL; - --- AlterTable -ALTER TABLE "Message" DROP COLUMN "groupId", -DROP COLUMN "isRead", -DROP COLUMN "mediaType", -DROP COLUMN "recipientId", -ADD COLUMN "chatId" TEXT, -ADD COLUMN "read" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "receiverId" TEXT, -ALTER COLUMN "content" SET NOT NULL; - --- AlterTable -ALTER TABLE "Notification" DROP COLUMN "body", -DROP COLUMN "data", -DROP COLUMN "isRead", -DROP COLUMN "title", -ADD COLUMN "actorId" TEXT, -ADD COLUMN "content" TEXT NOT NULL, -ADD COLUMN "postId" TEXT, -ADD COLUMN "read" BOOLEAN NOT NULL DEFAULT false, -DROP COLUMN "type", -ADD COLUMN "type" "NotificationType" NOT NULL; - --- AlterTable -ALTER TABLE "Post" DROP COLUMN "codeSnippet", -DROP COLUMN "githubRepoId", -DROP COLUMN "hashtags", -DROP COLUMN "isArchived", -DROP COLUMN "language", -DROP COLUMN "latitude", -DROP COLUMN "location", -DROP COLUMN "longitude", -DROP COLUMN "mediaType", -DROP COLUMN "mediaUrl", -DROP COLUMN "mentions", -ADD COLUMN "mediaUrls" TEXT[], -ADD COLUMN "projectId" TEXT, -ADD COLUMN "repoData" JSONB, -ADD COLUMN "repoUrl" TEXT, -ADD COLUMN "type" "PostType" NOT NULL DEFAULT 'POST', -ADD COLUMN "viewsCount" INTEGER NOT NULL DEFAULT 0, -ALTER COLUMN "content" SET NOT NULL; - --- AlterTable -ALTER TABLE "PostReport" DROP COLUMN "details", -DROP COLUMN "status"; - --- AlterTable -ALTER TABLE "SavedPost" ADD COLUMN "collectionId" TEXT; - --- AlterTable -ALTER TABLE "Story" DROP COLUMN "mediaType"; - --- AlterTable -ALTER TABLE "StoryView" DROP COLUMN "viewedAt", -ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; - --- AlterTable -ALTER TABLE "User" DROP COLUMN "githubToken", -DROP COLUMN "interests", -DROP COLUMN "isGoldenVerified", -DROP COLUMN "isVerified", -DROP COLUMN "latitude", -DROP COLUMN "longitude", -DROP COLUMN "role", -ADD COLUMN "emailVerified" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "githubAccessToken" TEXT, -ADD COLUMN "googleId" TEXT, -ADD COLUMN "location" TEXT, -ADD COLUMN "premium" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "twoFactorEnabled" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "twoFactorSecret" TEXT, -ADD COLUMN "verified" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "website" TEXT; - --- DropTable -DROP TABLE "AccountSettings"; - --- DropTable -DROP TABLE "Ad"; - --- DropTable -DROP TABLE "AdCampaign"; - --- DropTable -DROP TABLE "AdInteraction"; - --- DropTable -DROP TABLE "AdPayment"; - --- DropTable -DROP TABLE "AdPreference"; - --- DropTable -DROP TABLE "AdReport"; - --- DropTable -DROP TABLE "AdTargeting"; - --- DropTable -DROP TABLE "Collection"; - --- DropTable -DROP TABLE "CollectionPost"; - --- DropTable -DROP TABLE "EmailVerificationToken"; - --- DropTable -DROP TABLE "Feedback"; - --- DropTable -DROP TABLE "GitHubProject"; - --- DropTable -DROP TABLE "GitHubSync"; - --- DropTable -DROP TABLE "GroupChat"; - --- DropTable -DROP TABLE "GroupChatMember"; - --- DropTable -DROP TABLE "LinkedAccount"; - --- DropTable -DROP TABLE "MessageRequest"; - --- DropTable -DROP TABLE "Moment"; - --- DropTable -DROP TABLE "MomentLike"; - --- DropTable -DROP TABLE "NotificationPreference"; - --- DropTable -DROP TABLE "PasswordResetToken"; - --- DropTable -DROP TABLE "Reel"; - --- DropTable -DROP TABLE "RefreshToken"; - --- DropTable -DROP TABLE "SavedProject"; - --- DropTable -DROP TABLE "StoreItem"; - --- DropTable -DROP TABLE "Subscription"; - --- DropTable -DROP TABLE "SubscriptionHistory"; - --- DropTable -DROP TABLE "Transaction"; - --- DropTable -DROP TABLE "UserSession"; - --- DropTable -DROP TABLE "VerificationPurchase"; - --- DropTable -DROP TABLE "VerificationRequest"; - --- CreateTable -CREATE TABLE "Session" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "refreshToken" TEXT NOT NULL, - "expiresAt" TIMESTAMP(3) NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Session_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Chat" ( - "id" TEXT NOT NULL, - "name" TEXT, - "isGroup" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Chat_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ChatMember" ( - "id" TEXT NOT NULL, - "chatId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "role" "ChatRole" NOT NULL DEFAULT 'MEMBER', - "joinedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ChatMember_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Hashtag" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "count" INTEGER NOT NULL DEFAULT 0, - "trending" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Hashtag_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PostHashtag" ( - "id" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "hashtagId" TEXT NOT NULL, - - CONSTRAINT "PostHashtag_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryReaction" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryReaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryReply" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryReply_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Mention" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "postId" TEXT, - "commentId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Mention_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedCollection" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "isPrivate" BOOLEAN NOT NULL DEFAULT true, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "SavedCollection_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedCollectionItem" ( - "id" TEXT NOT NULL, - "collectionId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SavedCollectionItem_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Project" ( - "id" TEXT NOT NULL, - "githubId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "owner" TEXT NOT NULL, - "description" TEXT, - "url" TEXT NOT NULL, - "stars" INTEGER NOT NULL DEFAULT 0, - "forks" INTEGER NOT NULL DEFAULT 0, - "language" TEXT, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Project_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "Session_refreshToken_key" ON "Session"("refreshToken"); - --- CreateIndex -CREATE INDEX "Session_userId_idx" ON "Session"("userId"); - --- CreateIndex -CREATE INDEX "Session_refreshToken_idx" ON "Session"("refreshToken"); - --- CreateIndex -CREATE INDEX "Chat_isGroup_idx" ON "Chat"("isGroup"); - --- CreateIndex -CREATE INDEX "ChatMember_chatId_idx" ON "ChatMember"("chatId"); - --- CreateIndex -CREATE INDEX "ChatMember_userId_idx" ON "ChatMember"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "ChatMember_chatId_userId_key" ON "ChatMember"("chatId", "userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Hashtag_name_key" ON "Hashtag"("name"); - --- CreateIndex -CREATE INDEX "Hashtag_name_idx" ON "Hashtag"("name"); - --- CreateIndex -CREATE INDEX "Hashtag_trending_idx" ON "Hashtag"("trending"); - --- CreateIndex -CREATE INDEX "PostHashtag_postId_idx" ON "PostHashtag"("postId"); - --- CreateIndex -CREATE INDEX "PostHashtag_hashtagId_idx" ON "PostHashtag"("hashtagId"); - --- CreateIndex -CREATE UNIQUE INDEX "PostHashtag_postId_hashtagId_key" ON "PostHashtag"("postId", "hashtagId"); - --- CreateIndex -CREATE INDEX "StoryReaction_storyId_idx" ON "StoryReaction"("storyId"); - --- CreateIndex -CREATE INDEX "StoryReaction_userId_idx" ON "StoryReaction"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "StoryReaction_storyId_userId_key" ON "StoryReaction"("storyId", "userId"); - --- CreateIndex -CREATE INDEX "StoryReply_storyId_idx" ON "StoryReply"("storyId"); - --- CreateIndex -CREATE INDEX "StoryReply_userId_idx" ON "StoryReply"("userId"); - --- CreateIndex -CREATE INDEX "Mention_userId_idx" ON "Mention"("userId"); - --- CreateIndex -CREATE INDEX "Mention_postId_idx" ON "Mention"("postId"); - --- CreateIndex -CREATE INDEX "Mention_commentId_idx" ON "Mention"("commentId"); - --- CreateIndex -CREATE INDEX "SavedCollection_userId_idx" ON "SavedCollection"("userId"); - --- CreateIndex -CREATE INDEX "SavedCollectionItem_collectionId_idx" ON "SavedCollectionItem"("collectionId"); - --- CreateIndex -CREATE INDEX "SavedCollectionItem_postId_idx" ON "SavedCollectionItem"("postId"); - --- CreateIndex -CREATE UNIQUE INDEX "SavedCollectionItem_collectionId_postId_key" ON "SavedCollectionItem"("collectionId", "postId"); - --- CreateIndex -CREATE UNIQUE INDEX "Project_githubId_key" ON "Project"("githubId"); - --- CreateIndex -CREATE INDEX "Project_userId_idx" ON "Project"("userId"); - --- CreateIndex -CREATE INDEX "Project_owner_name_idx" ON "Project"("owner", "name"); - --- CreateIndex -CREATE INDEX "Like_userId_idx" ON "Like"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Like_postId_userId_key" ON "Like"("postId", "userId"); - --- CreateIndex -CREATE INDEX "Message_senderId_idx" ON "Message"("senderId"); - --- CreateIndex -CREATE INDEX "Message_receiverId_idx" ON "Message"("receiverId"); - --- CreateIndex -CREATE INDEX "Message_chatId_idx" ON "Message"("chatId"); - --- CreateIndex -CREATE INDEX "Notification_userId_idx" ON "Notification"("userId"); - --- CreateIndex -CREATE INDEX "Notification_read_idx" ON "Notification"("read"); - --- CreateIndex -CREATE INDEX "Post_projectId_idx" ON "Post"("projectId"); - --- CreateIndex -CREATE INDEX "Post_type_idx" ON "Post"("type"); - --- CreateIndex -CREATE INDEX "SavedPost_userId_idx" ON "SavedPost"("userId"); - --- CreateIndex -CREATE INDEX "SavedPost_postId_idx" ON "SavedPost"("postId"); - --- CreateIndex -CREATE INDEX "SavedPost_collectionId_idx" ON "SavedPost"("collectionId"); - --- CreateIndex -CREATE INDEX "StoryView_storyId_idx" ON "StoryView"("storyId"); - --- CreateIndex -CREATE INDEX "StoryView_userId_idx" ON "StoryView"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "User_googleId_key" ON "User"("googleId"); - --- CreateIndex -CREATE INDEX "User_githubId_idx" ON "User"("githubId"); - --- CreateIndex -CREATE INDEX "User_googleId_idx" ON "User"("googleId"); - --- AddForeignKey -ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ChatMember" ADD CONSTRAINT "ChatMember_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_hashtagId_fkey" FOREIGN KEY ("hashtagId") REFERENCES "Hashtag"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReaction" ADD CONSTRAINT "StoryReaction_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReply" ADD CONSTRAINT "StoryReply_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedCollectionItem" ADD CONSTRAINT "SavedCollectionItem_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251130082143_add_monetization_models/migration.sql b/gitgram/backend/prisma/migrations/20251130082143_add_monetization_models/migration.sql deleted file mode 100644 index 6dce1793..00000000 --- a/gitgram/backend/prisma/migrations/20251130082143_add_monetization_models/migration.sql +++ /dev/null @@ -1,105 +0,0 @@ --- CreateTable -CREATE TABLE "Subscription" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "plan" TEXT NOT NULL, - "status" TEXT NOT NULL, - "stripeCustomerId" TEXT, - "stripeSubscriptionId" TEXT, - "currentPeriodEnd" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Subscription_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Analytics" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "views" INTEGER NOT NULL DEFAULT 0, - "likes" INTEGER NOT NULL DEFAULT 0, - "comments" INTEGER NOT NULL DEFAULT 0, - "shares" INTEGER NOT NULL DEFAULT 0, - "followers" INTEGER NOT NULL DEFAULT 0, - "reach" INTEGER NOT NULL DEFAULT 0, - "engagement" DOUBLE PRECISION NOT NULL DEFAULT 0, - - CONSTRAINT "Analytics_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ScheduledPost" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "mediaUrls" TEXT[], - "scheduledFor" TIMESTAMP(3) NOT NULL, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ScheduledPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Advertisement" ( - "id" TEXT NOT NULL, - "advertiserId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "content" TEXT NOT NULL, - "mediaUrl" TEXT, - "targetAudience" JSONB, - "budget" DOUBLE PRECISION NOT NULL, - "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, - "impressions" INTEGER NOT NULL DEFAULT 0, - "clicks" INTEGER NOT NULL DEFAULT 0, - "status" TEXT NOT NULL DEFAULT 'active', - "startDate" TIMESTAMP(3) NOT NULL, - "endDate" TIMESTAMP(3) NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Advertisement_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_userId_key" ON "Subscription"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_stripeCustomerId_key" ON "Subscription"("stripeCustomerId"); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_stripeSubscriptionId_key" ON "Subscription"("stripeSubscriptionId"); - --- CreateIndex -CREATE INDEX "Subscription_userId_idx" ON "Subscription"("userId"); - --- CreateIndex -CREATE INDEX "Subscription_status_idx" ON "Subscription"("status"); - --- CreateIndex -CREATE INDEX "Analytics_userId_idx" ON "Analytics"("userId"); - --- CreateIndex -CREATE INDEX "Analytics_date_idx" ON "Analytics"("date"); - --- CreateIndex -CREATE UNIQUE INDEX "Analytics_userId_date_key" ON "Analytics"("userId", "date"); - --- CreateIndex -CREATE INDEX "ScheduledPost_userId_idx" ON "ScheduledPost"("userId"); - --- CreateIndex -CREATE INDEX "ScheduledPost_scheduledFor_idx" ON "ScheduledPost"("scheduledFor"); - --- CreateIndex -CREATE INDEX "ScheduledPost_status_idx" ON "ScheduledPost"("status"); - --- CreateIndex -CREATE INDEX "Advertisement_advertiserId_idx" ON "Advertisement"("advertiserId"); - --- CreateIndex -CREATE INDEX "Advertisement_status_idx" ON "Advertisement"("status"); - --- CreateIndex -CREATE INDEX "Advertisement_startDate_idx" ON "Advertisement"("startDate"); diff --git a/gitgram/backend/prisma/migrations/20251130095349_add_moderation_log/migration.sql b/gitgram/backend/prisma/migrations/20251130095349_add_moderation_log/migration.sql deleted file mode 100644 index ad601f9d..00000000 --- a/gitgram/backend/prisma/migrations/20251130095349_add_moderation_log/migration.sql +++ /dev/null @@ -1,22 +0,0 @@ --- CreateTable -CREATE TABLE "ModerationLog" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "flags" TEXT NOT NULL, - "scores" TEXT NOT NULL, - "action" TEXT NOT NULL, - "category" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ModerationLog_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "ModerationLog_userId_idx" ON "ModerationLog"("userId"); - --- CreateIndex -CREATE INDEX "ModerationLog_action_idx" ON "ModerationLog"("action"); - --- CreateIndex -CREATE INDEX "ModerationLog_createdAt_idx" ON "ModerationLog"("createdAt"); diff --git a/gitgram/backend/prisma/migrations/20251130101604_add_notification_preferences/migration.sql b/gitgram/backend/prisma/migrations/20251130101604_add_notification_preferences/migration.sql deleted file mode 100644 index 9c19c0e7..00000000 --- a/gitgram/backend/prisma/migrations/20251130101604_add_notification_preferences/migration.sql +++ /dev/null @@ -1,21 +0,0 @@ --- CreateTable -CREATE TABLE "NotificationPreferences" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "likes" BOOLEAN NOT NULL DEFAULT true, - "comments" BOOLEAN NOT NULL DEFAULT true, - "follows" BOOLEAN NOT NULL DEFAULT true, - "mentions" BOOLEAN NOT NULL DEFAULT true, - "messages" BOOLEAN NOT NULL DEFAULT true, - "posts" BOOLEAN NOT NULL DEFAULT true, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "NotificationPreferences_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "NotificationPreferences_userId_key" ON "NotificationPreferences"("userId"); - --- CreateIndex -CREATE INDEX "NotificationPreferences_userId_idx" ON "NotificationPreferences"("userId"); diff --git a/gitgram/backend/prisma/migrations/20251201113012_add_universal_repos/migration.sql b/gitgram/backend/prisma/migrations/20251201113012_add_universal_repos/migration.sql deleted file mode 100644 index 6cde7df2..00000000 --- a/gitgram/backend/prisma/migrations/20251201113012_add_universal_repos/migration.sql +++ /dev/null @@ -1,67 +0,0 @@ --- AlterTable -ALTER TABLE "Post" ADD COLUMN "repoName" TEXT, -ADD COLUMN "repoOwner" TEXT, -ADD COLUMN "repositoryId" TEXT; - --- CreateTable -CREATE TABLE "Repository" ( - "id" TEXT NOT NULL, - "owner" TEXT NOT NULL, - "name" TEXT NOT NULL, - "fullName" TEXT NOT NULL, - "description" TEXT, - "stars" INTEGER NOT NULL DEFAULT 0, - "forks" INTEGER NOT NULL DEFAULT 0, - "language" TEXT, - "topics" TEXT[], - "avatarUrl" TEXT, - "htmlUrl" TEXT NOT NULL, - "lastFetched" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Repository_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepositoryFollow" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepositoryFollow_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "Repository_stars_idx" ON "Repository"("stars"); - --- CreateIndex -CREATE INDEX "Repository_language_idx" ON "Repository"("language"); - --- CreateIndex -CREATE INDEX "Repository_fullName_idx" ON "Repository"("fullName"); - --- CreateIndex -CREATE UNIQUE INDEX "Repository_owner_name_key" ON "Repository"("owner", "name"); - --- CreateIndex -CREATE INDEX "RepositoryFollow_userId_idx" ON "RepositoryFollow"("userId"); - --- CreateIndex -CREATE INDEX "RepositoryFollow_repositoryId_idx" ON "RepositoryFollow"("repositoryId"); - --- CreateIndex -CREATE UNIQUE INDEX "RepositoryFollow_userId_repositoryId_key" ON "RepositoryFollow"("userId", "repositoryId"); - --- CreateIndex -CREATE INDEX "Post_repositoryId_idx" ON "Post"("repositoryId"); - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryFollow" ADD CONSTRAINT "RepositoryFollow_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryFollow" ADD CONSTRAINT "RepositoryFollow_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251201113939_github_features_enhancement/migration.sql b/gitgram/backend/prisma/migrations/20251201113939_github_features_enhancement/migration.sql deleted file mode 100644 index 9ff3c55e..00000000 --- a/gitgram/backend/prisma/migrations/20251201113939_github_features_enhancement/migration.sql +++ /dev/null @@ -1,118 +0,0 @@ --- AlterTable -ALTER TABLE "Repository" ADD COLUMN "openIssues" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "trending" BOOLEAN NOT NULL DEFAULT false, -ADD COLUMN "trendingScore" DOUBLE PRECISION NOT NULL DEFAULT 0, -ADD COLUMN "watchers" INTEGER NOT NULL DEFAULT 0; - --- CreateTable -CREATE TABLE "UserLanguagePreference" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "language" TEXT NOT NULL, - "score" DOUBLE PRECISION NOT NULL DEFAULT 1.0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "UserLanguagePreference_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "UserTopicInterest" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "topic" TEXT NOT NULL, - "score" DOUBLE PRECISION NOT NULL DEFAULT 1.0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "UserTopicInterest_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepositoryView" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepositoryView_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepositoryBookmark" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepositoryBookmark_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "TrendingRepository" ( - "id" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "period" TEXT NOT NULL, - "rank" INTEGER NOT NULL, - "score" DOUBLE PRECISION NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "TrendingRepository_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "UserLanguagePreference_userId_idx" ON "UserLanguagePreference"("userId"); - --- CreateIndex -CREATE INDEX "UserLanguagePreference_language_idx" ON "UserLanguagePreference"("language"); - --- CreateIndex -CREATE UNIQUE INDEX "UserLanguagePreference_userId_language_key" ON "UserLanguagePreference"("userId", "language"); - --- CreateIndex -CREATE INDEX "UserTopicInterest_userId_idx" ON "UserTopicInterest"("userId"); - --- CreateIndex -CREATE INDEX "UserTopicInterest_topic_idx" ON "UserTopicInterest"("topic"); - --- CreateIndex -CREATE UNIQUE INDEX "UserTopicInterest_userId_topic_key" ON "UserTopicInterest"("userId", "topic"); - --- CreateIndex -CREATE INDEX "RepositoryView_userId_idx" ON "RepositoryView"("userId"); - --- CreateIndex -CREATE INDEX "RepositoryView_repositoryId_idx" ON "RepositoryView"("repositoryId"); - --- CreateIndex -CREATE INDEX "RepositoryView_createdAt_idx" ON "RepositoryView"("createdAt"); - --- CreateIndex -CREATE INDEX "RepositoryBookmark_userId_idx" ON "RepositoryBookmark"("userId"); - --- CreateIndex -CREATE INDEX "RepositoryBookmark_repositoryId_idx" ON "RepositoryBookmark"("repositoryId"); - --- CreateIndex -CREATE UNIQUE INDEX "RepositoryBookmark_userId_repositoryId_key" ON "RepositoryBookmark"("userId", "repositoryId"); - --- CreateIndex -CREATE INDEX "TrendingRepository_period_rank_idx" ON "TrendingRepository"("period", "rank"); - --- CreateIndex -CREATE INDEX "TrendingRepository_createdAt_idx" ON "TrendingRepository"("createdAt"); - --- CreateIndex -CREATE UNIQUE INDEX "TrendingRepository_repositoryId_period_key" ON "TrendingRepository"("repositoryId", "period"); - --- CreateIndex -CREATE INDEX "Repository_trending_idx" ON "Repository"("trending"); - --- CreateIndex -CREATE INDEX "Repository_trendingScore_idx" ON "Repository"("trendingScore"); - --- AddForeignKey -ALTER TABLE "RepositoryView" ADD CONSTRAINT "RepositoryView_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryBookmark" ADD CONSTRAINT "RepositoryBookmark_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251201232249_add_gif_support/migration.sql b/gitgram/backend/prisma/migrations/20251201232249_add_gif_support/migration.sql deleted file mode 100644 index 8ae1ed41..00000000 --- a/gitgram/backend/prisma/migrations/20251201232249_add_gif_support/migration.sql +++ /dev/null @@ -1,5 +0,0 @@ --- AlterTable -ALTER TABLE "Message" ADD COLUMN "gifUrl" TEXT; - --- AlterTable -ALTER TABLE "Post" ADD COLUMN "gifUrl" TEXT; diff --git a/gitgram/backend/prisma/migrations/20251202160047_add_reels_and_update_stories/migration.sql b/gitgram/backend/prisma/migrations/20251202160047_add_reels_and_update_stories/migration.sql deleted file mode 100644 index be5cf0f6..00000000 --- a/gitgram/backend/prisma/migrations/20251202160047_add_reels_and_update_stories/migration.sql +++ /dev/null @@ -1,149 +0,0 @@ --- DropIndex -DROP INDEX "Repository_fullName_idx"; - --- DropIndex -DROP INDEX "Repository_trendingScore_idx"; - --- AlterTable -ALTER TABLE "Story" ADD COLUMN "caption" TEXT, -ADD COLUMN "duration" INTEGER, -ADD COLUMN "mediaType" TEXT NOT NULL DEFAULT 'image', -ADD COLUMN "repositoryId" TEXT, -ADD COLUMN "thumbnailUrl" TEXT; - --- CreateTable -CREATE TABLE "Reel" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT, - "title" TEXT NOT NULL, - "description" TEXT, - "videoUrl" TEXT NOT NULL, - "thumbnailUrl" TEXT NOT NULL, - "duration" INTEGER NOT NULL, - "width" INTEGER, - "height" INTEGER, - "viewsCount" INTEGER NOT NULL DEFAULT 0, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "commentsCount" INTEGER NOT NULL DEFAULT 0, - "sharesCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Reel_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ReelLike" ( - "id" TEXT NOT NULL, - "reelId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ReelLike_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ReelComment" ( - "id" TEXT NOT NULL, - "reelId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ReelComment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ReelView" ( - "id" TEXT NOT NULL, - "reelId" TEXT NOT NULL, - "userId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ReelView_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "Reel_userId_idx" ON "Reel"("userId"); - --- CreateIndex -CREATE INDEX "Reel_repositoryId_idx" ON "Reel"("repositoryId"); - --- CreateIndex -CREATE INDEX "Reel_createdAt_idx" ON "Reel"("createdAt"); - --- CreateIndex -CREATE INDEX "Reel_viewsCount_idx" ON "Reel"("viewsCount"); - --- CreateIndex -CREATE INDEX "ReelLike_reelId_idx" ON "ReelLike"("reelId"); - --- CreateIndex -CREATE INDEX "ReelLike_userId_idx" ON "ReelLike"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "ReelLike_reelId_userId_key" ON "ReelLike"("reelId", "userId"); - --- CreateIndex -CREATE INDEX "ReelComment_reelId_idx" ON "ReelComment"("reelId"); - --- CreateIndex -CREATE INDEX "ReelComment_userId_idx" ON "ReelComment"("userId"); - --- CreateIndex -CREATE INDEX "ReelView_reelId_idx" ON "ReelView"("reelId"); - --- CreateIndex -CREATE INDEX "ReelView_userId_idx" ON "ReelView"("userId"); - --- CreateIndex -CREATE INDEX "ReelView_createdAt_idx" ON "ReelView"("createdAt"); - --- CreateIndex -CREATE INDEX "Repository_owner_idx" ON "Repository"("owner"); - --- CreateIndex -CREATE INDEX "Repository_name_idx" ON "Repository"("name"); - --- CreateIndex -CREATE INDEX "Repository_lastFetched_idx" ON "Repository"("lastFetched"); - --- CreateIndex -CREATE INDEX "Story_repositoryId_idx" ON "Story"("repositoryId"); - --- CreateIndex -CREATE INDEX "Story_createdAt_idx" ON "Story"("createdAt"); - --- AddForeignKey -ALTER TABLE "Story" ADD CONSTRAINT "Story_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryView" ADD CONSTRAINT "StoryView_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Reel" ADD CONSTRAINT "Reel_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Reel" ADD CONSTRAINT "Reel_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelLike" ADD CONSTRAINT "ReelLike_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelLike" ADD CONSTRAINT "ReelLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelView" ADD CONSTRAINT "ReelView_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelView" ADD CONSTRAINT "ReelView_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryBookmark" ADD CONSTRAINT "RepositoryBookmark_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251203193811_add_account_system/migration.sql b/gitgram/backend/prisma/migrations/20251203193811_add_account_system/migration.sql deleted file mode 100644 index 3330e8d7..00000000 --- a/gitgram/backend/prisma/migrations/20251203193811_add_account_system/migration.sql +++ /dev/null @@ -1,601 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `updatedAt` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Like` table. All the data in the column will be lost. - - You are about to drop the column `chatId` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `gifUrl` on the `Message` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `gifUrl` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `projectId` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `repoData` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `repoName` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `repoOwner` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `repoUrl` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `repositoryId` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `viewsCount` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `commentsCount` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `description` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `height` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `repositoryId` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `sharesCount` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `updatedAt` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `width` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `avatarUrl` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `lastFetched` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `openIssues` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `trending` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `trendingScore` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `duration` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `repositoryId` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `thumbnailUrl` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `userId` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `avatar` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `bio` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `location` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `premium` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `twoFactorEnabled` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `twoFactorSecret` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `username` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `verified` on the `User` table. All the data in the column will be lost. - - You are about to drop the column `website` on the `User` table. All the data in the column will be lost. - - You are about to drop the `Advertisement` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Analytics` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Chat` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ChatMember` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Hashtag` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Mention` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ModerationLog` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `NotificationPreferences` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PostHashtag` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PostReport` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PostShare` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Project` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ReelComment` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ReelLike` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ReelView` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `RepositoryBookmark` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `RepositoryFollow` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `RepositoryView` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedCollection` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedCollectionItem` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedPost` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ScheduledPost` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `StoryReaction` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `StoryReply` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `StoryView` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Subscription` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `TrendingRepository` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `UserBlock` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `UserLanguagePreference` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `UserTopicInterest` table. If the table is not empty, all the data it contains will be lost. - - A unique constraint covering the columns `[postId,accountId]` on the table `Like` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[fullName]` on the table `Repository` will be added. If there are existing duplicate values, this will fail. - - Added the required column `accountId` to the `Comment` table without a default value. This is not possible if the table is not empty. - - Added the required column `accountId` to the `Like` table without a default value. This is not possible if the table is not empty. - - Made the column `receiverId` on table `Message` required. This step will fail if there are existing NULL values in that column. - - Added the required column `accountId` to the `Notification` table without a default value. This is not possible if the table is not empty. - - Added the required column `accountId` to the `Post` table without a default value. This is not possible if the table is not empty. - - Added the required column `accountId` to the `Reel` table without a default value. This is not possible if the table is not empty. - - Added the required column `accountId` to the `Story` table without a default value. This is not possible if the table is not empty. - -*/ --- CreateEnum -CREATE TYPE "AccountType" AS ENUM ('USER', 'REPOSITORY', 'ORGANIZATION'); - --- CreateEnum -CREATE TYPE "ManagerRole" AS ENUM ('OWNER', 'ADMIN', 'EDITOR', 'VIEWER'); - --- CreateEnum -CREATE TYPE "OrgRole" AS ENUM ('OWNER', 'ADMIN', 'MEMBER'); - --- AlterEnum -ALTER TYPE "NotificationType" ADD VALUE 'REPO_UPDATE'; - --- DropForeignKey -ALTER TABLE "ChatMember" DROP CONSTRAINT "ChatMember_chatId_fkey"; - --- DropForeignKey -ALTER TABLE "Comment" DROP CONSTRAINT "Comment_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Follow" DROP CONSTRAINT "Follow_followerId_fkey"; - --- DropForeignKey -ALTER TABLE "Follow" DROP CONSTRAINT "Follow_followingId_fkey"; - --- DropForeignKey -ALTER TABLE "Like" DROP CONSTRAINT "Like_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_chatId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_receiverId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_senderId_fkey"; - --- DropForeignKey -ALTER TABLE "Notification" DROP CONSTRAINT "Notification_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Post" DROP CONSTRAINT "Post_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "Post" DROP CONSTRAINT "Post_userId_fkey"; - --- DropForeignKey -ALTER TABLE "PostHashtag" DROP CONSTRAINT "PostHashtag_hashtagId_fkey"; - --- DropForeignKey -ALTER TABLE "PostHashtag" DROP CONSTRAINT "PostHashtag_postId_fkey"; - --- DropForeignKey -ALTER TABLE "Reel" DROP CONSTRAINT "Reel_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "Reel" DROP CONSTRAINT "Reel_userId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelComment" DROP CONSTRAINT "ReelComment_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelComment" DROP CONSTRAINT "ReelComment_userId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelLike" DROP CONSTRAINT "ReelLike_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelLike" DROP CONSTRAINT "ReelLike_userId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelView" DROP CONSTRAINT "ReelView_reelId_fkey"; - --- DropForeignKey -ALTER TABLE "ReelView" DROP CONSTRAINT "ReelView_userId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryBookmark" DROP CONSTRAINT "RepositoryBookmark_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryBookmark" DROP CONSTRAINT "RepositoryBookmark_userId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryFollow" DROP CONSTRAINT "RepositoryFollow_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryFollow" DROP CONSTRAINT "RepositoryFollow_userId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryView" DROP CONSTRAINT "RepositoryView_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedCollectionItem" DROP CONSTRAINT "SavedCollectionItem_collectionId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedPost" DROP CONSTRAINT "SavedPost_collectionId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedPost" DROP CONSTRAINT "SavedPost_postId_fkey"; - --- DropForeignKey -ALTER TABLE "Story" DROP CONSTRAINT "Story_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "Story" DROP CONSTRAINT "Story_userId_fkey"; - --- DropForeignKey -ALTER TABLE "StoryReaction" DROP CONSTRAINT "StoryReaction_storyId_fkey"; - --- DropForeignKey -ALTER TABLE "StoryReply" DROP CONSTRAINT "StoryReply_storyId_fkey"; - --- DropForeignKey -ALTER TABLE "StoryView" DROP CONSTRAINT "StoryView_storyId_fkey"; - --- DropForeignKey -ALTER TABLE "StoryView" DROP CONSTRAINT "StoryView_userId_fkey"; - --- DropIndex -DROP INDEX "Comment_userId_idx"; - --- DropIndex -DROP INDEX "Like_postId_userId_key"; - --- DropIndex -DROP INDEX "Like_userId_idx"; - --- DropIndex -DROP INDEX "Message_chatId_idx"; - --- DropIndex -DROP INDEX "Notification_userId_idx"; - --- DropIndex -DROP INDEX "Post_projectId_idx"; - --- DropIndex -DROP INDEX "Post_repositoryId_idx"; - --- DropIndex -DROP INDEX "Post_type_idx"; - --- DropIndex -DROP INDEX "Post_userId_idx"; - --- DropIndex -DROP INDEX "Reel_repositoryId_idx"; - --- DropIndex -DROP INDEX "Reel_userId_idx"; - --- DropIndex -DROP INDEX "Reel_viewsCount_idx"; - --- DropIndex -DROP INDEX "Repository_language_idx"; - --- DropIndex -DROP INDEX "Repository_lastFetched_idx"; - --- DropIndex -DROP INDEX "Repository_name_idx"; - --- DropIndex -DROP INDEX "Repository_stars_idx"; - --- DropIndex -DROP INDEX "Repository_trending_idx"; - --- DropIndex -DROP INDEX "Session_refreshToken_idx"; - --- DropIndex -DROP INDEX "Story_createdAt_idx"; - --- DropIndex -DROP INDEX "Story_repositoryId_idx"; - --- DropIndex -DROP INDEX "Story_userId_idx"; - --- DropIndex -DROP INDEX "User_googleId_idx"; - --- DropIndex -DROP INDEX "User_username_idx"; - --- DropIndex -DROP INDEX "User_username_key"; - --- AlterTable -ALTER TABLE "Comment" DROP COLUMN "updatedAt", -DROP COLUMN "userId", -ADD COLUMN "accountId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Like" DROP COLUMN "userId", -ADD COLUMN "accountId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Message" DROP COLUMN "chatId", -DROP COLUMN "gifUrl", -ALTER COLUMN "receiverId" SET NOT NULL; - --- AlterTable -ALTER TABLE "Notification" DROP COLUMN "userId", -ADD COLUMN "accountId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Post" DROP COLUMN "gifUrl", -DROP COLUMN "projectId", -DROP COLUMN "repoData", -DROP COLUMN "repoName", -DROP COLUMN "repoOwner", -DROP COLUMN "repoUrl", -DROP COLUMN "repositoryId", -DROP COLUMN "userId", -DROP COLUMN "viewsCount", -ADD COLUMN "accountId" TEXT NOT NULL, -ADD COLUMN "sharesCount" INTEGER NOT NULL DEFAULT 0; - --- AlterTable -ALTER TABLE "Reel" DROP COLUMN "commentsCount", -DROP COLUMN "description", -DROP COLUMN "height", -DROP COLUMN "repositoryId", -DROP COLUMN "sharesCount", -DROP COLUMN "updatedAt", -DROP COLUMN "userId", -DROP COLUMN "width", -ADD COLUMN "accountId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Repository" DROP COLUMN "avatarUrl", -DROP COLUMN "lastFetched", -DROP COLUMN "openIssues", -DROP COLUMN "trending", -DROP COLUMN "trendingScore", -ADD COLUMN "claimedAt" TIMESTAMP(3), -ADD COLUMN "claimedBy" TEXT, -ADD COLUMN "lastSynced" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; - --- AlterTable -ALTER TABLE "Story" DROP COLUMN "duration", -DROP COLUMN "repositoryId", -DROP COLUMN "thumbnailUrl", -DROP COLUMN "userId", -ADD COLUMN "accountId" TEXT NOT NULL, -ALTER COLUMN "mediaType" DROP DEFAULT; - --- AlterTable -ALTER TABLE "User" DROP COLUMN "avatar", -DROP COLUMN "bio", -DROP COLUMN "location", -DROP COLUMN "premium", -DROP COLUMN "twoFactorEnabled", -DROP COLUMN "twoFactorSecret", -DROP COLUMN "username", -DROP COLUMN "verified", -DROP COLUMN "website"; - --- DropTable -DROP TABLE "Advertisement"; - --- DropTable -DROP TABLE "Analytics"; - --- DropTable -DROP TABLE "Chat"; - --- DropTable -DROP TABLE "ChatMember"; - --- DropTable -DROP TABLE "Hashtag"; - --- DropTable -DROP TABLE "Mention"; - --- DropTable -DROP TABLE "ModerationLog"; - --- DropTable -DROP TABLE "NotificationPreferences"; - --- DropTable -DROP TABLE "PostHashtag"; - --- DropTable -DROP TABLE "PostReport"; - --- DropTable -DROP TABLE "PostShare"; - --- DropTable -DROP TABLE "Project"; - --- DropTable -DROP TABLE "ReelComment"; - --- DropTable -DROP TABLE "ReelLike"; - --- DropTable -DROP TABLE "ReelView"; - --- DropTable -DROP TABLE "RepositoryBookmark"; - --- DropTable -DROP TABLE "RepositoryFollow"; - --- DropTable -DROP TABLE "RepositoryView"; - --- DropTable -DROP TABLE "SavedCollection"; - --- DropTable -DROP TABLE "SavedCollectionItem"; - --- DropTable -DROP TABLE "SavedPost"; - --- DropTable -DROP TABLE "ScheduledPost"; - --- DropTable -DROP TABLE "StoryReaction"; - --- DropTable -DROP TABLE "StoryReply"; - --- DropTable -DROP TABLE "StoryView"; - --- DropTable -DROP TABLE "Subscription"; - --- DropTable -DROP TABLE "TrendingRepository"; - --- DropTable -DROP TABLE "UserBlock"; - --- DropTable -DROP TABLE "UserLanguagePreference"; - --- DropTable -DROP TABLE "UserTopicInterest"; - --- DropEnum -DROP TYPE "ChatRole"; - --- CreateTable -CREATE TABLE "Account" ( - "id" TEXT NOT NULL, - "type" "AccountType" NOT NULL, - "username" TEXT NOT NULL, - "displayName" TEXT, - "avatar" TEXT, - "bio" TEXT, - "verified" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "userId" TEXT, - "repositoryId" TEXT, - "organizationId" TEXT, - - CONSTRAINT "Account_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepositoryManager" ( - "id" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "role" "ManagerRole" NOT NULL DEFAULT 'EDITOR', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepositoryManager_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Organization" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "slug" TEXT NOT NULL, - "website" TEXT, - "location" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Organization_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "OrganizationMember" ( - "id" TEXT NOT NULL, - "organizationId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "role" "OrgRole" NOT NULL DEFAULT 'MEMBER', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "OrganizationMember_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE UNIQUE INDEX "Account_username_key" ON "Account"("username"); - --- CreateIndex -CREATE UNIQUE INDEX "Account_userId_key" ON "Account"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Account_repositoryId_key" ON "Account"("repositoryId"); - --- CreateIndex -CREATE UNIQUE INDEX "Account_organizationId_key" ON "Account"("organizationId"); - --- CreateIndex -CREATE INDEX "Account_type_idx" ON "Account"("type"); - --- CreateIndex -CREATE INDEX "Account_username_idx" ON "Account"("username"); - --- CreateIndex -CREATE INDEX "RepositoryManager_userId_idx" ON "RepositoryManager"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "RepositoryManager_repositoryId_userId_key" ON "RepositoryManager"("repositoryId", "userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Organization_slug_key" ON "Organization"("slug"); - --- CreateIndex -CREATE INDEX "Organization_slug_idx" ON "Organization"("slug"); - --- CreateIndex -CREATE INDEX "OrganizationMember_userId_idx" ON "OrganizationMember"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "OrganizationMember_organizationId_userId_key" ON "OrganizationMember"("organizationId", "userId"); - --- CreateIndex -CREATE INDEX "Comment_accountId_idx" ON "Comment"("accountId"); - --- CreateIndex -CREATE INDEX "Like_accountId_idx" ON "Like"("accountId"); - --- CreateIndex -CREATE UNIQUE INDEX "Like_postId_accountId_key" ON "Like"("postId", "accountId"); - --- CreateIndex -CREATE INDEX "Notification_accountId_idx" ON "Notification"("accountId"); - --- CreateIndex -CREATE INDEX "Post_accountId_idx" ON "Post"("accountId"); - --- CreateIndex -CREATE INDEX "Reel_accountId_idx" ON "Reel"("accountId"); - --- CreateIndex -CREATE UNIQUE INDEX "Repository_fullName_key" ON "Repository"("fullName"); - --- CreateIndex -CREATE INDEX "Repository_claimedBy_idx" ON "Repository"("claimedBy"); - --- CreateIndex -CREATE INDEX "Story_accountId_idx" ON "Story"("accountId"); - --- AddForeignKey -ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Account" ADD CONSTRAINT "Account_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Account" ADD CONSTRAINT "Account_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryManager" ADD CONSTRAINT "RepositoryManager_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepositoryManager" ADD CONSTRAINT "RepositoryManager_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "OrganizationMember" ADD CONSTRAINT "OrganizationMember_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "OrganizationMember" ADD CONSTRAINT "OrganizationMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Like" ADD CONSTRAINT "Like_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Story" ADD CONSTRAINT "Story_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Reel" ADD CONSTRAINT "Reel_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followerId_fkey" FOREIGN KEY ("followerId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followingId_fkey" FOREIGN KEY ("followingId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20251208142049_add_missing_models/migration.sql b/gitgram/backend/prisma/migrations/20251208142049_add_missing_models/migration.sql deleted file mode 100644 index 0c495700..00000000 --- a/gitgram/backend/prisma/migrations/20251208142049_add_missing_models/migration.sql +++ /dev/null @@ -1,371 +0,0 @@ --- CreateEnum -CREATE TYPE "AdStatus" AS ENUM ('DRAFT', 'PENDING', 'ACTIVE', 'PAUSED', 'COMPLETED', 'REJECTED'); - --- CreateEnum -CREATE TYPE "ModerationAction" AS ENUM ('APPROVE', 'REJECT', 'FLAG', 'REVIEW'); - --- CreateEnum -CREATE TYPE "SubscriptionTier" AS ENUM ('FREE', 'PREMIUM', 'CREATOR'); - --- CreateEnum -CREATE TYPE "SubscriptionStatus" AS ENUM ('ACTIVE', 'CANCELLED', 'EXPIRED', 'PAST_DUE'); - --- CreateTable -CREATE TABLE "Analytics" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "date" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "views" INTEGER NOT NULL DEFAULT 0, - "likes" INTEGER NOT NULL DEFAULT 0, - "comments" INTEGER NOT NULL DEFAULT 0, - "shares" INTEGER NOT NULL DEFAULT 0, - "followers" INTEGER NOT NULL DEFAULT 0, - - CONSTRAINT "Analytics_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Advertisement" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "title" TEXT NOT NULL, - "content" TEXT NOT NULL, - "mediaUrl" TEXT, - "targetUrl" TEXT NOT NULL, - "budget" DOUBLE PRECISION NOT NULL, - "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, - "impressions" INTEGER NOT NULL DEFAULT 0, - "clicks" INTEGER NOT NULL DEFAULT 0, - "status" "AdStatus" NOT NULL DEFAULT 'DRAFT', - "startDate" TIMESTAMP(3), - "endDate" TIMESTAMP(3), - "targeting" JSONB, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Advertisement_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedCollection" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "isPrivate" BOOLEAN NOT NULL DEFAULT true, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "SavedCollection_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedPost" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "collectionId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SavedPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Chat" ( - "id" TEXT NOT NULL, - "name" TEXT, - "isGroup" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Chat_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ChatMember" ( - "id" TEXT NOT NULL, - "chatId" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "role" TEXT NOT NULL DEFAULT 'member', - "joinedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ChatMember_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ChatMessage" ( - "id" TEXT NOT NULL, - "chatId" TEXT NOT NULL, - "senderId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "mediaUrl" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ChatMessage_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ModerationLog" ( - "id" TEXT NOT NULL, - "accountId" TEXT, - "postId" TEXT, - "content" TEXT, - "flags" TEXT, - "scores" TEXT, - "action" "ModerationAction" NOT NULL, - "category" TEXT, - "reason" TEXT, - "reviewedBy" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ModerationLog_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Report" ( - "id" TEXT NOT NULL, - "reporterId" TEXT NOT NULL, - "targetType" TEXT NOT NULL, - "targetId" TEXT NOT NULL, - "reason" TEXT NOT NULL, - "details" TEXT, - "status" TEXT NOT NULL DEFAULT 'pending', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Report_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Hashtag" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "count" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Hashtag_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PostHashtag" ( - "id" TEXT NOT NULL, - "postId" TEXT NOT NULL, - "hashtagId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "PostHashtag_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Subscription" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "tier" "SubscriptionTier" NOT NULL DEFAULT 'FREE', - "status" "SubscriptionStatus" NOT NULL DEFAULT 'ACTIVE', - "stripeCustomerId" TEXT, - "stripeSubId" TEXT, - "currentPeriodEnd" TIMESTAMP(3), - "cancelAtPeriodEnd" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Subscription_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ScheduledPost" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "mediaUrls" TEXT[], - "scheduledAt" TIMESTAMP(3) NOT NULL, - "published" BOOLEAN NOT NULL DEFAULT false, - "publishedAt" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ScheduledPost_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "TwoFactorAuth" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "secret" TEXT NOT NULL, - "enabled" BOOLEAN NOT NULL DEFAULT false, - "backupCodes" TEXT[], - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "TwoFactorAuth_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PushToken" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "token" TEXT NOT NULL, - "platform" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "PushToken_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "NotificationPreference" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "likes" BOOLEAN NOT NULL DEFAULT true, - "comments" BOOLEAN NOT NULL DEFAULT true, - "follows" BOOLEAN NOT NULL DEFAULT true, - "mentions" BOOLEAN NOT NULL DEFAULT true, - "messages" BOOLEAN NOT NULL DEFAULT true, - "repoUpdates" BOOLEAN NOT NULL DEFAULT true, - "emailDigest" BOOLEAN NOT NULL DEFAULT false, - "pushEnabled" BOOLEAN NOT NULL DEFAULT true, - - CONSTRAINT "NotificationPreference_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PrivacySettings" ( - "id" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "isPrivate" BOOLEAN NOT NULL DEFAULT false, - "showActivity" BOOLEAN NOT NULL DEFAULT true, - "allowMessages" TEXT NOT NULL DEFAULT 'everyone', - "allowMentions" TEXT NOT NULL DEFAULT 'everyone', - "allowTagging" TEXT NOT NULL DEFAULT 'everyone', - - CONSTRAINT "PrivacySettings_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "BlockedAccount" ( - "id" TEXT NOT NULL, - "blockerId" TEXT NOT NULL, - "blockedId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "BlockedAccount_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "Analytics_accountId_idx" ON "Analytics"("accountId"); - --- CreateIndex -CREATE INDEX "Analytics_date_idx" ON "Analytics"("date"); - --- CreateIndex -CREATE UNIQUE INDEX "Analytics_accountId_date_key" ON "Analytics"("accountId", "date"); - --- CreateIndex -CREATE INDEX "Advertisement_accountId_idx" ON "Advertisement"("accountId"); - --- CreateIndex -CREATE INDEX "Advertisement_status_idx" ON "Advertisement"("status"); - --- CreateIndex -CREATE INDEX "SavedCollection_accountId_idx" ON "SavedCollection"("accountId"); - --- CreateIndex -CREATE INDEX "SavedPost_accountId_idx" ON "SavedPost"("accountId"); - --- CreateIndex -CREATE INDEX "SavedPost_collectionId_idx" ON "SavedPost"("collectionId"); - --- CreateIndex -CREATE UNIQUE INDEX "SavedPost_accountId_postId_key" ON "SavedPost"("accountId", "postId"); - --- CreateIndex -CREATE INDEX "Chat_updatedAt_idx" ON "Chat"("updatedAt"); - --- CreateIndex -CREATE INDEX "ChatMember_accountId_idx" ON "ChatMember"("accountId"); - --- CreateIndex -CREATE UNIQUE INDEX "ChatMember_chatId_accountId_key" ON "ChatMember"("chatId", "accountId"); - --- CreateIndex -CREATE INDEX "ChatMessage_chatId_idx" ON "ChatMessage"("chatId"); - --- CreateIndex -CREATE INDEX "ChatMessage_createdAt_idx" ON "ChatMessage"("createdAt"); - --- CreateIndex -CREATE INDEX "ModerationLog_accountId_idx" ON "ModerationLog"("accountId"); - --- CreateIndex -CREATE INDEX "ModerationLog_action_idx" ON "ModerationLog"("action"); - --- CreateIndex -CREATE INDEX "ModerationLog_createdAt_idx" ON "ModerationLog"("createdAt"); - --- CreateIndex -CREATE INDEX "Report_reporterId_idx" ON "Report"("reporterId"); - --- CreateIndex -CREATE INDEX "Report_targetType_targetId_idx" ON "Report"("targetType", "targetId"); - --- CreateIndex -CREATE INDEX "Report_status_idx" ON "Report"("status"); - --- CreateIndex -CREATE UNIQUE INDEX "Hashtag_name_key" ON "Hashtag"("name"); - --- CreateIndex -CREATE INDEX "Hashtag_count_idx" ON "Hashtag"("count"); - --- CreateIndex -CREATE INDEX "PostHashtag_hashtagId_idx" ON "PostHashtag"("hashtagId"); - --- CreateIndex -CREATE UNIQUE INDEX "PostHashtag_postId_hashtagId_key" ON "PostHashtag"("postId", "hashtagId"); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_accountId_key" ON "Subscription"("accountId"); - --- CreateIndex -CREATE INDEX "Subscription_status_idx" ON "Subscription"("status"); - --- CreateIndex -CREATE INDEX "ScheduledPost_accountId_idx" ON "ScheduledPost"("accountId"); - --- CreateIndex -CREATE INDEX "ScheduledPost_scheduledAt_idx" ON "ScheduledPost"("scheduledAt"); - --- CreateIndex -CREATE INDEX "ScheduledPost_published_idx" ON "ScheduledPost"("published"); - --- CreateIndex -CREATE UNIQUE INDEX "TwoFactorAuth_userId_key" ON "TwoFactorAuth"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "PushToken_token_key" ON "PushToken"("token"); - --- CreateIndex -CREATE INDEX "PushToken_accountId_idx" ON "PushToken"("accountId"); - --- CreateIndex -CREATE UNIQUE INDEX "NotificationPreference_accountId_key" ON "NotificationPreference"("accountId"); - --- CreateIndex -CREATE UNIQUE INDEX "PrivacySettings_accountId_key" ON "PrivacySettings"("accountId"); - --- CreateIndex -CREATE INDEX "BlockedAccount_blockerId_idx" ON "BlockedAccount"("blockerId"); - --- CreateIndex -CREATE INDEX "BlockedAccount_blockedId_idx" ON "BlockedAccount"("blockedId"); - --- CreateIndex -CREATE UNIQUE INDEX "BlockedAccount_blockerId_blockedId_key" ON "BlockedAccount"("blockerId", "blockedId"); - --- AddForeignKey -ALTER TABLE "SavedPost" ADD CONSTRAINT "SavedPost_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "SavedCollection"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ChatMember" ADD CONSTRAINT "ChatMember_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ChatMessage" ADD CONSTRAINT "ChatMessage_chatId_fkey" FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_hashtagId_fkey" FOREIGN KEY ("hashtagId") REFERENCES "Hashtag"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20260109185732_add_stories_reels_unified/migration.sql b/gitgram/backend/prisma/migrations/20260109185732_add_stories_reels_unified/migration.sql deleted file mode 100644 index 343751d6..00000000 --- a/gitgram/backend/prisma/migrations/20260109185732_add_stories_reels_unified/migration.sql +++ /dev/null @@ -1,753 +0,0 @@ -/* - Warnings: - - - The values [MESSAGE,REPO_UPDATE] on the enum `NotificationType` will be removed. If these variants are still used in the database, this will fail. - - The values [POST,STORY] on the enum `PostType` will be removed. If these variants are still used in the database, this will fail. - - The values [PREMIUM,CREATOR] on the enum `SubscriptionTier` will be removed. If these variants are still used in the database, this will fail. - - You are about to drop the column `accountId` on the `Comment` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Like` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Notification` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Post` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Reel` table. All the data in the column will be lost. - - You are about to drop the column `claimedAt` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `claimedBy` on the `Repository` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Story` table. All the data in the column will be lost. - - You are about to drop the column `accountId` on the `Subscription` table. All the data in the column will be lost. - - You are about to drop the column `cancelAtPeriodEnd` on the `Subscription` table. All the data in the column will be lost. - - You are about to drop the column `currentPeriodEnd` on the `Subscription` table. All the data in the column will be lost. - - You are about to drop the column `status` on the `Subscription` table. All the data in the column will be lost. - - You are about to drop the column `updatedAt` on the `Subscription` table. All the data in the column will be lost. - - You are about to drop the column `updatedAt` on the `TwoFactorAuth` table. All the data in the column will be lost. - - You are about to drop the `Account` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Advertisement` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Analytics` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `BlockedAccount` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Chat` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ChatMember` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ChatMessage` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ModerationLog` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `NotificationPreference` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Organization` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `OrganizationMember` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PrivacySettings` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `PushToken` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Report` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `RepositoryManager` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedCollection` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SavedPost` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `ScheduledPost` table. If the table is not empty, all the data it contains will be lost. - - A unique constraint covering the columns `[postId,userId]` on the table `Like` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[userId]` on the table `Subscription` will be added. If there are existing duplicate values, this will fail. - - A unique constraint covering the columns `[username]` on the table `User` will be added. If there are existing duplicate values, this will fail. - - Added the required column `userId` to the `Comment` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Like` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Notification` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Post` table without a default value. This is not possible if the table is not empty. - - Added the required column `updatedAt` to the `Reel` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Reel` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Story` table without a default value. This is not possible if the table is not empty. - - Added the required column `userId` to the `Subscription` table without a default value. This is not possible if the table is not empty. - - Added the required column `username` to the `User` table without a default value. This is not possible if the table is not empty. - -*/ --- CreateEnum -CREATE TYPE "ReactionType" AS ENUM ('STAR', 'FIRE', 'ROCKET', 'EYES', 'HEART', 'CLAP', 'MINDBLOWN'); - --- CreateEnum -CREATE TYPE "ContentType" AS ENUM ('POST', 'REPOSITORY', 'REEL', 'STORY', 'SNIPPET'); - --- AlterEnum -BEGIN; -CREATE TYPE "NotificationType_new" AS ENUM ('LIKE', 'COMMENT', 'FOLLOW', 'MENTION', 'REPO_COMMENT', 'REPO_REACTION', 'NEW_POST', 'STORY_REPLY', 'STORY_REACTION', 'REEL_LIKE', 'REEL_COMMENT'); -ALTER TABLE "Notification" ALTER COLUMN "type" TYPE "NotificationType_new" USING ("type"::text::"NotificationType_new"); -ALTER TYPE "NotificationType" RENAME TO "NotificationType_old"; -ALTER TYPE "NotificationType_new" RENAME TO "NotificationType"; -DROP TYPE "NotificationType_old"; -COMMIT; - --- AlterEnum -BEGIN; -CREATE TYPE "PostType_new" AS ENUM ('IMAGE', 'VIDEO', 'REEL', 'CAROUSEL'); -ALTER TABLE "Post" ALTER COLUMN "type" DROP DEFAULT; -ALTER TABLE "Post" ALTER COLUMN "type" TYPE "PostType_new" USING ("type"::text::"PostType_new"); -ALTER TYPE "PostType" RENAME TO "PostType_old"; -ALTER TYPE "PostType_new" RENAME TO "PostType"; -DROP TYPE "PostType_old"; -ALTER TABLE "Post" ALTER COLUMN "type" SET DEFAULT 'IMAGE'; -COMMIT; - --- AlterEnum -BEGIN; -CREATE TYPE "SubscriptionTier_new" AS ENUM ('FREE', 'PRO', 'TEAM'); -ALTER TABLE "Subscription" ALTER COLUMN "tier" DROP DEFAULT; -ALTER TABLE "Subscription" ALTER COLUMN "tier" TYPE "SubscriptionTier_new" USING ("tier"::text::"SubscriptionTier_new"); -ALTER TYPE "SubscriptionTier" RENAME TO "SubscriptionTier_old"; -ALTER TYPE "SubscriptionTier_new" RENAME TO "SubscriptionTier"; -DROP TYPE "SubscriptionTier_old"; -ALTER TABLE "Subscription" ALTER COLUMN "tier" SET DEFAULT 'FREE'; -COMMIT; - --- DropForeignKey -ALTER TABLE "Account" DROP CONSTRAINT "Account_organizationId_fkey"; - --- DropForeignKey -ALTER TABLE "Account" DROP CONSTRAINT "Account_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "Account" DROP CONSTRAINT "Account_userId_fkey"; - --- DropForeignKey -ALTER TABLE "ChatMember" DROP CONSTRAINT "ChatMember_chatId_fkey"; - --- DropForeignKey -ALTER TABLE "ChatMessage" DROP CONSTRAINT "ChatMessage_chatId_fkey"; - --- DropForeignKey -ALTER TABLE "Comment" DROP CONSTRAINT "Comment_accountId_fkey"; - --- DropForeignKey -ALTER TABLE "Follow" DROP CONSTRAINT "Follow_followerId_fkey"; - --- DropForeignKey -ALTER TABLE "Follow" DROP CONSTRAINT "Follow_followingId_fkey"; - --- DropForeignKey -ALTER TABLE "Like" DROP CONSTRAINT "Like_accountId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_receiverId_fkey"; - --- DropForeignKey -ALTER TABLE "Message" DROP CONSTRAINT "Message_senderId_fkey"; - --- DropForeignKey -ALTER TABLE "OrganizationMember" DROP CONSTRAINT "OrganizationMember_organizationId_fkey"; - --- DropForeignKey -ALTER TABLE "OrganizationMember" DROP CONSTRAINT "OrganizationMember_userId_fkey"; - --- DropForeignKey -ALTER TABLE "Post" DROP CONSTRAINT "Post_accountId_fkey"; - --- DropForeignKey -ALTER TABLE "Reel" DROP CONSTRAINT "Reel_accountId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryManager" DROP CONSTRAINT "RepositoryManager_repositoryId_fkey"; - --- DropForeignKey -ALTER TABLE "RepositoryManager" DROP CONSTRAINT "RepositoryManager_userId_fkey"; - --- DropForeignKey -ALTER TABLE "SavedPost" DROP CONSTRAINT "SavedPost_collectionId_fkey"; - --- DropForeignKey -ALTER TABLE "Story" DROP CONSTRAINT "Story_accountId_fkey"; - --- DropIndex -DROP INDEX "Comment_accountId_idx"; - --- DropIndex -DROP INDEX "Like_accountId_idx"; - --- DropIndex -DROP INDEX "Like_postId_accountId_key"; - --- DropIndex -DROP INDEX "Message_createdAt_idx"; - --- DropIndex -DROP INDEX "Notification_accountId_idx"; - --- DropIndex -DROP INDEX "Notification_createdAt_idx"; - --- DropIndex -DROP INDEX "Post_accountId_idx"; - --- DropIndex -DROP INDEX "PostHashtag_hashtagId_idx"; - --- DropIndex -DROP INDEX "Reel_accountId_idx"; - --- DropIndex -DROP INDEX "Repository_claimedBy_idx"; - --- DropIndex -DROP INDEX "Repository_owner_idx"; - --- DropIndex -DROP INDEX "Story_accountId_idx"; - --- DropIndex -DROP INDEX "Subscription_accountId_key"; - --- DropIndex -DROP INDEX "Subscription_status_idx"; - --- DropIndex -DROP INDEX "User_email_idx"; - --- AlterTable -ALTER TABLE "Comment" DROP COLUMN "accountId", -ADD COLUMN "likesCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "parentId" TEXT, -ADD COLUMN "userId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Like" DROP COLUMN "accountId", -ADD COLUMN "userId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Notification" DROP COLUMN "accountId", -ADD COLUMN "repoId" TEXT, -ADD COLUMN "userId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "Post" DROP COLUMN "accountId", -ADD COLUMN "duration" INTEGER, -ADD COLUMN "repositoryId" TEXT, -ADD COLUMN "thumbnailUrl" TEXT, -ADD COLUMN "userId" TEXT NOT NULL, -ADD COLUMN "viewsCount" INTEGER NOT NULL DEFAULT 0, -ALTER COLUMN "type" SET DEFAULT 'IMAGE'; - --- AlterTable -ALTER TABLE "Reel" DROP COLUMN "accountId", -ADD COLUMN "commentsCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "description" TEXT, -ADD COLUMN "sharesCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL, -ADD COLUMN "userId" TEXT NOT NULL, -ALTER COLUMN "title" DROP NOT NULL, -ALTER COLUMN "thumbnailUrl" DROP NOT NULL; - --- AlterTable -ALTER TABLE "Repository" DROP COLUMN "claimedAt", -DROP COLUMN "claimedBy", -ADD COLUMN "commentsCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "followersCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "homepage" TEXT, -ADD COLUMN "postsCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "reactionsCount" INTEGER NOT NULL DEFAULT 0, -ADD COLUMN "savesCount" INTEGER NOT NULL DEFAULT 0; - --- AlterTable -ALTER TABLE "Story" DROP COLUMN "accountId", -ADD COLUMN "duration" INTEGER NOT NULL DEFAULT 5, -ADD COLUMN "userId" TEXT NOT NULL, -ALTER COLUMN "mediaType" SET DEFAULT 'image'; - --- AlterTable -ALTER TABLE "Subscription" DROP COLUMN "accountId", -DROP COLUMN "cancelAtPeriodEnd", -DROP COLUMN "currentPeriodEnd", -DROP COLUMN "status", -DROP COLUMN "updatedAt", -ADD COLUMN "expiresAt" TIMESTAMP(3), -ADD COLUMN "userId" TEXT NOT NULL; - --- AlterTable -ALTER TABLE "TwoFactorAuth" DROP COLUMN "updatedAt"; - --- AlterTable -ALTER TABLE "User" ADD COLUMN "avatar" TEXT, -ADD COLUMN "bio" TEXT, -ADD COLUMN "displayName" TEXT, -ADD COLUMN "username" TEXT NOT NULL, -ADD COLUMN "verified" BOOLEAN NOT NULL DEFAULT false; - --- DropTable -DROP TABLE "Account"; - --- DropTable -DROP TABLE "Advertisement"; - --- DropTable -DROP TABLE "Analytics"; - --- DropTable -DROP TABLE "BlockedAccount"; - --- DropTable -DROP TABLE "Chat"; - --- DropTable -DROP TABLE "ChatMember"; - --- DropTable -DROP TABLE "ChatMessage"; - --- DropTable -DROP TABLE "ModerationLog"; - --- DropTable -DROP TABLE "NotificationPreference"; - --- DropTable -DROP TABLE "Organization"; - --- DropTable -DROP TABLE "OrganizationMember"; - --- DropTable -DROP TABLE "PrivacySettings"; - --- DropTable -DROP TABLE "PushToken"; - --- DropTable -DROP TABLE "Report"; - --- DropTable -DROP TABLE "RepositoryManager"; - --- DropTable -DROP TABLE "SavedCollection"; - --- DropTable -DROP TABLE "SavedPost"; - --- DropTable -DROP TABLE "ScheduledPost"; - --- DropEnum -DROP TYPE "AccountType"; - --- DropEnum -DROP TYPE "AdStatus"; - --- DropEnum -DROP TYPE "ManagerRole"; - --- DropEnum -DROP TYPE "ModerationAction"; - --- DropEnum -DROP TYPE "OrgRole"; - --- DropEnum -DROP TYPE "SubscriptionStatus"; - --- CreateTable -CREATE TABLE "RepoComment" ( - "id" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "filePath" TEXT, - "lineNumber" INTEGER, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "parentId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "RepoComment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepoReaction" ( - "id" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" "ReactionType" NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepoReaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "CodeSnippet" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT, - "title" TEXT NOT NULL, - "description" TEXT, - "code" TEXT NOT NULL, - "language" TEXT NOT NULL, - "filePath" TEXT, - "startLine" INTEGER, - "endLine" INTEGER, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "viewsCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "CodeSnippet_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "RepoFollow" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "RepoFollow_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "SavedRepo" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "collectionId" TEXT, - "note" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "SavedRepo_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Collection" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "isPrivate" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Collection_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "TrendingRepo" ( - "id" TEXT NOT NULL, - "repositoryId" TEXT NOT NULL, - "score" DOUBLE PRECISION NOT NULL DEFAULT 0, - "period" TEXT NOT NULL, - "rank" INTEGER NOT NULL, - "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "TrendingRepo_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Interaction" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "contentType" "ContentType" NOT NULL, - "contentId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "Interaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "UnifiedComment" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "contentType" "ContentType" NOT NULL, - "contentId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "parentId" TEXT, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "UnifiedComment_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryReaction" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryReaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryReply" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryReply_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "StoryView" ( - "id" TEXT NOT NULL, - "storyId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "viewedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "StoryView_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ReelLike" ( - "id" TEXT NOT NULL, - "reelId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ReelLike_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "ReelComment" ( - "id" TEXT NOT NULL, - "reelId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "content" TEXT NOT NULL, - "parentId" TEXT, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "ReelComment_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "RepoComment_repositoryId_idx" ON "RepoComment"("repositoryId"); - --- CreateIndex -CREATE INDEX "RepoComment_userId_idx" ON "RepoComment"("userId"); - --- CreateIndex -CREATE INDEX "RepoReaction_repositoryId_idx" ON "RepoReaction"("repositoryId"); - --- CreateIndex -CREATE UNIQUE INDEX "RepoReaction_repositoryId_userId_type_key" ON "RepoReaction"("repositoryId", "userId", "type"); - --- CreateIndex -CREATE INDEX "CodeSnippet_userId_idx" ON "CodeSnippet"("userId"); - --- CreateIndex -CREATE INDEX "CodeSnippet_language_idx" ON "CodeSnippet"("language"); - --- CreateIndex -CREATE INDEX "RepoFollow_repositoryId_idx" ON "RepoFollow"("repositoryId"); - --- CreateIndex -CREATE INDEX "RepoFollow_userId_idx" ON "RepoFollow"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "RepoFollow_userId_repositoryId_key" ON "RepoFollow"("userId", "repositoryId"); - --- CreateIndex -CREATE INDEX "SavedRepo_userId_idx" ON "SavedRepo"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "SavedRepo_userId_repositoryId_key" ON "SavedRepo"("userId", "repositoryId"); - --- CreateIndex -CREATE INDEX "Collection_userId_idx" ON "Collection"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "TrendingRepo_repositoryId_key" ON "TrendingRepo"("repositoryId"); - --- CreateIndex -CREATE INDEX "TrendingRepo_period_rank_idx" ON "TrendingRepo"("period", "rank"); - --- CreateIndex -CREATE INDEX "Interaction_contentType_contentId_idx" ON "Interaction"("contentType", "contentId"); - --- CreateIndex -CREATE INDEX "Interaction_userId_idx" ON "Interaction"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Interaction_userId_contentType_contentId_type_key" ON "Interaction"("userId", "contentType", "contentId", "type"); - --- CreateIndex -CREATE INDEX "UnifiedComment_contentType_contentId_idx" ON "UnifiedComment"("contentType", "contentId"); - --- CreateIndex -CREATE INDEX "UnifiedComment_userId_idx" ON "UnifiedComment"("userId"); - --- CreateIndex -CREATE INDEX "UnifiedComment_parentId_idx" ON "UnifiedComment"("parentId"); - --- CreateIndex -CREATE INDEX "StoryReaction_storyId_idx" ON "StoryReaction"("storyId"); - --- CreateIndex -CREATE UNIQUE INDEX "StoryReaction_storyId_userId_type_key" ON "StoryReaction"("storyId", "userId", "type"); - --- CreateIndex -CREATE INDEX "StoryReply_storyId_idx" ON "StoryReply"("storyId"); - --- CreateIndex -CREATE UNIQUE INDEX "StoryView_storyId_userId_key" ON "StoryView"("storyId", "userId"); - --- CreateIndex -CREATE UNIQUE INDEX "ReelLike_reelId_userId_key" ON "ReelLike"("reelId", "userId"); - --- CreateIndex -CREATE INDEX "ReelComment_reelId_idx" ON "ReelComment"("reelId"); - --- CreateIndex -CREATE INDEX "ReelComment_parentId_idx" ON "ReelComment"("parentId"); - --- CreateIndex -CREATE INDEX "Comment_userId_idx" ON "Comment"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Like_postId_userId_key" ON "Like"("postId", "userId"); - --- CreateIndex -CREATE INDEX "Notification_userId_idx" ON "Notification"("userId"); - --- CreateIndex -CREATE INDEX "Post_userId_idx" ON "Post"("userId"); - --- CreateIndex -CREATE INDEX "Post_repositoryId_idx" ON "Post"("repositoryId"); - --- CreateIndex -CREATE INDEX "Post_type_idx" ON "Post"("type"); - --- CreateIndex -CREATE INDEX "Reel_userId_idx" ON "Reel"("userId"); - --- CreateIndex -CREATE INDEX "Repository_stars_idx" ON "Repository"("stars"); - --- CreateIndex -CREATE INDEX "Repository_language_idx" ON "Repository"("language"); - --- CreateIndex -CREATE INDEX "Story_userId_idx" ON "Story"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Subscription_userId_key" ON "Subscription"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE INDEX "User_username_idx" ON "User"("username"); - --- AddForeignKey -ALTER TABLE "RepoComment" ADD CONSTRAINT "RepoComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "RepoComment"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoComment" ADD CONSTRAINT "RepoComment_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoComment" ADD CONSTRAINT "RepoComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoReaction" ADD CONSTRAINT "RepoReaction_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoReaction" ADD CONSTRAINT "RepoReaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Post" ADD CONSTRAINT "Post_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Comment"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Like" ADD CONSTRAINT "Like_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CodeSnippet" ADD CONSTRAINT "CodeSnippet_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CodeSnippet" ADD CONSTRAINT "CodeSnippet_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followerId_fkey" FOREIGN KEY ("followerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Follow" ADD CONSTRAINT "Follow_followingId_fkey" FOREIGN KEY ("followingId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoFollow" ADD CONSTRAINT "RepoFollow_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "RepoFollow" ADD CONSTRAINT "RepoFollow_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedRepo" ADD CONSTRAINT "SavedRepo_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedRepo" ADD CONSTRAINT "SavedRepo_repositoryId_fkey" FOREIGN KEY ("repositoryId") REFERENCES "Repository"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "SavedRepo" ADD CONSTRAINT "SavedRepo_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Collection" ADD CONSTRAINT "Collection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PostHashtag" ADD CONSTRAINT "PostHashtag_postId_fkey" FOREIGN KEY ("postId") REFERENCES "Post"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Message" ADD CONSTRAINT "Message_receiverId_fkey" FOREIGN KEY ("receiverId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Notification" ADD CONSTRAINT "Notification_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "TwoFactorAuth" ADD CONSTRAINT "TwoFactorAuth_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Subscription" ADD CONSTRAINT "Subscription_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Interaction" ADD CONSTRAINT "Interaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "UnifiedComment" ADD CONSTRAINT "UnifiedComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "UnifiedComment" ADD CONSTRAINT "UnifiedComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "UnifiedComment"("id") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Story" ADD CONSTRAINT "Story_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReaction" ADD CONSTRAINT "StoryReaction_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReaction" ADD CONSTRAINT "StoryReaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReply" ADD CONSTRAINT "StoryReply_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryReply" ADD CONSTRAINT "StoryReply_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryView" ADD CONSTRAINT "StoryView_storyId_fkey" FOREIGN KEY ("storyId") REFERENCES "Story"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "StoryView" ADD CONSTRAINT "StoryView_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Reel" ADD CONSTRAINT "Reel_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelLike" ADD CONSTRAINT "ReelLike_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelLike" ADD CONSTRAINT "ReelLike_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_reelId_fkey" FOREIGN KEY ("reelId") REFERENCES "Reel"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "ReelComment" ADD CONSTRAINT "ReelComment_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "ReelComment"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/gitgram/backend/prisma/migrations/20260408000000_add_aitm_checkpoint_linkage/migration.sql b/gitgram/backend/prisma/migrations/20260408000000_add_aitm_checkpoint_linkage/migration.sql deleted file mode 100644 index 322aa5e8..00000000 --- a/gitgram/backend/prisma/migrations/20260408000000_add_aitm_checkpoint_linkage/migration.sql +++ /dev/null @@ -1,10 +0,0 @@ --- AlterTable -ALTER TABLE "Post" ADD COLUMN "aitm_checkpoint_id" TEXT, -ADD COLUMN "aitm_project_id" TEXT, -ADD COLUMN "aitm_checkpoint_ref" JSONB; - --- CreateIndex -CREATE INDEX "Post_aitmCheckpointId_idx" ON "Post"("aitm_checkpoint_id"); - --- CreateIndex -CREATE INDEX "Post_aitmProjectId_idx" ON "Post"("aitm_project_id"); diff --git a/gitgram/backend/prisma/migrations/20260514174000_repair_scheduled_posts_schema/migration.sql b/gitgram/backend/prisma/migrations/20260514174000_repair_scheduled_posts_schema/migration.sql deleted file mode 100644 index 2ed1b2d0..00000000 --- a/gitgram/backend/prisma/migrations/20260514174000_repair_scheduled_posts_schema/migration.sql +++ /dev/null @@ -1,65 +0,0 @@ --- Repair ScheduledPost drift from earlier table recreations. --- The application schema now uses scheduledFor, optional account/user links, --- timezone support, recurrence metadata, and published-post linkage. - -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'RecurrenceType') THEN - CREATE TYPE "RecurrenceType" AS ENUM ('NONE', 'DAILY', 'WEEKLY', 'MONTHLY'); - END IF; -END $$; - -ALTER TABLE "ScheduledPost" - ADD COLUMN IF NOT EXISTS "accountId" TEXT, - ADD COLUMN IF NOT EXISTS "userId" TEXT, - ADD COLUMN IF NOT EXISTS "scheduledFor" TIMESTAMP(3), - ADD COLUMN IF NOT EXISTS "published" BOOLEAN NOT NULL DEFAULT false, - ADD COLUMN IF NOT EXISTS "publishedAt" TIMESTAMP(3), - ADD COLUMN IF NOT EXISTS "status" TEXT NOT NULL DEFAULT 'pending', - ADD COLUMN IF NOT EXISTS "timezone" TEXT NOT NULL DEFAULT 'UTC', - ADD COLUMN IF NOT EXISTS "recurrenceType" "RecurrenceType" NOT NULL DEFAULT 'NONE', - ADD COLUMN IF NOT EXISTS "recurrenceEndDate" TIMESTAMP(3), - ADD COLUMN IF NOT EXISTS "parentPostId" TEXT, - ADD COLUMN IF NOT EXISTS "publishedPostId" TEXT; - -DO $$ -BEGIN - IF EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_name = 'ScheduledPost' - AND column_name = 'scheduledAt' - ) THEN - EXECUTE 'UPDATE "ScheduledPost" SET "scheduledFor" = COALESCE("scheduledFor", "scheduledAt")'; - END IF; -END $$; - -UPDATE "ScheduledPost" -SET - "scheduledFor" = COALESCE("scheduledFor", CURRENT_TIMESTAMP), - "mediaUrls" = COALESCE("mediaUrls", ARRAY[]::TEXT[]), - "status" = COALESCE("status", 'pending'), - "timezone" = COALESCE("timezone", 'UTC'), - "recurrenceType" = COALESCE("recurrenceType", 'NONE'::"RecurrenceType"), - "published" = COALESCE("published", false); - -ALTER TABLE "ScheduledPost" - ALTER COLUMN "accountId" DROP NOT NULL, - ALTER COLUMN "userId" DROP NOT NULL, - ALTER COLUMN "scheduledFor" SET NOT NULL, - ALTER COLUMN "mediaUrls" SET DEFAULT ARRAY[]::TEXT[], - ALTER COLUMN "mediaUrls" SET NOT NULL, - ALTER COLUMN "published" SET DEFAULT false, - ALTER COLUMN "published" SET NOT NULL, - ALTER COLUMN "status" SET DEFAULT 'pending', - ALTER COLUMN "status" SET NOT NULL, - ALTER COLUMN "timezone" SET DEFAULT 'UTC', - ALTER COLUMN "timezone" SET NOT NULL, - ALTER COLUMN "recurrenceType" SET DEFAULT 'NONE', - ALTER COLUMN "recurrenceType" SET NOT NULL; - -CREATE INDEX IF NOT EXISTS "ScheduledPost_accountId_idx" ON "ScheduledPost"("accountId"); -CREATE INDEX IF NOT EXISTS "ScheduledPost_userId_idx" ON "ScheduledPost"("userId"); -CREATE INDEX IF NOT EXISTS "ScheduledPost_scheduledFor_idx" ON "ScheduledPost"("scheduledFor"); -CREATE INDEX IF NOT EXISTS "ScheduledPost_status_idx" ON "ScheduledPost"("status"); -CREATE INDEX IF NOT EXISTS "ScheduledPost_parentPostId_idx" ON "ScheduledPost"("parentPostId"); diff --git a/gitgram/backend/prisma/migrations/20260628000000_add_store_moments_feedback_location_adcampaigns/migration.sql b/gitgram/backend/prisma/migrations/20260628000000_add_store_moments_feedback_location_adcampaigns/migration.sql deleted file mode 100644 index 3bca98c4..00000000 --- a/gitgram/backend/prisma/migrations/20260628000000_add_store_moments_feedback_location_adcampaigns/migration.sql +++ /dev/null @@ -1,142 +0,0 @@ --- Store: creator marketplace items & purchases -CREATE TABLE "StoreItem" ( - "id" TEXT NOT NULL, - "sellerId" TEXT NOT NULL, - "title" TEXT NOT NULL, - "description" TEXT, - "price" DOUBLE PRECISION NOT NULL DEFAULT 0, - "category" TEXT NOT NULL DEFAULT 'other', - "images" TEXT[] DEFAULT ARRAY[]::TEXT[], - "status" TEXT NOT NULL DEFAULT 'active', - "polarProductId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - CONSTRAINT "StoreItem_pkey" PRIMARY KEY ("id") -); -CREATE INDEX "StoreItem_sellerId_idx" ON "StoreItem"("sellerId"); -CREATE INDEX "StoreItem_status_idx" ON "StoreItem"("status"); -CREATE INDEX "StoreItem_category_idx" ON "StoreItem"("category"); -CREATE INDEX "StoreItem_createdAt_idx" ON "StoreItem"("createdAt"); - -CREATE TABLE "StorePurchase" ( - "id" TEXT NOT NULL, - "itemId" TEXT NOT NULL, - "buyerId" TEXT NOT NULL, - "sellerId" TEXT NOT NULL, - "amount" DOUBLE PRECISION NOT NULL DEFAULT 0, - "status" TEXT NOT NULL DEFAULT 'pending', - "provider" TEXT NOT NULL DEFAULT 'internal', - "checkoutId" TEXT, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "completedAt" TIMESTAMP(3), - CONSTRAINT "StorePurchase_pkey" PRIMARY KEY ("id") -); -CREATE INDEX "StorePurchase_itemId_idx" ON "StorePurchase"("itemId"); -CREATE INDEX "StorePurchase_buyerId_idx" ON "StorePurchase"("buyerId"); -CREATE INDEX "StorePurchase_sellerId_idx" ON "StorePurchase"("sellerId"); -CREATE INDEX "StorePurchase_status_idx" ON "StorePurchase"("status"); -ALTER TABLE "StorePurchase" ADD CONSTRAINT "StorePurchase_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "StoreItem"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- Moments: screenshot + selfie posts -CREATE TABLE "Moment" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "screenshotUrl" TEXT NOT NULL, - "selfieUrl" TEXT NOT NULL, - "caption" TEXT, - "location" TEXT, - "likesCount" INTEGER NOT NULL DEFAULT 0, - "commentsCount" INTEGER NOT NULL DEFAULT 0, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "expiresAt" TIMESTAMP(3), - CONSTRAINT "Moment_pkey" PRIMARY KEY ("id") -); -CREATE INDEX "Moment_userId_idx" ON "Moment"("userId"); -CREATE INDEX "Moment_createdAt_idx" ON "Moment"("createdAt"); - -CREATE TABLE "MomentLike" ( - "id" TEXT NOT NULL, - "momentId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "MomentLike_pkey" PRIMARY KEY ("id") -); -CREATE UNIQUE INDEX "MomentLike_momentId_userId_key" ON "MomentLike"("momentId", "userId"); -CREATE INDEX "MomentLike_momentId_idx" ON "MomentLike"("momentId"); -CREATE INDEX "MomentLike_userId_idx" ON "MomentLike"("userId"); -ALTER TABLE "MomentLike" ADD CONSTRAINT "MomentLike_momentId_fkey" FOREIGN KEY ("momentId") REFERENCES "Moment"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- Feedback: user-submitted bug reports & feature requests -CREATE TABLE "Feedback" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "type" TEXT NOT NULL DEFAULT 'other', - "title" TEXT NOT NULL, - "content" TEXT NOT NULL, - "screenshotUrl" TEXT, - "status" TEXT NOT NULL DEFAULT 'open', - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - CONSTRAINT "Feedback_pkey" PRIMARY KEY ("id") -); -CREATE INDEX "Feedback_userId_idx" ON "Feedback"("userId"); -CREATE INDEX "Feedback_status_idx" ON "Feedback"("status"); -CREATE INDEX "Feedback_type_idx" ON "Feedback"("type"); -CREATE INDEX "Feedback_createdAt_idx" ON "Feedback"("createdAt"); - --- Ad campaigns -CREATE TABLE "AdCampaign" ( - "id" TEXT NOT NULL, - "advertiserId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "description" TEXT, - "type" TEXT NOT NULL DEFAULT 'post', - "budget" DOUBLE PRECISION NOT NULL DEFAULT 0, - "dailyBudget" DOUBLE PRECISION, - "spent" DOUBLE PRECISION NOT NULL DEFAULT 0, - "billingType" TEXT NOT NULL DEFAULT 'cpc', - "status" TEXT NOT NULL DEFAULT 'active', - "targetAudience" TEXT, - "startDate" TIMESTAMP(3), - "endDate" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - CONSTRAINT "AdCampaign_pkey" PRIMARY KEY ("id") -); -CREATE INDEX "AdCampaign_advertiserId_idx" ON "AdCampaign"("advertiserId"); -CREATE INDEX "AdCampaign_status_idx" ON "AdCampaign"("status"); - --- Ad preferences (per-user personalization) -CREATE TABLE "AdPreferences" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "personalizedAds" BOOLEAN NOT NULL DEFAULT true, - "interestCategories" TEXT[] DEFAULT ARRAY[]::TEXT[], - "optOut" BOOLEAN NOT NULL DEFAULT false, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - CONSTRAINT "AdPreferences_pkey" PRIMARY KEY ("id") -); -CREATE UNIQUE INDEX "AdPreferences_userId_key" ON "AdPreferences"("userId"); -CREATE INDEX "AdPreferences_userId_idx" ON "AdPreferences"("userId"); - --- Advertisement: campaign linkage + creative & engagement fields -ALTER TABLE "Advertisement" ADD COLUMN "campaignId" TEXT; -ALTER TABLE "Advertisement" ADD COLUMN "callToAction" TEXT; -ALTER TABLE "Advertisement" ADD COLUMN "placement" TEXT[] DEFAULT ARRAY[]::TEXT[]; -ALTER TABLE "Advertisement" ADD COLUMN "priority" INTEGER NOT NULL DEFAULT 0; -ALTER TABLE "Advertisement" ADD COLUMN "conversions" INTEGER NOT NULL DEFAULT 0; -CREATE INDEX "Advertisement_campaignId_idx" ON "Advertisement"("campaignId"); - --- Geotagging columns for map / nearby discovery -ALTER TABLE "Post" ADD COLUMN "location" TEXT; -ALTER TABLE "Post" ADD COLUMN "latitude" DOUBLE PRECISION; -ALTER TABLE "Post" ADD COLUMN "longitude" DOUBLE PRECISION; - -ALTER TABLE "Project" ADD COLUMN "location" TEXT; -ALTER TABLE "Project" ADD COLUMN "latitude" DOUBLE PRECISION; -ALTER TABLE "Project" ADD COLUMN "longitude" DOUBLE PRECISION; - -ALTER TABLE "User" ADD COLUMN "location" TEXT; -ALTER TABLE "User" ADD COLUMN "latitude" DOUBLE PRECISION; -ALTER TABLE "User" ADD COLUMN "longitude" DOUBLE PRECISION; diff --git a/gitgram/backend/prisma/migrations/20260629000000_marathon_additions/migration.sql b/gitgram/backend/prisma/migrations/20260629000000_marathon_additions/migration.sql deleted file mode 100644 index b93daedd..00000000 --- a/gitgram/backend/prisma/migrations/20260629000000_marathon_additions/migration.sql +++ /dev/null @@ -1,57 +0,0 @@ --- Marathon additions: per-user muted words/tags, message reactions, post content language. --- Incremental migration on top of the prior 16 migrations. - --- AlterTable -ALTER TABLE "Post" ADD COLUMN "contentLanguage" TEXT; - --- CreateTable -CREATE TABLE "MessageReaction" ( - "id" TEXT NOT NULL, - "messageId" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "emoji" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - - CONSTRAINT "MessageReaction_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "MutedWord" ( - "id" TEXT NOT NULL, - "userId" TEXT NOT NULL, - "value" TEXT NOT NULL, - "targets" TEXT[] DEFAULT ARRAY['content']::TEXT[], - "actorTarget" TEXT NOT NULL DEFAULT 'all', - "expiresAt" TIMESTAMP(3), - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "MutedWord_pkey" PRIMARY KEY ("id") -); - --- CreateIndex -CREATE INDEX "Post_contentLanguage_idx" ON "Post"("contentLanguage"); - --- CreateIndex -CREATE INDEX "MessageReaction_messageId_idx" ON "MessageReaction"("messageId"); - --- CreateIndex -CREATE INDEX "MessageReaction_userId_idx" ON "MessageReaction"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "MessageReaction_messageId_userId_emoji_key" ON "MessageReaction"("messageId", "userId", "emoji"); - --- CreateIndex -CREATE INDEX "MutedWord_userId_idx" ON "MutedWord"("userId"); - --- CreateIndex -CREATE INDEX "MutedWord_expiresAt_idx" ON "MutedWord"("expiresAt"); - --- CreateIndex -CREATE UNIQUE INDEX "MutedWord_userId_value_key" ON "MutedWord"("userId", "value"); - --- AddForeignKey -ALTER TABLE "MessageReaction" ADD CONSTRAINT "MessageReaction_messageId_fkey" FOREIGN KEY ("messageId") REFERENCES "Message"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "MessageReaction" ADD CONSTRAINT "MessageReaction_userId_fkey" FOREIGN KEY ("userId") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE;