From 68a5a3df405b4d73243a18bf365a39fb55fb781b Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 08:52:12 +0400 Subject: [PATCH 1/8] feat: Add Remove exercise fields to Exercise schema --- .../migration.sql | 6 ++++++ prisma/schema.prisma | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql diff --git a/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql b/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql new file mode 100644 index 000000000..04e6607ac --- /dev/null +++ b/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql @@ -0,0 +1,6 @@ +-- AlterTable +ALTER TABLE "exercises" ADD COLUMN "removedAt" TIMESTAMP(3), +ADD COLUMN "removedById" INTEGER; + +-- AddForeignKey +ALTER TABLE "exercises" ADD CONSTRAINT "exercises_removedById_fkey" FOREIGN KEY ("removedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2e7d5ea1d..186a58a99 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -149,7 +149,8 @@ model User { comments Comment[] exercises Exercise[] exerciseSubmissions ExerciseSubmission[] - Exercise Exercise[] @relation("flaggedExercises") + FlaggedExercise Exercise[] @relation("flaggedExercises") + RemovedExercise Exercise[] @relation("removedExercises") modules Module[] starsMentor Star[] @relation("starMentor") starsGiven Star[] @relation("starStudent") @@ -188,6 +189,9 @@ model Exercise { testStr String? explanation String? removed Boolean? @default(false) + removedAt DateTime? + removedById Int? + removedBy User? @relation("removedExercises", fields: [removedById], references: [id]) flagReason String? flaggedAt DateTime? flaggedById Int? From 6ebe9e072c05c7f1c2cc60a3daedd5ab0299b2d7 Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 08:52:31 +0400 Subject: [PATCH 2/8] feat: Update Exercise type definition with the new fields --- graphql/index.tsx | 12 ++++++++++++ graphql/typeDefs.ts | 3 +++ 2 files changed, 15 insertions(+) diff --git a/graphql/index.tsx b/graphql/index.tsx index 7183d5d20..7294d356a 100644 --- a/graphql/index.tsx +++ b/graphql/index.tsx @@ -86,6 +86,9 @@ export type Exercise = { id: Scalars['Int'] module: Module removed?: Maybe + removedAt?: Maybe + removedBy?: Maybe + removedById?: Maybe testStr?: Maybe } @@ -1747,6 +1750,9 @@ export type ExerciseResolvers< id?: Resolver module?: Resolver removed?: Resolver, ParentType, ContextType> + removedAt?: Resolver, ParentType, ContextType> + removedBy?: Resolver, ParentType, ContextType> + removedById?: Resolver, ParentType, ContextType> testStr?: Resolver, ParentType, ContextType> __isTypeOf?: IsTypeOfResolverFn }> @@ -6543,6 +6549,9 @@ export type ExerciseKeySpecifier = ( | 'id' | 'module' | 'removed' + | 'removedAt' + | 'removedBy' + | 'removedById' | 'testStr' | ExerciseKeySpecifier )[] @@ -6558,6 +6567,9 @@ export type ExerciseFieldPolicy = { id?: FieldPolicy | FieldReadFunction module?: FieldPolicy | FieldReadFunction removed?: FieldPolicy | FieldReadFunction + removedAt?: FieldPolicy | FieldReadFunction + removedBy?: FieldPolicy | FieldReadFunction + removedById?: FieldPolicy | FieldReadFunction testStr?: FieldPolicy | FieldReadFunction } export type ExerciseCommentKeySpecifier = ( diff --git a/graphql/typeDefs.ts b/graphql/typeDefs.ts index 3ef486a74..20965ff48 100644 --- a/graphql/typeDefs.ts +++ b/graphql/typeDefs.ts @@ -278,6 +278,9 @@ export default gql` testStr: String explanation: String removed: Boolean + removedAt: String + removedBy: User + removedById: Int flaggedAt: String flagReason: String flaggedBy: User From bb3af6dff42ec660c6cfd8843f7345a8ed73e598 Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:03:50 +0400 Subject: [PATCH 3/8] Revert "feat: Add Remove exercise fields to Exercise schema" This reverts commit 68a5a3df405b4d73243a18bf365a39fb55fb781b. --- .../migration.sql | 6 ------ prisma/schema.prisma | 6 +----- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql diff --git a/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql b/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql deleted file mode 100644 index 04e6607ac..000000000 --- a/prisma/migrations/20230101045032_add_removed_column_date_and_user_to_exercise/migration.sql +++ /dev/null @@ -1,6 +0,0 @@ --- AlterTable -ALTER TABLE "exercises" ADD COLUMN "removedAt" TIMESTAMP(3), -ADD COLUMN "removedById" INTEGER; - --- AddForeignKey -ALTER TABLE "exercises" ADD CONSTRAINT "exercises_removedById_fkey" FOREIGN KEY ("removedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 186a58a99..2e7d5ea1d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -149,8 +149,7 @@ model User { comments Comment[] exercises Exercise[] exerciseSubmissions ExerciseSubmission[] - FlaggedExercise Exercise[] @relation("flaggedExercises") - RemovedExercise Exercise[] @relation("removedExercises") + Exercise Exercise[] @relation("flaggedExercises") modules Module[] starsMentor Star[] @relation("starMentor") starsGiven Star[] @relation("starStudent") @@ -189,9 +188,6 @@ model Exercise { testStr String? explanation String? removed Boolean? @default(false) - removedAt DateTime? - removedById Int? - removedBy User? @relation("removedExercises", fields: [removedById], references: [id]) flagReason String? flaggedAt DateTime? flaggedById Int? From cc4210add81df92410436e83c1320b47b46fb04a Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:07:07 +0400 Subject: [PATCH 4/8] Revert "feat: Update Exercise type definition with the new fields" This reverts commit 6ebe9e072c05c7f1c2cc60a3daedd5ab0299b2d7. --- graphql/index.tsx | 12 ------------ graphql/typeDefs.ts | 3 --- 2 files changed, 15 deletions(-) diff --git a/graphql/index.tsx b/graphql/index.tsx index 7294d356a..7183d5d20 100644 --- a/graphql/index.tsx +++ b/graphql/index.tsx @@ -86,9 +86,6 @@ export type Exercise = { id: Scalars['Int'] module: Module removed?: Maybe - removedAt?: Maybe - removedBy?: Maybe - removedById?: Maybe testStr?: Maybe } @@ -1750,9 +1747,6 @@ export type ExerciseResolvers< id?: Resolver module?: Resolver removed?: Resolver, ParentType, ContextType> - removedAt?: Resolver, ParentType, ContextType> - removedBy?: Resolver, ParentType, ContextType> - removedById?: Resolver, ParentType, ContextType> testStr?: Resolver, ParentType, ContextType> __isTypeOf?: IsTypeOfResolverFn }> @@ -6549,9 +6543,6 @@ export type ExerciseKeySpecifier = ( | 'id' | 'module' | 'removed' - | 'removedAt' - | 'removedBy' - | 'removedById' | 'testStr' | ExerciseKeySpecifier )[] @@ -6567,9 +6558,6 @@ export type ExerciseFieldPolicy = { id?: FieldPolicy | FieldReadFunction module?: FieldPolicy | FieldReadFunction removed?: FieldPolicy | FieldReadFunction - removedAt?: FieldPolicy | FieldReadFunction - removedBy?: FieldPolicy | FieldReadFunction - removedById?: FieldPolicy | FieldReadFunction testStr?: FieldPolicy | FieldReadFunction } export type ExerciseCommentKeySpecifier = ( diff --git a/graphql/typeDefs.ts b/graphql/typeDefs.ts index 20965ff48..3ef486a74 100644 --- a/graphql/typeDefs.ts +++ b/graphql/typeDefs.ts @@ -278,9 +278,6 @@ export default gql` testStr: String explanation: String removed: Boolean - removedAt: String - removedBy: User - removedById: Int flaggedAt: String flagReason: String flaggedBy: User From 76aae44493f17fc0fe72967885eecc2fff9b51ab Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:09:28 +0400 Subject: [PATCH 5/8] feat: Add Remove exercise fields to Exercise schema --- .../migration.sql | 13 +++++++++++++ prisma/schema.prisma | 7 +++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 prisma/migrations/20230101050656_add_removed_column_date_and_user_to_exercise/migration.sql diff --git a/prisma/migrations/20230101050656_add_removed_column_date_and_user_to_exercise/migration.sql b/prisma/migrations/20230101050656_add_removed_column_date_and_user_to_exercise/migration.sql new file mode 100644 index 000000000..2bcb9ee2d --- /dev/null +++ b/prisma/migrations/20230101050656_add_removed_column_date_and_user_to_exercise/migration.sql @@ -0,0 +1,13 @@ +/* + Warnings: + + - You are about to drop the column `removed` on the `exercises` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "exercises" DROP COLUMN "removed", +ADD COLUMN "removedAt" TIMESTAMP(3), +ADD COLUMN "removedById" INTEGER; + +-- AddForeignKey +ALTER TABLE "exercises" ADD CONSTRAINT "exercises_removedById_fkey" FOREIGN KEY ("removedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2e7d5ea1d..1e5b5e374 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -149,7 +149,8 @@ model User { comments Comment[] exercises Exercise[] exerciseSubmissions ExerciseSubmission[] - Exercise Exercise[] @relation("flaggedExercises") + FlaggedExercise Exercise[] @relation("flaggedExercises") + RemovedExercise Exercise[] @relation("removedExercises") modules Module[] starsMentor Star[] @relation("starMentor") starsGiven Star[] @relation("starStudent") @@ -187,7 +188,9 @@ model Exercise { answer String testStr String? explanation String? - removed Boolean? @default(false) + removedAt DateTime? + removedById Int? + removedBy User? @relation("removedExercises", fields: [removedById], references: [id]) flagReason String? flaggedAt DateTime? flaggedById Int? From 25982cd814d84eded9b23d7250e970f0c3637c40 Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:09:37 +0400 Subject: [PATCH 6/8] feat: Update Exercise type definition with the new fields --- graphql/index.tsx | 20 ++++++++++++++------ graphql/typeDefs.ts | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/graphql/index.tsx b/graphql/index.tsx index 7183d5d20..bf4ad10d6 100644 --- a/graphql/index.tsx +++ b/graphql/index.tsx @@ -85,7 +85,9 @@ export type Exercise = { flaggedById?: Maybe id: Scalars['Int'] module: Module - removed?: Maybe + removedAt?: Maybe + removedBy?: Maybe + removedById?: Maybe testStr?: Maybe } @@ -1007,7 +1009,7 @@ export type GetExercisesQuery = { exercises: Array<{ __typename?: 'Exercise' id: number - removed?: boolean | null + removedAt?: string | null description: string answer: string explanation?: string | null @@ -1746,7 +1748,9 @@ export type ExerciseResolvers< flaggedById?: Resolver, ParentType, ContextType> id?: Resolver module?: Resolver - removed?: Resolver, ParentType, ContextType> + removedAt?: Resolver, ParentType, ContextType> + removedBy?: Resolver, ParentType, ContextType> + removedById?: Resolver, ParentType, ContextType> testStr?: Resolver, ParentType, ContextType> __isTypeOf?: IsTypeOfResolverFn }> @@ -4354,7 +4358,7 @@ export const GetExercisesDocument = gql` slug } } - removed + removedAt description answer explanation @@ -6542,7 +6546,9 @@ export type ExerciseKeySpecifier = ( | 'flaggedById' | 'id' | 'module' - | 'removed' + | 'removedAt' + | 'removedBy' + | 'removedById' | 'testStr' | ExerciseKeySpecifier )[] @@ -6557,7 +6563,9 @@ export type ExerciseFieldPolicy = { flaggedById?: FieldPolicy | FieldReadFunction id?: FieldPolicy | FieldReadFunction module?: FieldPolicy | FieldReadFunction - removed?: FieldPolicy | FieldReadFunction + removedAt?: FieldPolicy | FieldReadFunction + removedBy?: FieldPolicy | FieldReadFunction + removedById?: FieldPolicy | FieldReadFunction testStr?: FieldPolicy | FieldReadFunction } export type ExerciseCommentKeySpecifier = ( diff --git a/graphql/typeDefs.ts b/graphql/typeDefs.ts index 3ef486a74..d14ca50a5 100644 --- a/graphql/typeDefs.ts +++ b/graphql/typeDefs.ts @@ -277,7 +277,9 @@ export default gql` answer: String! testStr: String explanation: String - removed: Boolean + removedAt: String + removedBy: User + removedById: Int flaggedAt: String flagReason: String flaggedBy: User From 938c626d8639de09bf7ca897b0ff703183dbf216 Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:09:49 +0400 Subject: [PATCH 7/8] Update getExercise query --- graphql/queries/getExercises.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql/queries/getExercises.ts b/graphql/queries/getExercises.ts index 6187ca990..13f8f438b 100644 --- a/graphql/queries/getExercises.ts +++ b/graphql/queries/getExercises.ts @@ -28,7 +28,7 @@ const GET_EXERCISES = gql` slug } } - removed + removedAt description answer explanation From b52f45b597a09b1ce7ed6acde448c6f278d8da7f Mon Sep 17 00:00:00 2001 From: Flacial Date: Sun, 1 Jan 2023 09:28:15 +0400 Subject: [PATCH 8/8] Update getExercisesData mock --- __dummy__/getExercisesData.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__dummy__/getExercisesData.ts b/__dummy__/getExercisesData.ts index 065b8ed54..69d3c4b66 100644 --- a/__dummy__/getExercisesData.ts +++ b/__dummy__/getExercisesData.ts @@ -70,7 +70,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, - removed: false, + removedAt: null, description: '```\nlet a = 5\na = a + 10\n// what is a?\n```', answer: '15', explanation: 'You can reassign variables that were created with "let".', @@ -91,7 +91,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, - removed: false, + removedAt: null, description: '```\nlet a = 1\na += 2\n// what is a?\n```', answer: '3', explanation: '`a += 2` is a shorter way to write `a = a + 2`', @@ -112,7 +112,7 @@ const getExercisesData: GetExercisesQuery = { email: 'noob@c0d3.com', discordId: '8321' }, - removed: false, + removedAt: null, description: '```\nlet a = 1\na -= 2\n// what is a?\n```', answer: '-1', explanation: null,