mirror of
https://github.com/massbug/judge4c.git
synced 2026-10-15 15:17:31 +00:00
feat: update main branch (#45)
Build & Push Judge4c Docker Image / build-and-push-judge4c-docker-image (., Dockerfile, judge4c) (push) Failing after 17s
Build & Push Judge4c Docker Image / build-and-push-judge4c-docker-image (., Dockerfile, judge4c) (push) Failing after 17s
* chore(deps): add pino and pino-pretty packages * feat(log): add pino logging support * chore(tailwind): update config with features path and animate import * chore(deps): add react-icons package * refactor(auth)!: replace credentials with OAuth providers and add logging BREAKING CHANGE: - Removed credentials-based authentication - Added Google OAuth provider - Implemented detailed logging for auth events - Removed custom JWT/session handling - Added sign-in page configuration - Marked as server-only * refactor(auth)!: remove components and rewrite sign-in page * feat(user-avatar): refactor avatar component into user-avatar with improved structure * style(dockview): reduce tabs container height and center align items - Changed --dv-tabs-and-actions-container-height from 44px to 36px - Added align-items: center to .dv-tabs-container - Improved CSS formatting for better readability * refactor(stores): split dockview store into problem-specific store - Remove generic dockview store (`src/stores/dockview.tsx`) - Add problem-specific dockview store (`src/stores/problem-dockview.tsx`) - Remove submission-related state as it's no longer needed * feat(dockview): refactor dockview component and add problem-specific implementation - Refactor Dockview component into more modular structure: - Extract layout persistence logic to custom hook - Extract component conversion logic to custom hook - Make storageKey optional - Improve type safety with PanelParams interface - Add better error handling and duplicate panel detection - Add new ProblemDockview wrapper component: - Integrates with problem-dockview store - Adds locale awareness - Provides standardized storage key - Update related type definitions and imports * refactor(problems): migrate description and solution to feature-based structure - Remove old parallel route implementations (@Description and @Solutions) - Add new feature-based components for problem description and solution - Create content and panel components for both features - Implement skeleton loading states - Use cached data fetching - Update MDX rendering and scroll area implementations * chore(problems): move problem-dockview to components directory * refactor(layouts): overhaul problem and problemset page structures - Simplify ProblemLayout to use children prop and remove ProblemStoreProvider - Replace PlaygroundHeader with dedicated ProblemHeader component - Streamline ProblemsetLayout with new ProblemsetHeader - Remove deprecated BackButton in favor of NavigateBackButton - Delete unused ProblemStoreProvider and related dependencies * feat(prisma): add server-only caching for problems queries - Add 'server-only' import to enforce server-side usage - Implement cached problem queries with logging: - Add getProblems/getCachedProblems for all problems - Add getProblem/getCachedProblem for single problem by ID - Use React cache and Next.js unstable_cache with tags - Add detailed logging with timing metrics * refactor(mdx-renderer): simplify component implementation - Remove Suspense and Skeleton loading state - Convert to arrow function syntax - Reorganize import statements - Simplify export syntax * feat(components): add TooltipButton component - A reusable button with tooltip functionality - Supports customizable delay, tooltip content, and className - Uses shadcn/ui Tooltip and Button components * refactor(editor): consolidate editor toolbar actions into unified structure - Moved all editor action buttons (copy, format, undo, redo, reset) from `src/components/features/playground/workspace/editor/components/` to new location `src/features/problems/code/components/toolbar/actions/` - Introduced shared `TooltipButton` component to reduce duplication - Created centralized `useProblemEditorActions` hook for common editor operations - Updated imports and exports through new index file - Maintained all existing functionality while improving code organization * refactor(structure): reorganize page and component exports - Move root page from /(app) to / directory - Convert default exports to named exports in components - Rename MainView component to HeroSection for better semantics * refactor(route): rename [id] to [problemId] in problems route * chore(components): remove unused problem-related components - Delete footer.tsx from problem/description - Delete solution.tsx from problem/description - Delete header.tsx from problem/workspace/editor/components * fix(page): add missing return statement in RootPage component * feat(prisma/schema): add multilingual support for problem descriptions and solutions BREAKING CHANGE: - Removed `description` and `solution` fields from Problem model - Added new models `ProblemDescription` and `ProblemSolution` with language support (EN/ZH) - Updated seed data structure to support multilingual content - Requires database migration and data migration from old structure * chore(prisma/migrations): add migration for multilingual problem support * fix(styles): adjust tabs overflow container height in abyss theme Changed height property from 'unset !important' to '100%' for .dv-tabs-overflow-container and .dv-tabs-overflow-dropdown-default in the abyss-spaced theme to fix layout issues. * refactor(loading): change to named export and arrow function - Switch from default export to named export - Convert component to arrow function - Remove unused props parameter * chore(shiki): convert function to arrow function * chore(scripts): remove --turbopack flag from dev script * refactor(prisma): simplify schema and remove zod-prisma-types - Reorganized Prisma schema structure with simplified models and relations - Removed zod-prisma-types generator as it's no longer needed - Consolidated problem content types into a single ProblemLocalization model - Simplified testcase and template structures - Removed unused prisma types file * refactor(prisma): simplify schema and remove zod-prisma-types - Reorganized Prisma schema structure with simplified models and relations - Removed zod-prisma-types generator as it's no longer needed - Consolidated problem content types into a single ProblemLocalization model - Simplified testcase and template structures - Removed unused prisma types file * refactor(i18n): migrate locale configuration to generated types - Replace hardcoded locale strings with generated Locale enum from client - Update cookie key name to be more specific (LOCALE_COOKIE_NAME -> JUDGE4C_LOCALE_KEY) - Rename defaultLocale to DEFAULT_LOCALE for consistency - Add 'server-only' imports to ensure server-side usage - Simplify locale validation using Object.values(Locale) - Clean up accept-language header parsing logic * refactor(hooks): remove theme config and simplify theme hook - Delete src/config/monaco-theme.ts and src/types/monaco-theme.ts - Simplify useMonacoTheme hook to directly return theme strings - Format use-mobile.ts with consistent semicolons and quotes * refactor(i18n): replace language-settings with locale-switcher - Replace react-world-flags with next/image for better optimization - Simplify locale handling logic and remove unused getUserLocale - Rename component to be more descriptive (language-settings -> locale-switcher) - Update all references to use the new component - Add proper SVG flag assets for supported locales - Remove react-world-flags dependency from package.json * refactor(shiki): migrate to shiki/core with lazy initialization - Replace shiki with shiki/core for better tree-shaking - Change highlighter initialization to explicit theme/lang imports - Export getHighlighter function instead of direct highlighter instance - Add error handling for uninitialized highlighter access * refactor(language-selector): migrate to new location and implementation - Remove old language selector from `src/components/features/playground/workspace/editor/components` - Add new implementation in `src/features/problems/code/components/toolbar/controls` - Update toolbar exports to include the new selector * feat(problems): add localization support for problem descriptions and solutions - Replace cached problem data with direct Prisma queries for localized content - Implement locale-based content selection for both descriptions and solutions - Refactor skeleton loading components structure - Change all exports from named to default exports * refactor(code-toolbar): standardize component exports and simplify reset logic - Changed all toolbar action components from named exports with curly braces to default exports - Simplified ResetButton by moving template logic to useProblemEditorActions hook - Updated useProblemEditorActions to handle template selection internally using store data - Renamed problem-editor-store import to problem-editor for consistency * refactor(prisma): simplify prisma client initialization and remove caching Removed all caching and logging functionality from prisma.ts, keeping only the basic Prisma client initialization logic. This includes: - Removal of getProblems, getCachedProblems, getProblem, getCachedProblem functions - Removal of related logger and cache imports - Simplified the global prisma client instantiation * feat(config): add LANGUAGES constant for language enum values * refactor(problemset): move components to separate files and improve structure - Move ProblemsetHeader component from 'problemset-header' to 'header' - Extract problemset table logic into dedicated ProblemsetTable component - Add Suspense and skeleton loading for better UX - Update layout and page structure * feat(dockview): export Dockview component and create ProblemDockview wrapper - Export Dockview component from src/components/dockview.tsx to make it reusable - Create new ProblemDockview component in src/features/problems/components/dockview.tsx that: - Integrates with next-intl for locale handling - Connects to problem-dockview store - Wraps Dockview with problem-specific configuration - Adds locale-based key for proper re-rendering - Maintain existing Dockview functionality including: - Layout persistence - Panel management - API handling * refactor(problems): update ProblemHeader import path to new location * refactor(mdx-render): simplify theme configuration and change export style - Remove custom Monaco theme imports - Use github default themes for rehypePrettyCode - Change component export from default to named export * feat(store): add problem editor state management - Create problem-editor store with Zustand - Manage editor state including problem, language, value and path - Implement localStorage persistence for editor content - Provide utility functions for language and value retrieval * chore(utils): remove unused utility functions - Remove getPath function (moved to problem-editor store) - Remove getDifficultyColorClass function (unused) - Keep only core cn utility function * feat(code-panel): add code editor panel components - Add CodePanel component as container for editor interface - Add CodeContent component with Prisma data fetching - Include CodeContentSkeleton for loading state - Implement ProblemEditor integration with templates * refactor(back-button): relocate and rename back button component - Move from features/problems/components to shared components directory - Rename NavigateBackButton to simpler BackButton - Update component interface naming to BackButtonProps - Keep all existing functionality intact * feat(problemset): enhance header component with back button and className prop - Replace problem-header.tsx with new header.tsx implementation - Add BackButton functionality to navigate to home page - Make className prop configurable using cn utility - Maintain existing user avatar functionality * refactor(config): migrate editor options to standalone editor config - Rename `editor-language.ts` to `editor.ts` - Update interface from `IEditorConstructionOptions` to `IStandaloneEditorConstructionOptions` - Keep all existing editor options unchanged * refactor(components): simplify BackButton by using TooltipButton * refactor(problems): consolidate judge status toast - Migrate status toast from shared hooks to problems feature - Remove deprecated show-status-toast.tsx and status.ts - Implement self-contained JudgeToast component with built-in status mapping * refactor(judge-button): migrate run code button to standalone component - Replace RunCodeButton with new JudgeButton component - Use problem-specific stores instead of playground stores - Implement new judge toast notification system - Simplify authentication check logic - Utilize new TooltipButton component * refactor(api): extract OpenAI client to shared module * fix(prisma): make TestcaseResult.output field optional * chore(prisma): make TestcaseResult.output nullable in migration * feat: replace dockview with flexlayout-react
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Role" AS ENUM ('ADMIN', 'TEACHER', 'STUDENT', 'GUEST');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Difficulty" AS ENUM ('EASY', 'MEDIUM', 'HARD');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EditorLanguage" AS ENUM ('c', 'cpp');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"role" "Role" NOT NULL DEFAULT 'GUEST',
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Problem" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"description" TEXT NOT NULL,
|
||||
"solution" TEXT NOT NULL,
|
||||
"difficulty" "Difficulty" NOT NULL DEFAULT 'EASY',
|
||||
"published" BOOLEAN NOT NULL DEFAULT false,
|
||||
"authorId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Problem_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Template" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"language" "EditorLanguage" NOT NULL,
|
||||
"template" TEXT NOT NULL,
|
||||
"problemId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Template_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_name_key" ON "User"("name");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Problem" ADD CONSTRAINT "Problem_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `Problem` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `authorId` on the `Problem` table. All the data in the column will be lost.
|
||||
- The primary key for the `Template` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `id` on the `Template` table. All the data in the column will be lost.
|
||||
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- Added the required column `userId` to the `Problem` table without a default value. This is not possible if the table is not empty.
|
||||
- Added the required column `updatedAt` to the `User` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Problem" DROP CONSTRAINT "Problem_authorId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_problemId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "User_name_key";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Problem" DROP CONSTRAINT "Problem_pkey",
|
||||
DROP COLUMN "authorId",
|
||||
ADD COLUMN "userId" TEXT NOT NULL,
|
||||
ALTER COLUMN "id" DROP DEFAULT,
|
||||
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
||||
ADD CONSTRAINT "Problem_pkey" PRIMARY KEY ("id");
|
||||
DROP SEQUENCE "Problem_id_seq";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Template" DROP CONSTRAINT "Template_pkey",
|
||||
DROP COLUMN "id",
|
||||
ALTER COLUMN "problemId" SET DATA TYPE TEXT,
|
||||
ADD CONSTRAINT "Template_pkey" PRIMARY KEY ("problemId", "language");
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
|
||||
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
ADD COLUMN "emailVerified" TIMESTAMP(3),
|
||||
ADD COLUMN "image" TEXT,
|
||||
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
ALTER COLUMN "id" DROP DEFAULT,
|
||||
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
||||
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id");
|
||||
DROP SEQUENCE "User_id_seq";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Account" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"provider" TEXT NOT NULL,
|
||||
"providerAccountId" TEXT NOT NULL,
|
||||
"refresh_token" TEXT,
|
||||
"access_token" TEXT,
|
||||
"expires_at" INTEGER,
|
||||
"token_type" TEXT,
|
||||
"scope" TEXT,
|
||||
"id_token" TEXT,
|
||||
"session_state" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Account_pkey" PRIMARY KEY ("provider","providerAccountId")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Session" (
|
||||
"sessionToken" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "VerificationToken" (
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "VerificationToken_pkey" PRIMARY KEY ("identifier","token")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Authenticator" (
|
||||
"credentialID" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"providerAccountId" TEXT NOT NULL,
|
||||
"credentialPublicKey" TEXT NOT NULL,
|
||||
"counter" INTEGER NOT NULL,
|
||||
"credentialDeviceType" TEXT NOT NULL,
|
||||
"credentialBackedUp" BOOLEAN NOT NULL,
|
||||
"transports" TEXT,
|
||||
|
||||
CONSTRAINT "Authenticator_pkey" PRIMARY KEY ("userId","credentialID")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Authenticator_credentialID_key" ON "Authenticator"("credentialID");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Problem_userId_idx" ON "Problem"("userId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "Problem_difficulty_idx" ON "Problem"("difficulty");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Problem" ADD CONSTRAINT "Problem_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Authenticator" ADD CONSTRAINT "Authenticator_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,4 +0,0 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "password" TEXT,
|
||||
ALTER COLUMN "name" DROP NOT NULL,
|
||||
ALTER COLUMN "email" DROP NOT NULL;
|
||||
@@ -1,10 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "EditorLanguageConfig" (
|
||||
"id" TEXT NOT NULL,
|
||||
"language" "EditorLanguage" NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"fileName" TEXT NOT NULL,
|
||||
"fileExtension" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "EditorLanguageConfig_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The primary key for the `EditorLanguageConfig` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||
- You are about to drop the column `id` on the `EditorLanguageConfig` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[language]` on the table `EditorLanguageConfig` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EditorLanguageConfig" DROP CONSTRAINT "EditorLanguageConfig_pkey",
|
||||
DROP COLUMN "id";
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EditorLanguageConfig_language_key" ON "EditorLanguageConfig"("language");
|
||||
@@ -1,14 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "LanguageServerConfig" (
|
||||
"language" "EditorLanguage" NOT NULL,
|
||||
"protocol" TEXT NOT NULL,
|
||||
"hostname" TEXT NOT NULL,
|
||||
"port" INTEGER,
|
||||
"path" TEXT
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "LanguageServerConfig_language_key" ON "LanguageServerConfig"("language");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "LanguageServerConfig" ADD CONSTRAINT "LanguageServerConfig_language_fkey" FOREIGN KEY ("language") REFERENCES "EditorLanguageConfig"("language") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,17 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "DockerConfig" (
|
||||
"language" "EditorLanguage" NOT NULL,
|
||||
"image" TEXT NOT NULL,
|
||||
"tag" TEXT NOT NULL,
|
||||
"workingDir" TEXT NOT NULL,
|
||||
"timeLimit" INTEGER NOT NULL,
|
||||
"memoryLimit" INTEGER NOT NULL,
|
||||
"compileOutputLimit" INTEGER NOT NULL,
|
||||
"runOutputLimit" INTEGER NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "DockerConfig_language_key" ON "DockerConfig"("language");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DockerConfig" ADD CONSTRAINT "DockerConfig_language_fkey" FOREIGN KEY ("language") REFERENCES "EditorLanguageConfig"("language") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ExitCode" AS ENUM ('SE', 'CS', 'CE', 'TLE', 'MLE', 'RE', 'AC', 'WA');
|
||||
@@ -1,10 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "JudgeResult" (
|
||||
"id" TEXT NOT NULL,
|
||||
"output" TEXT NOT NULL,
|
||||
"exitCode" "ExitCode" NOT NULL,
|
||||
"executionTime" INTEGER,
|
||||
"memoryUsage" INTEGER,
|
||||
|
||||
CONSTRAINT "JudgeResult_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Changed the type of `protocol` on the `LanguageServerConfig` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "LanguageServerProtocol" AS ENUM ('ws', 'wss');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "LanguageServerConfig" DROP COLUMN "protocol",
|
||||
ADD COLUMN "protocol" "LanguageServerProtocol" NOT NULL;
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- The values [TEACHER,STUDENT] on the enum `Role` will be removed. If these variants are still used in the database, this will fail.
|
||||
|
||||
*/
|
||||
-- AlterEnum
|
||||
BEGIN;
|
||||
CREATE TYPE "Role_new" AS ENUM ('ADMIN', 'GUEST');
|
||||
ALTER TABLE "User" ALTER COLUMN "role" DROP DEFAULT;
|
||||
ALTER TABLE "User" ALTER COLUMN "role" TYPE "Role_new" USING ("role"::text::"Role_new");
|
||||
ALTER TYPE "Role" RENAME TO "Role_old";
|
||||
ALTER TYPE "Role_new" RENAME TO "Role";
|
||||
DROP TYPE "Role_old";
|
||||
ALTER TABLE "User" ALTER COLUMN "role" SET DEFAULT 'GUEST';
|
||||
COMMIT;
|
||||
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[displayId]` on the table `Problem` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `displayId` to the `Problem` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Problem" ADD COLUMN "displayId" INTEGER NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Problem_displayId_key" ON "Problem"("displayId");
|
||||
@@ -1,23 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Testcase" (
|
||||
"id" TEXT NOT NULL,
|
||||
"problemId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Testcase_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TestcaseData" (
|
||||
"id" TEXT NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"value" TEXT NOT NULL,
|
||||
"testcaseId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "TestcaseData_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Testcase" ADD CONSTRAINT "Testcase_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseData" ADD CONSTRAINT "TestcaseData_testcaseId_fkey" FOREIGN KEY ("testcaseId") REFERENCES "Testcase"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `expectedOutput` to the `Testcase` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Testcase" ADD COLUMN "expectedOutput" TEXT NOT NULL;
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `memoryLimit` on the `DockerConfig` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `timeLimit` on the `DockerConfig` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "DockerConfig" DROP COLUMN "memoryLimit",
|
||||
DROP COLUMN "timeLimit";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Problem" ADD COLUMN "memoryLimit" INTEGER NOT NULL DEFAULT 128,
|
||||
ADD COLUMN "timeLimit" INTEGER NOT NULL DEFAULT 1000;
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the `JudgeResult` table. If the table is not empty, all the data it contains will be lost.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Status" AS ENUM ('PD', 'QD', 'CP', 'CE', 'CS', 'RU', 'TLE', 'MLE', 'RE', 'AC', 'WA', 'SE');
|
||||
|
||||
-- DropTable
|
||||
DROP TABLE "JudgeResult";
|
||||
|
||||
-- DropEnum
|
||||
DROP TYPE "ExitCode";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Submission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"language" "EditorLanguage" NOT NULL,
|
||||
"code" TEXT NOT NULL,
|
||||
"status" "Status" NOT NULL,
|
||||
"message" TEXT,
|
||||
"executionTime" INTEGER,
|
||||
"memoryUsage" INTEGER,
|
||||
"userId" TEXT NOT NULL,
|
||||
"problemId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Submission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Submission" ADD CONSTRAINT "Submission_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `index` to the `TestcaseData` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "TestcaseData" ADD COLUMN "index" INTEGER NOT NULL;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TestcaseResult" (
|
||||
"id" TEXT NOT NULL,
|
||||
"isCorrect" BOOLEAN NOT NULL,
|
||||
"output" TEXT NOT NULL,
|
||||
"executionTime" INTEGER,
|
||||
"memoryUsage" INTEGER,
|
||||
"submissionId" TEXT NOT NULL,
|
||||
"testcaseId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "TestcaseResult_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseResult" ADD CONSTRAINT "TestcaseResult_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "Submission"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseResult" ADD CONSTRAINT "TestcaseResult_testcaseId_fkey" FOREIGN KEY ("testcaseId") REFERENCES "Testcase"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,244 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Role" AS ENUM ('ADMIN', 'GUEST');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Difficulty" AS ENUM ('EASY', 'MEDIUM', 'HARD');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Locale" AS ENUM ('en', 'zh');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Language" AS ENUM ('c', 'cpp');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Protocol" AS ENUM ('ws', 'wss');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Status" AS ENUM ('PD', 'QD', 'CP', 'CE', 'CS', 'RU', 'TLE', 'MLE', 'RE', 'AC', 'WA', 'SE');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ProblemContentType" AS ENUM ('TITLE', 'DESCRIPTION', 'SOLUTION');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT,
|
||||
"email" TEXT NOT NULL,
|
||||
"emailVerified" TIMESTAMP(3),
|
||||
"image" TEXT,
|
||||
"role" "Role" NOT NULL DEFAULT 'GUEST',
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Problem" (
|
||||
"id" TEXT NOT NULL,
|
||||
"displayId" INTEGER NOT NULL,
|
||||
"difficulty" "Difficulty" NOT NULL DEFAULT 'EASY',
|
||||
"isPublished" BOOLEAN NOT NULL DEFAULT false,
|
||||
"timeLimit" INTEGER NOT NULL DEFAULT 1000,
|
||||
"memoryLimit" INTEGER NOT NULL DEFAULT 134217728,
|
||||
"userId" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Problem_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ProblemLocalization" (
|
||||
"problemId" TEXT NOT NULL,
|
||||
"locale" "Locale" NOT NULL,
|
||||
"type" "ProblemContentType" NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "ProblemLocalization_pkey" PRIMARY KEY ("problemId","locale","type")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Template" (
|
||||
"problemId" TEXT NOT NULL,
|
||||
"language" "Language" NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Template_pkey" PRIMARY KEY ("problemId","language")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Submission" (
|
||||
"id" TEXT NOT NULL,
|
||||
"language" "Language" NOT NULL,
|
||||
"content" TEXT NOT NULL,
|
||||
"status" "Status" NOT NULL,
|
||||
"message" TEXT,
|
||||
"timeUsage" INTEGER,
|
||||
"memoryUsage" INTEGER,
|
||||
"userId" TEXT NOT NULL,
|
||||
"problemId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Submission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Testcase" (
|
||||
"id" TEXT NOT NULL,
|
||||
"expectedOutput" TEXT NOT NULL,
|
||||
"problemId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Testcase_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TestcaseInput" (
|
||||
"id" TEXT NOT NULL,
|
||||
"index" INTEGER NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"value" TEXT NOT NULL,
|
||||
"testcaseId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "TestcaseInput_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TestcaseResult" (
|
||||
"id" TEXT NOT NULL,
|
||||
"isCorrect" BOOLEAN NOT NULL,
|
||||
"output" TEXT NOT NULL,
|
||||
"timeUsage" INTEGER,
|
||||
"memoryUsage" INTEGER,
|
||||
"submissionId" TEXT NOT NULL,
|
||||
"testcaseId" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "TestcaseResult_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "DockerConfig" (
|
||||
"language" "Language" NOT NULL,
|
||||
"image" TEXT NOT NULL,
|
||||
"tag" TEXT NOT NULL,
|
||||
"workingDir" TEXT NOT NULL,
|
||||
"compileOutputLimit" INTEGER NOT NULL DEFAULT 1048576,
|
||||
"runOutputLimit" INTEGER NOT NULL DEFAULT 1048576,
|
||||
|
||||
CONSTRAINT "DockerConfig_pkey" PRIMARY KEY ("language")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "LanguageServerConfig" (
|
||||
"language" "Language" NOT NULL,
|
||||
"protocol" "Protocol" NOT NULL,
|
||||
"hostname" TEXT NOT NULL,
|
||||
"port" INTEGER,
|
||||
"path" TEXT,
|
||||
|
||||
CONSTRAINT "LanguageServerConfig_pkey" PRIMARY KEY ("language")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Account" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"provider" TEXT NOT NULL,
|
||||
"providerAccountId" TEXT NOT NULL,
|
||||
"refresh_token" TEXT,
|
||||
"access_token" TEXT,
|
||||
"expires_at" INTEGER,
|
||||
"token_type" TEXT,
|
||||
"scope" TEXT,
|
||||
"id_token" TEXT,
|
||||
"session_state" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Account_pkey" PRIMARY KEY ("provider","providerAccountId")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Session" (
|
||||
"sessionToken" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "VerificationToken" (
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "VerificationToken_pkey" PRIMARY KEY ("identifier","token")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Authenticator" (
|
||||
"credentialID" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"providerAccountId" TEXT NOT NULL,
|
||||
"credentialPublicKey" TEXT NOT NULL,
|
||||
"counter" INTEGER NOT NULL,
|
||||
"credentialDeviceType" TEXT NOT NULL,
|
||||
"credentialBackedUp" BOOLEAN NOT NULL,
|
||||
"transports" TEXT,
|
||||
|
||||
CONSTRAINT "Authenticator_pkey" PRIMARY KEY ("userId","credentialID")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Problem_displayId_key" ON "Problem"("displayId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Session_sessionToken_key" ON "Session"("sessionToken");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Authenticator_credentialID_key" ON "Authenticator"("credentialID");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Problem" ADD CONSTRAINT "Problem_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProblemLocalization" ADD CONSTRAINT "ProblemLocalization_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Template" ADD CONSTRAINT "Template_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Submission" ADD CONSTRAINT "Submission_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Testcase" ADD CONSTRAINT "Testcase_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseInput" ADD CONSTRAINT "TestcaseInput_testcaseId_fkey" FOREIGN KEY ("testcaseId") REFERENCES "Testcase"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseResult" ADD CONSTRAINT "TestcaseResult_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "Submission"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TestcaseResult" ADD CONSTRAINT "TestcaseResult_testcaseId_fkey" FOREIGN KEY ("testcaseId") REFERENCES "Testcase"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Account" ADD CONSTRAINT "Account_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Session" ADD CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Authenticator" ADD CONSTRAINT "Authenticator_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "TestcaseResult" ALTER COLUMN "output" DROP NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "password" TEXT;
|
||||
+143
-124
@@ -1,116 +1,39 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../src/generated/client"
|
||||
}
|
||||
|
||||
generator zod {
|
||||
provider = "zod-prisma-types"
|
||||
output = "../src/generated/zod"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../src/generated/client"
|
||||
}
|
||||
|
||||
enum Role {
|
||||
ADMIN
|
||||
GUEST
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
password String?
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
// Optional for WebAuthn support
|
||||
Authenticator Authenticator[]
|
||||
|
||||
role Role @default(GUEST)
|
||||
problems Problem[]
|
||||
submissions Submission[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
enum Difficulty {
|
||||
EASY
|
||||
MEDIUM
|
||||
HARD
|
||||
}
|
||||
|
||||
model Problem {
|
||||
id String @id @default(cuid())
|
||||
displayId Int @unique
|
||||
title String
|
||||
description String
|
||||
solution String
|
||||
difficulty Difficulty @default(EASY)
|
||||
published Boolean @default(false)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
timeLimit Int @default(1000)
|
||||
memoryLimit Int @default(128)
|
||||
templates Template[]
|
||||
testcases Testcase[]
|
||||
submissions Submission[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([difficulty])
|
||||
enum Locale {
|
||||
en
|
||||
zh
|
||||
}
|
||||
|
||||
enum EditorLanguage {
|
||||
enum Language {
|
||||
c
|
||||
cpp
|
||||
}
|
||||
|
||||
model EditorLanguageConfig {
|
||||
language EditorLanguage @unique
|
||||
label String
|
||||
fileName String
|
||||
fileExtension String
|
||||
languageServerConfig LanguageServerConfig? @relation
|
||||
dockerConfig DockerConfig? @relation
|
||||
}
|
||||
|
||||
enum LanguageServerProtocol {
|
||||
enum Protocol {
|
||||
ws
|
||||
wss
|
||||
}
|
||||
|
||||
model LanguageServerConfig {
|
||||
language EditorLanguage @unique
|
||||
protocol LanguageServerProtocol
|
||||
hostname String
|
||||
port Int?
|
||||
path String?
|
||||
editorLanguageConfig EditorLanguageConfig @relation(fields: [language], references: [language])
|
||||
}
|
||||
|
||||
model DockerConfig {
|
||||
language EditorLanguage @unique
|
||||
image String
|
||||
tag String
|
||||
workingDir String
|
||||
compileOutputLimit Int
|
||||
runOutputLimit Int
|
||||
editorLanguageConfig EditorLanguageConfig @relation(fields: [language], references: [language])
|
||||
}
|
||||
|
||||
model Template {
|
||||
language EditorLanguage
|
||||
template String
|
||||
problemId String
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([problemId, language])
|
||||
}
|
||||
|
||||
enum Status {
|
||||
PD // PENDING
|
||||
QD // QUEUED
|
||||
@@ -126,14 +49,86 @@ enum Status {
|
||||
SE // System Error
|
||||
}
|
||||
|
||||
enum ProblemContentType {
|
||||
TITLE
|
||||
DESCRIPTION
|
||||
SOLUTION
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String @unique
|
||||
password String?
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
role Role @default(GUEST)
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
// Optional for WebAuthn support
|
||||
Authenticator Authenticator[]
|
||||
problems Problem[]
|
||||
submissions Submission[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Problem {
|
||||
id String @id @default(cuid())
|
||||
displayId Int @unique
|
||||
difficulty Difficulty @default(EASY)
|
||||
isPublished Boolean @default(false)
|
||||
timeLimit Int @default(1000)
|
||||
memoryLimit Int @default(134217728)
|
||||
|
||||
localizations ProblemLocalization[]
|
||||
templates Template[]
|
||||
testcases Testcase[]
|
||||
submissions Submission[]
|
||||
|
||||
userId String?
|
||||
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ProblemLocalization {
|
||||
problemId String
|
||||
locale Locale
|
||||
type ProblemContentType
|
||||
|
||||
content String
|
||||
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([problemId, locale, type])
|
||||
}
|
||||
|
||||
model Template {
|
||||
problemId String
|
||||
language Language
|
||||
|
||||
content String
|
||||
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([problemId, language])
|
||||
}
|
||||
|
||||
model Submission {
|
||||
id String @id @default(cuid())
|
||||
language EditorLanguage
|
||||
code String
|
||||
status Status
|
||||
message String?
|
||||
executionTime Int?
|
||||
memoryUsage Int?
|
||||
id String @id @default(cuid())
|
||||
language Language
|
||||
content String
|
||||
status Status
|
||||
message String?
|
||||
timeUsage Int?
|
||||
memoryUsage Int?
|
||||
|
||||
testcaseResults TestcaseResult[]
|
||||
|
||||
userId String
|
||||
problemId String
|
||||
@@ -141,47 +136,70 @@ model Submission {
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
|
||||
testcaseResults TestcaseResult[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Testcase {
|
||||
id String @id @default(cuid())
|
||||
problemId String
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
data TestcaseData[]
|
||||
id String @id @default(cuid())
|
||||
expectedOutput String
|
||||
|
||||
inputs TestcaseInput[]
|
||||
testcaseResults TestcaseResult[]
|
||||
}
|
||||
|
||||
model TestcaseData {
|
||||
id String @id @default(cuid())
|
||||
index Int
|
||||
label String
|
||||
value String
|
||||
testcaseId String
|
||||
testcase Testcase @relation(fields: [testcaseId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
problemId String
|
||||
|
||||
model TestcaseResult {
|
||||
id String @id @default(cuid())
|
||||
isCorrect Boolean
|
||||
output String
|
||||
|
||||
executionTime Int?
|
||||
memoryUsage Int?
|
||||
|
||||
submissionId String
|
||||
testcaseId String
|
||||
submission Submission @relation(fields: [submissionId], references: [id], onDelete: Cascade)
|
||||
testcase Testcase @relation(fields: [testcaseId], references: [id], onDelete: Cascade)
|
||||
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model TestcaseInput {
|
||||
id String @id @default(cuid())
|
||||
index Int
|
||||
name String
|
||||
value String
|
||||
|
||||
testcaseId String
|
||||
|
||||
testcase Testcase @relation(fields: [testcaseId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model TestcaseResult {
|
||||
id String @id @default(cuid())
|
||||
isCorrect Boolean
|
||||
output String?
|
||||
timeUsage Int?
|
||||
memoryUsage Int?
|
||||
|
||||
submissionId String
|
||||
testcaseId String
|
||||
|
||||
submission Submission @relation(fields: [submissionId], references: [id], onDelete: Cascade)
|
||||
testcase Testcase @relation(fields: [testcaseId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model DockerConfig {
|
||||
language Language @id
|
||||
image String
|
||||
tag String
|
||||
workingDir String
|
||||
compileOutputLimit Int @default(1048576)
|
||||
runOutputLimit Int @default(1048576)
|
||||
}
|
||||
|
||||
model LanguageServerConfig {
|
||||
language Language @id
|
||||
protocol Protocol
|
||||
hostname String
|
||||
port Int?
|
||||
path String?
|
||||
}
|
||||
|
||||
model Account {
|
||||
userId String
|
||||
type String
|
||||
@@ -195,11 +213,11 @@ model Account {
|
||||
id_token String?
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([provider, providerAccountId])
|
||||
}
|
||||
|
||||
@@ -207,7 +225,8 @@ model Session {
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
+807
-179
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user