Skip to content

Commit

Permalink
Merge pull request #66 from Rituraj67/master
Browse files Browse the repository at this point in the history
added Poll Migration
  • Loading branch information
imdeveshshukla authored Sep 8, 2024
2 parents 5a865c2 + 657e565 commit 690897d
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,54 +1,18 @@
-- CreateTable
CREATE TABLE "User" (
"dp" TEXT,
"bgImg" TEXT,
"bio" TEXT,
"userID" TEXT NOT NULL,
"username" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"isVarified" BOOLEAN NOT NULL DEFAULT false,
"leetcode" TEXT,
"showLC" BOOLEAN NOT NULL DEFAULT false,
"codeforces" TEXT,
"showCf" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "User_pkey" PRIMARY KEY ("userID")
);

-- CreateTable
CREATE TABLE "Poll" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"userId" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "PollOption" (
"id" TEXT NOT NULL,
"text" TEXT NOT NULL,
"pollId" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "Vote" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"optionId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "UserVarify" (
"userID" TEXT NOT NULL,
Expand Down Expand Up @@ -164,18 +128,6 @@ CREATE UNIQUE INDEX "Rooms_id_title_key" ON "Rooms"("id", "title");
-- CreateIndex
CREATE UNIQUE INDEX "EnrolledRooms_userId_RoomId_key" ON "EnrolledRooms"("userId", "RoomId");

-- AddForeignKey
ALTER TABLE "Poll" ADD CONSTRAINT "Poll_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "PollOption" ADD CONSTRAINT "PollOption_pollId_fkey" FOREIGN KEY ("pollId") REFERENCES "Poll"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Vote" ADD CONSTRAINT "Vote_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Vote" ADD CONSTRAINT "Vote_optionId_fkey" FOREIGN KEY ("optionId") REFERENCES "PollOption"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Post" ADD CONSTRAINT "Post_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE CASCADE ON UPDATE CASCADE;

Expand Down
5 changes: 5 additions & 0 deletions backend/prisma/migrations/20240731125024_dev/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "Rooms" DROP CONSTRAINT "Rooms_CreatorId_fkey";

-- AddForeignKey
ALTER TABLE "Rooms" ADD CONSTRAINT "Rooms_CreatorId_fkey" FOREIGN KEY ("CreatorId") REFERENCES "User"("username") ON DELETE CASCADE ON UPDATE CASCADE;
5 changes: 5 additions & 0 deletions backend/prisma/migrations/20240731132317_dev/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "Rooms" DROP CONSTRAINT "Rooms_CreatorId_fkey";

-- AddForeignKey
ALTER TABLE "Rooms" ADD CONSTRAINT "Rooms_CreatorId_fkey" FOREIGN KEY ("CreatorId") REFERENCES "User"("userID") ON DELETE CASCADE ON UPDATE CASCADE;
24 changes: 24 additions & 0 deletions backend/prisma/migrations/20240816011135_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- CreateTable
CREATE TABLE "Leetcode" (
"id" TEXT NOT NULL,
"acceptanceRate" DOUBLE PRECISION NOT NULL,
"contributionPoints" INTEGER NOT NULL,
"easySolved" INTEGER NOT NULL,
"hardSolved" INTEGER NOT NULL,
"mediumSolved" INTEGER NOT NULL,
"ranking" INTEGER NOT NULL,
"totalEasy" INTEGER NOT NULL,
"totalHard" INTEGER NOT NULL,
"totalMedium" INTEGER NOT NULL,
"totalQuestions" INTEGER NOT NULL,
"totalSolved" INTEGER NOT NULL,
"userId" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Leetcode_userId_key" ON "Leetcode"("userId");

-- AddForeignKey
ALTER TABLE "Leetcode" ADD CONSTRAINT "Leetcode_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE RESTRICT ON UPDATE CASCADE;
14 changes: 14 additions & 0 deletions backend/prisma/migrations/20240816063047_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Warnings:
- You are about to drop the `Leetcode` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Leetcode" DROP CONSTRAINT "Leetcode_userId_fkey";

-- AlterTable
ALTER TABLE "User" ADD COLUMN "leetcode" TEXT;

-- DropTable
DROP TABLE "Leetcode";
2 changes: 2 additions & 0 deletions backend/prisma/migrations/20240817011920_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "showLC" BOOLEAN NOT NULL DEFAULT false;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "codeforces" TEXT,
ADD COLUMN "showCf" BOOLEAN NOT NULL DEFAULT false;
2 changes: 2 additions & 0 deletions backend/prisma/migrations/20240825232056_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "bgImg" TEXT;
23 changes: 0 additions & 23 deletions backend/prisma/migrations/20240905164750_development/migration.sql

This file was deleted.

This file was deleted.

47 changes: 47 additions & 0 deletions backend/prisma/migrations/20240908104001_poll/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- CreateTable
CREATE TABLE "Poll" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"topic" TEXT,
"description" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"userId" TEXT NOT NULL,
"subCommunity" TEXT,

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

-- CreateTable
CREATE TABLE "PollOption" (
"id" TEXT NOT NULL,
"text" TEXT NOT NULL,
"pollId" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "Vote" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"optionId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- AddForeignKey
ALTER TABLE "Poll" ADD CONSTRAINT "Poll_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Poll" ADD CONSTRAINT "Poll_subCommunity_fkey" FOREIGN KEY ("subCommunity") REFERENCES "Rooms"("title") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "PollOption" ADD CONSTRAINT "PollOption_pollId_fkey" FOREIGN KEY ("pollId") REFERENCES "Poll"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Vote" ADD CONSTRAINT "Vote_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userID") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Vote" ADD CONSTRAINT "Vote_optionId_fkey" FOREIGN KEY ("optionId") REFERENCES "PollOption"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion frontend/src/components/Polls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const Polls = ({ poll, setPollVote, user, inRoom, room, topic, joined }) => {


</div>
<div className=' bg-gray-700 h-[1px]'></div>
<div className=' ml-4 xs:ml-0 bg-gray-700 h-[1px] mr-4'></div>

</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Posts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ const Posts = ({ id, post, title,topic, body, media, countComment, inRoom, room,
</footer>
</div>

<div className=' bg-gray-700 h-[1px]'></div>
<div className='ml-4 xs:ml-0 bg-gray-700 h-[1px] mr-4'></div>
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const Home = () => {

return (<>

<div id="scrollableDiv" className=' overflow-auto h-fit'>
<div id="scrollableDiv" className=' xs:pl-8 sm:pl-16 overflow-auto h-fit'>
<InfiniteScroll
dataLength={posts.length}
next={fetchMoreData}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/ProfileComments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const UserComment = ({ comment }) => {


</div>
<div className=' bg-gray-700 h-[1px]'></div>
<div className='ml-4 xs:ml-0 mr-4 bg-gray-700 h-[1px]'></div>

</div>)
}
6 changes: 2 additions & 4 deletions frontend/src/pages/Room.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ export const RoomPost = ({title,privateRoom,joined,data})=>{
console.log('Request canceled:', error.message);
} else {
console.error(error);
setHasMore(false); // Disable further fetching in case of error
} // Stop fetching if there's an error
setHasMore(false);
}
}

}
Expand Down Expand Up @@ -494,8 +494,6 @@ export const RoomPost = ({title,privateRoom,joined,data})=>{
endMessage={hotposts.length > 0 ? <p className=' text-center font-semibold p-4'>{"You've reached the end of the page!"}</p> : <p className=' text-center font-semibold p-4'>No posts available to display!</p>}
>



<div className="post">
{
(
Expand Down

0 comments on commit 690897d

Please sign in to comment.