fix(backend,docker): reconcile migration history (squash) + context7 in compose
Migration history reconciliation: The autonomous-build migration history was corrupted — 20260109185732 dropped 13 tables still in the schema (Account, Advertisement, ScheduledPost, Chat, Organization, Report, …) plus their enums/constraints without recreating them, so a fresh `prisma migrate deploy` failed on the later repair/ALTER migrations (ScheduledPost, Advertisement, AccountType, …). Squashed the 16 broken migrations into a single clean 00000000000000_init generated from the current schema (93 tables, 19 enums, incl. MutedWord/MessageReaction/Post.contentLanguage). Verified: fresh `migrate deploy` applies cleanly on an empty DB; the running DB was re-baselined (resolve --applied init) and the backend boots healthy. context7: Switch the compose service from a broken raw node:20-alpine + read-only-volume + npm-install setup to the package's upstream pnpm Dockerfile (build context = context7 monorepo root), serving StreamableHTTP on container :8080 (host :3100); point aitm-mcp's CONTEXT7_URL at :8080. Now Up/healthy. Result: all 9 compose services healthy (gitgram backend+web, postgres, redis, aitm-api/mcp/website, gitnexus, context7). E2e through containers still 201/200. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
63133da446
commit
043ea0bf9e
@ -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
|
||||
|
||||
2660
gitgram/backend/prisma/migrations/00000000000000_init/migration.sql
Normal file
2660
gitgram/backend/prisma/migrations/00000000000000_init/migration.sql
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
@ -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");
|
||||
@ -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");
|
||||
@ -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");
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -1,5 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Message" ADD COLUMN "gifUrl" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Post" ADD COLUMN "gifUrl" TEXT;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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");
|
||||
@ -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");
|
||||
@ -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;
|
||||
@ -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;
|
||||
Reference in New Issue
Block a user