diff --git a/backend/.dockerignore b/backend/.dockerignore index 23b5b6273..c1fb5fa60 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -1,2 +1 @@ -.env .node_modules \ No newline at end of file diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 000000000..2eea525d8 --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index ce56c2acf..91a541a31 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -8,6 +8,8 @@ services: - POSTGRES_DB=db - POSTGRES_USER=admin - POSTGRES_PASSWORD=password + volumes: + - ./data/postgres:/var/lib/postgresql/data networks: - docker-service diff --git a/backend/drizzle/0000_luxuriant_mandrill.sql b/backend/drizzle/0000_luxuriant_mandrill.sql deleted file mode 100644 index 5331c1ea6..000000000 --- a/backend/drizzle/0000_luxuriant_mandrill.sql +++ /dev/null @@ -1,103 +0,0 @@ -DO $$ BEGIN - CREATE TYPE "permission" AS ENUM('newStudent', 'Student', 'Admin', 'RespoCE', 'Respo', 'Anim'); -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "challenge" ( - "id" serial PRIMARY KEY NOT NULL, - "challenge_name" text NOT NULL, - "challenge_desc" text NOT NULL, - "points" integer NOT NULL, - CONSTRAINT "challenge_challenge_name_unique" UNIQUE("challenge_name") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "factionTochallenge" ( - "faction_id" integer NOT NULL, - "challenge_id" integer NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "event" ( - "id" serial PRIMARY KEY NOT NULL, - "event_name" text NOT NULL, - "state" boolean NOT NULL, - CONSTRAINT "event_event_name_unique" UNIQUE("event_name") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "faction" ( - "id" serial PRIMARY KEY NOT NULL, - "team_name" text NOT NULL, - "points" integer NOT NULL, - CONSTRAINT "faction_team_name_unique" UNIQUE("team_name") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "role" ( - "id" serial PRIMARY KEY NOT NULL, - "role_name" text NOT NULL, - "role_desc" text NOT NULL, - CONSTRAINT "role_role_name_unique" UNIQUE("role_name") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "userToRole" ( - "user_id" integer NOT NULL, - "role_id" integer NOT NULL, - "isWish" boolean NOT NULL -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "team" ( - "id" serial PRIMARY KEY NOT NULL, - "isOfficial" boolean NOT NULL, - "timeCode" bigint, - "team_name" text NOT NULL, - "city_id" integer, - CONSTRAINT "team_team_name_unique" UNIQUE("team_name") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "user" ( - "id" serial PRIMARY KEY NOT NULL, - "first_name" text NOT NULL, - "last_name" text NOT NULL, - "email" text NOT NULL, - "contact" text, - "connection_num" integer NOT NULL, - "permission" "permission" NOT NULL, - "password" text NOT NULL, - "team" integer, - CONSTRAINT "user_email_unique" UNIQUE("email") -); ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "factionTochallenge" ADD CONSTRAINT "factionTochallenge_faction_id_faction_id_fk" FOREIGN KEY ("faction_id") REFERENCES "faction"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "factionTochallenge" ADD CONSTRAINT "factionTochallenge_challenge_id_challenge_id_fk" FOREIGN KEY ("challenge_id") REFERENCES "challenge"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToRole" ADD CONSTRAINT "userToRole_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToRole" ADD CONSTRAINT "userToRole_role_id_role_id_fk" FOREIGN KEY ("role_id") REFERENCES "role"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "team" ADD CONSTRAINT "team_city_id_faction_id_fk" FOREIGN KEY ("city_id") REFERENCES "faction"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "user" ADD CONSTRAINT "user_team_team_id_fk" FOREIGN KEY ("team") REFERENCES "team"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; diff --git a/backend/drizzle/0001_bright_strong_guy.sql b/backend/drizzle/0001_bright_strong_guy.sql deleted file mode 100644 index b5423c014..000000000 --- a/backend/drizzle/0001_bright_strong_guy.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "team" ALTER COLUMN "timeCode" SET DATA TYPE bigint; \ No newline at end of file diff --git a/backend/drizzle/0002_large_mulholland_black.sql b/backend/drizzle/0002_large_mulholland_black.sql deleted file mode 100644 index 27764f3dd..000000000 --- a/backend/drizzle/0002_large_mulholland_black.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "team" ALTER COLUMN "timeCode" SET DATA TYPE bigint; diff --git a/backend/drizzle/0003_odd_beyonder.sql b/backend/drizzle/0003_odd_beyonder.sql deleted file mode 100644 index 27764f3dd..000000000 --- a/backend/drizzle/0003_odd_beyonder.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "team" ALTER COLUMN "timeCode" SET DATA TYPE bigint; diff --git a/backend/drizzle/0004_fluffy_kate_bishop.sql b/backend/drizzle/0004_fluffy_kate_bishop.sql deleted file mode 100644 index 27764f3dd..000000000 --- a/backend/drizzle/0004_fluffy_kate_bishop.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "team" ALTER COLUMN "timeCode" SET DATA TYPE bigint; diff --git a/backend/drizzle/0005_quick_doorman.sql b/backend/drizzle/0005_quick_doorman.sql deleted file mode 100644 index b5423c014..000000000 --- a/backend/drizzle/0005_quick_doorman.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "team" ALTER COLUMN "timeCode" SET DATA TYPE bigint; \ No newline at end of file diff --git a/backend/drizzle/0006_huge_pride.sql b/backend/drizzle/0006_huge_pride.sql deleted file mode 100644 index 74c6ca589..000000000 --- a/backend/drizzle/0006_huge_pride.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE "userToRole" DROP CONSTRAINT "userToRole_user_id_user_id_fk"; ---> statement-breakpoint -ALTER TABLE "user" ADD COLUMN "birthday" date;--> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToRole" ADD CONSTRAINT "userToRole_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; diff --git a/backend/drizzle/0007_brief_joseph.sql b/backend/drizzle/0007_brief_joseph.sql deleted file mode 100644 index d67f40d39..000000000 --- a/backend/drizzle/0007_brief_joseph.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE IF NOT EXISTS "newstudentUUID" ( - "uiid" uuid PRIMARY KEY NOT NULL, - "isUsed" boolean DEFAULT false NOT NULL, - "user_id" integer NOT NULL -); ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "newstudentUUID" ADD CONSTRAINT "newstudentUUID_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; diff --git a/backend/drizzle/0008_cheerful_titanium_man.sql b/backend/drizzle/0008_cheerful_titanium_man.sql deleted file mode 100644 index c14bd6677..000000000 --- a/backend/drizzle/0008_cheerful_titanium_man.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "newstudentUUID" ALTER COLUMN "uiid" SET DEFAULT gen_random_uuid();--> statement-breakpoint -ALTER TABLE "newstudentUUID" ALTER COLUMN "user_id" DROP NOT NULL; \ No newline at end of file diff --git a/backend/drizzle/0009_awesome_vermin.sql b/backend/drizzle/0009_awesome_vermin.sql deleted file mode 100644 index 5b59e1044..000000000 --- a/backend/drizzle/0009_awesome_vermin.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE "newstudentUUID" RENAME TO "newstudent";--> statement-breakpoint -ALTER TABLE "newstudent" RENAME COLUMN "uiid" TO "uuid";--> statement-breakpoint -ALTER TABLE "newstudent" DROP CONSTRAINT "newstudentUUID_user_id_user_id_fk"; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "newstudent" ADD CONSTRAINT "newstudent_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; diff --git a/backend/drizzle/0010_sad_redwing.sql b/backend/drizzle/0010_sad_redwing.sql deleted file mode 100644 index cf5bb7439..000000000 --- a/backend/drizzle/0010_sad_redwing.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "user" ADD COLUMN "branch" text; \ No newline at end of file diff --git a/backend/drizzle/0011_ambitious_albert_cleary.sql b/backend/drizzle/0011_ambitious_albert_cleary.sql deleted file mode 100644 index 39abad0ff..000000000 --- a/backend/drizzle/0011_ambitious_albert_cleary.sql +++ /dev/null @@ -1,32 +0,0 @@ -CREATE TABLE IF NOT EXISTS "permanence" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "desc" text NOT NULL, - "startingTime" bigint, - "duartion" bigint, - "studenNumber" integer, - CONSTRAINT "permanence_name_unique" UNIQUE("name"), - CONSTRAINT "permanence_desc_unique" UNIQUE("desc") -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "userToPermanence" ( - "user_id" integer NOT NULL, - "perm_id" integer NOT NULL -); ---> statement-breakpoint -ALTER TABLE "faction" RENAME COLUMN "team_name" TO "faction_name";--> statement-breakpoint -ALTER TABLE "faction" DROP CONSTRAINT "faction_team_name_unique";--> statement-breakpoint -ALTER TABLE "user" ADD COLUMN "discord_id" text;--> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToPermanence" ADD CONSTRAINT "userToPermanence_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToPermanence" ADD CONSTRAINT "userToPermanence_perm_id_permanence_id_fk" FOREIGN KEY ("perm_id") REFERENCES "permanence"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -ALTER TABLE "faction" ADD CONSTRAINT "faction_faction_name_unique" UNIQUE("faction_name"); \ No newline at end of file diff --git a/backend/drizzle/0011_jittery_nekra.sql b/backend/drizzle/0011_jittery_nekra.sql deleted file mode 100644 index af4f83d7a..000000000 --- a/backend/drizzle/0011_jittery_nekra.sql +++ /dev/null @@ -1,10 +0,0 @@ -ALTER TABLE "faction" DROP CONSTRAINT "faction_team_name_unique";--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "name" text NOT NULL;--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "desc" text NOT NULL;--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "startingTime" bigint;--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "duartion" bigint;--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "studenNumber" integer;--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "team_name";--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "points";--> statement-breakpoint -ALTER TABLE "faction" ADD CONSTRAINT "faction_name_unique" UNIQUE("name");--> statement-breakpoint -ALTER TABLE "faction" ADD CONSTRAINT "faction_desc_unique" UNIQUE("desc"); \ No newline at end of file diff --git a/backend/drizzle/0012_chilly_squadron_sinister.sql b/backend/drizzle/0012_chilly_squadron_sinister.sql deleted file mode 100644 index b5b17569f..000000000 --- a/backend/drizzle/0012_chilly_squadron_sinister.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE IF NOT EXISTS "permanence" ( - "id" serial PRIMARY KEY NOT NULL, - "name" text NOT NULL, - "desc" text NOT NULL, - "startingTime" text NOT NULL, - "duration" bigint NOT NULL, - "studentNumber" integer NOT NULL, - CONSTRAINT "permanence_name_unique" UNIQUE("name") -); ---> statement-breakpoint -ALTER TABLE "faction" DROP CONSTRAINT "faction_name_unique";--> statement-breakpoint -ALTER TABLE "faction" DROP CONSTRAINT "faction_desc_unique";--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "team_name" text NOT NULL;--> statement-breakpoint -ALTER TABLE "faction" ADD COLUMN "points" integer NOT NULL;--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "name";--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "desc";--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "startingTime";--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "duartion";--> statement-breakpoint -ALTER TABLE "faction" DROP COLUMN IF EXISTS "studenNumber";--> statement-breakpoint -ALTER TABLE "faction" ADD CONSTRAINT "faction_team_name_unique" UNIQUE("team_name"); \ No newline at end of file diff --git a/backend/drizzle/0013_acoustic_gabe_jones.sql b/backend/drizzle/0013_acoustic_gabe_jones.sql deleted file mode 100644 index 45fe12f09..000000000 --- a/backend/drizzle/0013_acoustic_gabe_jones.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE IF NOT EXISTS "userToPermanence" ( - "user_id" integer NOT NULL, - "perm_id" integer NOT NULL -); ---> statement-breakpoint -ALTER TABLE "faction" RENAME COLUMN "team_name" TO "faction_name";--> statement-breakpoint -ALTER TABLE "faction" DROP CONSTRAINT "faction_team_name_unique";--> statement-breakpoint -ALTER TABLE "user" ADD COLUMN "discord_id" text;--> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToPermanence" ADD CONSTRAINT "userToPermanence_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "userToPermanence" ADD CONSTRAINT "userToPermanence_perm_id_permanence_id_fk" FOREIGN KEY ("perm_id") REFERENCES "permanence"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint -ALTER TABLE "faction" ADD CONSTRAINT "faction_faction_name_unique" UNIQUE("faction_name"); \ No newline at end of file diff --git a/backend/drizzle/0014_curved_red_ghost.sql b/backend/drizzle/0014_curved_red_ghost.sql deleted file mode 100644 index e62a5d7ea..000000000 --- a/backend/drizzle/0014_curved_red_ghost.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE "newstudent" DROP CONSTRAINT "newstudent_user_id_user_id_fk"; ---> statement-breakpoint -ALTER TABLE "newstudent" ADD COLUMN "email" text NOT NULL;--> statement-breakpoint -ALTER TABLE "newstudent" DROP COLUMN IF EXISTS "user_id";--> statement-breakpoint -ALTER TABLE "newstudent" ADD CONSTRAINT "newstudent_email_unique" UNIQUE("email"); \ No newline at end of file diff --git a/backend/drizzle/meta/0000_snapshot.json b/backend/drizzle/meta/0000_snapshot.json deleted file mode 100644 index 171618b73..000000000 --- a/backend/drizzle/meta/0000_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "a6eb0ed2-598a-471d-9b78-9f44ceb73ce2", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0001_snapshot.json b/backend/drizzle/meta/0001_snapshot.json deleted file mode 100644 index 622d19e88..000000000 --- a/backend/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "cd373bf5-fb40-4384-a361-f37ea0afc9fb", - "prevId": "a6eb0ed2-598a-471d-9b78-9f44ceb73ce2", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0002_snapshot.json b/backend/drizzle/meta/0002_snapshot.json deleted file mode 100644 index 64e71196e..000000000 --- a/backend/drizzle/meta/0002_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "3abb5177-9b9f-4729-b952-35a89b5f16f7", - "prevId": "cd373bf5-fb40-4384-a361-f37ea0afc9fb", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0003_snapshot.json b/backend/drizzle/meta/0003_snapshot.json deleted file mode 100644 index 8d22e5e57..000000000 --- a/backend/drizzle/meta/0003_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "c72cd2fe-6974-44bb-809b-da4fbdc147c1", - "prevId": "3abb5177-9b9f-4729-b952-35a89b5f16f7", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0004_snapshot.json b/backend/drizzle/meta/0004_snapshot.json deleted file mode 100644 index 23b10dc52..000000000 --- a/backend/drizzle/meta/0004_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "d0fbf3c8-ed48-4086-8660-fe1ca1e984d1", - "prevId": "c72cd2fe-6974-44bb-809b-da4fbdc147c1", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0005_snapshot.json b/backend/drizzle/meta/0005_snapshot.json deleted file mode 100644 index 770059971..000000000 --- a/backend/drizzle/meta/0005_snapshot.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "id": "5ffd61bf-3f96-439b-8c60-a3671ca2d3c3", - "prevId": "d0fbf3c8-ed48-4086-8660-fe1ca1e984d1", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0006_snapshot.json b/backend/drizzle/meta/0006_snapshot.json deleted file mode 100644 index 9692063d6..000000000 --- a/backend/drizzle/meta/0006_snapshot.json +++ /dev/null @@ -1,435 +0,0 @@ -{ - "id": "42ff6a57-5d16-43c8-b669-798912d4d9fa", - "prevId": "5ffd61bf-3f96-439b-8c60-a3671ca2d3c3", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0007_snapshot.json b/backend/drizzle/meta/0007_snapshot.json deleted file mode 100644 index 28e344acf..000000000 --- a/backend/drizzle/meta/0007_snapshot.json +++ /dev/null @@ -1,478 +0,0 @@ -{ - "id": "b487f454-b569-4751-a833-6350af78cff0", - "prevId": "42ff6a57-5d16-43c8-b669-798912d4d9fa", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "newstudentUUID": { - "name": "newstudentUUID", - "schema": "", - "columns": { - "uiid": { - "name": "uiid", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "newstudentUUID_user_id_user_id_fk": { - "name": "newstudentUUID_user_id_user_id_fk", - "tableFrom": "newstudentUUID", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0008_snapshot.json b/backend/drizzle/meta/0008_snapshot.json deleted file mode 100644 index e189996a7..000000000 --- a/backend/drizzle/meta/0008_snapshot.json +++ /dev/null @@ -1,479 +0,0 @@ -{ - "id": "4d4aeed9-4492-4303-92d7-ecae173ed84f", - "prevId": "b487f454-b569-4751-a833-6350af78cff0", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "newstudentUUID": { - "name": "newstudentUUID", - "schema": "", - "columns": { - "uiid": { - "name": "uiid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudentUUID_user_id_user_id_fk": { - "name": "newstudentUUID_user_id_user_id_fk", - "tableFrom": "newstudentUUID", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0009_snapshot.json b/backend/drizzle/meta/0009_snapshot.json deleted file mode 100644 index 66b5690d2..000000000 --- a/backend/drizzle/meta/0009_snapshot.json +++ /dev/null @@ -1,479 +0,0 @@ -{ - "id": "99a03e1c-5053-48e2-994d-4b7d6e8acdd3", - "prevId": "4d4aeed9-4492-4303-92d7-ecae173ed84f", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudent_user_id_user_id_fk": { - "name": "newstudent_user_id_user_id_fk", - "tableFrom": "newstudent", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0010_snapshot.json b/backend/drizzle/meta/0010_snapshot.json deleted file mode 100644 index 30841cd26..000000000 --- a/backend/drizzle/meta/0010_snapshot.json +++ /dev/null @@ -1,485 +0,0 @@ -{ - "id": "b10c3708-4e2a-47ef-9596-b8b1101c53f6", - "prevId": "99a03e1c-5053-48e2-994d-4b7d6e8acdd3", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudent_user_id_user_id_fk": { - "name": "newstudent_user_id_user_id_fk", - "tableFrom": "newstudent", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch": { - "name": "branch", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0011_snapshot.json b/backend/drizzle/meta/0011_snapshot.json deleted file mode 100644 index 6803eb693..000000000 --- a/backend/drizzle/meta/0011_snapshot.json +++ /dev/null @@ -1,662 +0,0 @@ -{ - "id": "fc1d1d52-59e5-4a7d-972f-424eda5d471e", - "prevId": "b10c3708-4e2a-47ef-9596-b8b1101c53f6", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "faction_name": { - "name": "faction_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "desc": { - "name": "desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "startingTime": { - "name": "startingTime", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "duartion": { - "name": "duartion", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "studenNumber": { - "name": "studenNumber", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_name_unique": { - "name": "faction_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - }, - "faction_desc_unique": { - "name": "faction_desc_unique", - "nullsNotDistinct": false, - "columns": [ - "desc" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudent_user_id_user_id_fk": { - "name": "newstudent_user_id_user_id_fk", - "tableFrom": "newstudent", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "permanence": { - "name": "permanence", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "desc": { - "name": "desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "startingTime": { - "name": "startingTime", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "duartion": { - "name": "duartion", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "studenNumber": { - "name": "studenNumber", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "permanence_name_unique": { - "name": "permanence_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - }, - "permanence_desc_unique": { - "name": "permanence_desc_unique", - "nullsNotDistinct": false, - "columns": [ - "desc" - ] - } - } - }, - "userToPermanence": { - "name": "userToPermanence", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "perm_id": { - "name": "perm_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToPermanence_user_id_user_id_fk": { - "name": "userToPermanence_user_id_user_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToPermanence_perm_id_permanence_id_fk": { - "name": "userToPermanence_perm_id_permanence_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "permanence", - "columnsFrom": [ - "perm_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch": { - "name": "branch", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "discord_id": { - "name": "discord_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0012_snapshot.json b/backend/drizzle/meta/0012_snapshot.json deleted file mode 100644 index 164e9fcf0..000000000 --- a/backend/drizzle/meta/0012_snapshot.json +++ /dev/null @@ -1,539 +0,0 @@ -{ - "id": "a4c1bccd-bfb7-4633-ac6c-7f90f62030c3", - "prevId": "fc1d1d52-59e5-4a7d-972f-424eda5d471e", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_team_name_unique": { - "name": "faction_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudent_user_id_user_id_fk": { - "name": "newstudent_user_id_user_id_fk", - "tableFrom": "newstudent", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "permanence": { - "name": "permanence", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "desc": { - "name": "desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "startingTime": { - "name": "startingTime", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "duration": { - "name": "duration", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "studentNumber": { - "name": "studentNumber", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "permanence_name_unique": { - "name": "permanence_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch": { - "name": "branch", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0013_snapshot.json b/backend/drizzle/meta/0013_snapshot.json deleted file mode 100644 index 6f2500e86..000000000 --- a/backend/drizzle/meta/0013_snapshot.json +++ /dev/null @@ -1,594 +0,0 @@ -{ - "id": "ec2d7b66-e8ae-47c3-b24b-ca0950714125", - "prevId": "a4c1bccd-bfb7-4633-ac6c-7f90f62030c3", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "faction_name": { - "name": "faction_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_faction_name_unique": { - "name": "faction_faction_name_unique", - "nullsNotDistinct": false, - "columns": [ - "faction_name" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "newstudent_user_id_user_id_fk": { - "name": "newstudent_user_id_user_id_fk", - "tableFrom": "newstudent", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "permanence": { - "name": "permanence", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "desc": { - "name": "desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "startingTime": { - "name": "startingTime", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "duration": { - "name": "duration", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "studentNumber": { - "name": "studentNumber", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "permanence_name_unique": { - "name": "permanence_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - } - }, - "userToPermanence": { - "name": "userToPermanence", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "perm_id": { - "name": "perm_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToPermanence_user_id_user_id_fk": { - "name": "userToPermanence_user_id_user_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToPermanence_perm_id_permanence_id_fk": { - "name": "userToPermanence_perm_id_permanence_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "permanence", - "columnsFrom": [ - "perm_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch": { - "name": "branch", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "discord_id": { - "name": "discord_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/0014_snapshot.json b/backend/drizzle/meta/0014_snapshot.json deleted file mode 100644 index ed393b4f2..000000000 --- a/backend/drizzle/meta/0014_snapshot.json +++ /dev/null @@ -1,588 +0,0 @@ -{ - "id": "cc69fdb5-5879-4bce-b5a4-791804201abc", - "prevId": "ec2d7b66-e8ae-47c3-b24b-ca0950714125", - "version": "5", - "dialect": "pg", - "tables": { - "challenge": { - "name": "challenge", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "challenge_name": { - "name": "challenge_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "challenge_desc": { - "name": "challenge_desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "challenge_challenge_name_unique": { - "name": "challenge_challenge_name_unique", - "nullsNotDistinct": false, - "columns": [ - "challenge_name" - ] - } - } - }, - "factionTochallenge": { - "name": "factionTochallenge", - "schema": "", - "columns": { - "faction_id": { - "name": "faction_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "challenge_id": { - "name": "challenge_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "factionTochallenge_faction_id_faction_id_fk": { - "name": "factionTochallenge_faction_id_faction_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "faction", - "columnsFrom": [ - "faction_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "factionTochallenge_challenge_id_challenge_id_fk": { - "name": "factionTochallenge_challenge_id_challenge_id_fk", - "tableFrom": "factionTochallenge", - "tableTo": "challenge", - "columnsFrom": [ - "challenge_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "event": { - "name": "event", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "event_name": { - "name": "event_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "state": { - "name": "state", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "event_event_name_unique": { - "name": "event_event_name_unique", - "nullsNotDistinct": false, - "columns": [ - "event_name" - ] - } - } - }, - "faction": { - "name": "faction", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "faction_name": { - "name": "faction_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "points": { - "name": "points", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "faction_faction_name_unique": { - "name": "faction_faction_name_unique", - "nullsNotDistinct": false, - "columns": [ - "faction_name" - ] - } - } - }, - "newstudent": { - "name": "newstudent", - "schema": "", - "columns": { - "uuid": { - "name": "uuid", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "gen_random_uuid()" - }, - "isUsed": { - "name": "isUsed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "newstudent_email_unique": { - "name": "newstudent_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - }, - "permanence": { - "name": "permanence", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "desc": { - "name": "desc", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "startingTime": { - "name": "startingTime", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "duration": { - "name": "duration", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "studentNumber": { - "name": "studentNumber", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "permanence_name_unique": { - "name": "permanence_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - } - }, - "userToPermanence": { - "name": "userToPermanence", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "perm_id": { - "name": "perm_id", - "type": "integer", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToPermanence_user_id_user_id_fk": { - "name": "userToPermanence_user_id_user_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToPermanence_perm_id_permanence_id_fk": { - "name": "userToPermanence_perm_id_permanence_id_fk", - "tableFrom": "userToPermanence", - "tableTo": "permanence", - "columnsFrom": [ - "perm_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "role": { - "name": "role", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "role_name": { - "name": "role_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "role_desc": { - "name": "role_desc", - "type": "text", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "role_role_name_unique": { - "name": "role_role_name_unique", - "nullsNotDistinct": false, - "columns": [ - "role_name" - ] - } - } - }, - "userToRole": { - "name": "userToRole", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "role_id": { - "name": "role_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "isWish": { - "name": "isWish", - "type": "boolean", - "primaryKey": false, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": { - "userToRole_user_id_user_id_fk": { - "name": "userToRole_user_id_user_id_fk", - "tableFrom": "userToRole", - "tableTo": "user", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "userToRole_role_id_role_id_fk": { - "name": "userToRole_role_id_role_id_fk", - "tableFrom": "userToRole", - "tableTo": "role", - "columnsFrom": [ - "role_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {} - }, - "team": { - "name": "team", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "isOfficial": { - "name": "isOfficial", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "timeCode": { - "name": "timeCode", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "team_name": { - "name": "team_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "city_id": { - "name": "city_id", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "team_city_id_faction_id_fk": { - "name": "team_city_id_faction_id_fk", - "tableFrom": "team", - "tableTo": "faction", - "columnsFrom": [ - "city_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "team_team_name_unique": { - "name": "team_team_name_unique", - "nullsNotDistinct": false, - "columns": [ - "team_name" - ] - } - } - }, - "user": { - "name": "user", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "first_name": { - "name": "first_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_name": { - "name": "last_name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "branch": { - "name": "branch", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "birthday": { - "name": "birthday", - "type": "date", - "primaryKey": false, - "notNull": false - }, - "contact": { - "name": "contact", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "discord_id": { - "name": "discord_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "connection_num": { - "name": "connection_num", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "permission": { - "name": "permission", - "type": "permission", - "primaryKey": false, - "notNull": true - }, - "password": { - "name": "password", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "team": { - "name": "team", - "type": "integer", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "user_team_team_id_fk": { - "name": "user_team_team_id_fk", - "tableFrom": "user", - "tableTo": "team", - "columnsFrom": [ - "team" - ], - "columnsTo": [ - "id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "user_email_unique": { - "name": "user_email_unique", - "nullsNotDistinct": false, - "columns": [ - "email" - ] - } - } - } - }, - "enums": { - "permission": { - "name": "permission", - "values": { - "newStudent": "newStudent", - "Student": "Student", - "Admin": "Admin", - "RespoCE": "RespoCE", - "Respo": "Respo", - "Anim": "Anim" - } - } - }, - "schemas": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/backend/drizzle/meta/_journal.json b/backend/drizzle/meta/_journal.json deleted file mode 100644 index 504350482..000000000 --- a/backend/drizzle/meta/_journal.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "version": "5", - "dialect": "pg", - "entries": [ - { - "idx": 0, - "version": "5", - "when": 1712611554924, - "tag": "0000_luxuriant_mandrill", - "breakpoints": true - }, - { - "idx": 1, - "version": "5", - "when": 1713011110190, - "tag": "0001_bright_strong_guy", - "breakpoints": true - }, - { - "idx": 2, - "version": "5", - "when": 1713011230279, - "tag": "0002_large_mulholland_black", - "breakpoints": true - }, - { - "idx": 3, - "version": "5", - "when": 1713011739381, - "tag": "0003_odd_beyonder", - "breakpoints": true - }, - { - "idx": 4, - "version": "5", - "when": 1713011834737, - "tag": "0004_fluffy_kate_bishop", - "breakpoints": true - }, - { - "idx": 5, - "version": "5", - "when": 1713020099457, - "tag": "0005_quick_doorman", - "breakpoints": true - }, - { - "idx": 6, - "version": "5", - "when": 1718178424536, - "tag": "0006_huge_pride", - "breakpoints": true - }, - { - "idx": 7, - "version": "5", - "when": 1718916126040, - "tag": "0007_brief_joseph", - "breakpoints": true - }, - { - "idx": 8, - "version": "5", - "when": 1718920925767, - "tag": "0008_cheerful_titanium_man", - "breakpoints": true - }, - { - "idx": 9, - "version": "5", - "when": 1719818625531, - "tag": "0009_awesome_vermin", - "breakpoints": true - }, - { - "idx": 10, - "version": "5", - "when": 1720111045424, - "tag": "0010_sad_redwing", - "breakpoints": true - }, - { - "idx": 11, - "version": "5", - "when": 1720700501555, - "tag": "0011_jittery_nekra", - "breakpoints": true - }, - { - "idx": 12, - "version": "5", - "when": 1721050358124, - "tag": "0012_chilly_squadron_sinister", - "breakpoints": true - }, - { - "idx": 13, - "version": "5", - "when": 1721069761838, - "tag": "0013_acoustic_gabe_jones", - "breakpoints": true - }, - { - "idx": 14, - "version": "5", - "when": 1722348395029, - "tag": "0014_curved_red_ghost", - "breakpoints": true - }, - { - "idx": 15, - "version": "5", - "when": 1722548656065, - "tag": "0015_confused_magik", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/backend/drizzle/migration/migrate.ts b/backend/drizzle/migration/migrate.ts deleted file mode 100644 index de5cc2202..000000000 --- a/backend/drizzle/migration/migrate.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Pool } from "pg"; -import { drizzle } from "drizzle-orm/node-postgres"; -import { migrate } from "drizzle-orm/node-postgres/migrator"; -import dotenv from "dotenv"; - -dotenv.config() - -const pool = new Pool({ - connectionString: process.env.OUTSIDE_DATABASE_URL, -}); - - -const db = drizzle(pool); - -export async function main() { - await migrate(db, { migrationsFolder: "drizzle" }); - pool.end(); - process.exit(0); -} - -main().catch((err) => { - console.log(err); - process.exit(0); -}); \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json index 69fb8e8d7..077667896 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -16,6 +16,7 @@ "axios": "^1.6.8", "bcryptjs": "^2.4.3", "cors": "^2.8.5", + "csv-parser": "^3.0.0", "dotenv": "^16.4.1", "drizzle-orm": "^0.29.3", "express": "^4.18.2", @@ -25,7 +26,7 @@ "nodemailer": "^6.9.14", "nodemon": "^3.0.3", "papaparse": "^5.4.1", - "pg": "^8.11.3", + "pg": "^8.12.0", "pg-promise": "^11.5.4", "postgres": "^3.4.3", "querystring": "^0.2.1", @@ -1490,6 +1491,21 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" }, + "node_modules/csv-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz", + "integrity": "sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "csv-parser": "bin/csv-parser" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/d": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/d/-/d-1.0.2.tgz", @@ -2907,6 +2923,7 @@ "version": "8.12.0", "resolved": "https://registry.npmjs.org/pg/-/pg-8.12.0.tgz", "integrity": "sha512-A+LHUSnwnxrnL/tZ+OLfqR1SxLN3c/pgDztZ47Rpbsd4jUytsTtwQo/TLPRzPJMp/1pbhYVhH9cuSZLAajNfjQ==", + "license": "MIT", "dependencies": { "pg-connection-string": "^2.6.4", "pg-pool": "^3.6.2", diff --git a/backend/package.json b/backend/package.json index dfd478612..11f53eeb3 100644 --- a/backend/package.json +++ b/backend/package.json @@ -22,6 +22,7 @@ "axios": "^1.6.8", "bcryptjs": "^2.4.3", "cors": "^2.8.5", + "csv-parser": "^3.0.0", "dotenv": "^16.4.1", "drizzle-orm": "^0.29.3", "express": "^4.18.2", @@ -31,7 +32,7 @@ "nodemailer": "^6.9.14", "nodemon": "^3.0.3", "papaparse": "^5.4.1", - "pg": "^8.11.3", + "pg": "^8.12.0", "pg-promise": "^11.5.4", "postgres": "^3.4.3", "querystring": "^0.2.1", diff --git a/backend/src/controllers/challenge.controller.ts b/backend/src/controllers/challenge.controller.ts index 809fd72a8..db7444ee5 100644 --- a/backend/src/controllers/challenge.controller.ts +++ b/backend/src/controllers/challenge.controller.ts @@ -1,22 +1,142 @@ import { Request, Response, NextFunction } from 'express'; import * as service from '../services/challenge.service'; import { Error, Created, Ok } from '../utils/responses'; +import {getAllChallenges, getChallengeFromIds} from "../utils/challenge"; +import {NoUser} from "../error/user"; +import {getCompletedChallengesForCe, getCompletedChallengesForFaction} from "../services/challenge.service"; -export const getAllChallenges = async (req: Request, res: Response, next: NextFunction) => { +export const getAllChallengesInDb = async (req: Request, res: Response, next: NextFunction) => { try { - const data = await service.getAllChallenges(); + const data = await getAllChallenges(); Ok(res, { data }); } catch (error) { Error(res, { error }); } } +export const getAllCeChallenges = async (req: Request, res: Response, next: NextFunction) => { + try { + const {filter, associatedId} = req.body + switch (filter) { + case "available": return Ok(res, { data: await service.getAvailableChallengeForCe(associatedId) } ) + case "completed": return Ok(res, { data: await getChallengeFromIds(await service.getCompletedChallengesForStudent(associatedId)) } ) + case "all": return Ok(res, { data: await service.getAllCeChallenges() } ) + default: Error(res, {msg: "filter '" + filter + "' do not exist."}) + } + } catch (error) { + Error(res, { error }); + } +} + +export const getAllFreeChallenges = async (req: Request, res: Response, next: NextFunction) => { + try { + const data = await service.getAllFreeChallenges(); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + +export const validChallenge = async (req: Request, res: Response, next: NextFunction) => { + try { + const {challId, associatedId, attributedPoints, text} = req.body + const data = await service.validateChallenge(challId, associatedId, attributedPoints, text); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + +export const validFreeChallenge = async (req: Request, res: Response, next: NextFunction) => { + try { + const {associatedId, attributedPoints, text} = req.body + const data = await service.freeChallengeToFaction(associatedId, attributedPoints, text); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + +export const getAllFreeText = async (req: Request, res: Response, next: NextFunction) => { + try { + const {factionId} = req.body + const data = await service.getFreeChallenges(factionId); + const response = data.map(value => value.text) + Ok(res, {data: response}); + } catch (error) { + Error(res, { error }); + } +} + +export const unvalidChallenge = async (req: Request, res: Response, next: NextFunction) => { + try { + const {challId, associatedId} = req.body + const data = await service.unvalidateChallenge(challId, associatedId); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + +export const unvalidFreeChallenge = async (req: Request, res: Response, next: NextFunction) => { + try { + const {factionId, text} = req.body + const data = await service.unvalidateToFaction(text, factionId); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + +export const getAllStudentChallenges = async (req: Request, res: Response, next: NextFunction) => { + try { + const {filter, associatedId} = req.body + switch (filter) { + case "available": return Ok(res, { data: await service.getAvailableChallengeForStudent(associatedId) } ) + case "completed": return Ok(res, { data: await getChallengeFromIds(await service.getCompletedChallengesForStudent(associatedId)) } ) + case "all": return Ok(res, { data: await service.getAllStudentChallenges() } ) + default: Error(res, {msg: "filter '" + filter + "' do not exist."}) + } + } catch (error) { + Error(res, { error }); + } +} + +export const getAllFactionChallenges = async (req: Request, res: Response, next: NextFunction) => { + try { + const {filter, associatedId} = req.body + console.log("filter: " + filter + " id: " + associatedId) + switch (filter) { + case "available": return Ok(res, { data: await service.getAvailableChallengeForFaction(associatedId) } ) + case "completed": return Ok(res, { data: await getChallengeFromIds(await service.getCompletedChallengesForFaction(associatedId)) } ) + case "all": return Ok(res, { data: await service.getAllFactionChallenges() } ) + default: Error(res, {msg: "filter '" + filter + "' do not exist."}) + } + } catch (error) { + Error(res, { error }); + } +} + +export const getAllTeamChallenges = async (req: Request, res: Response, next: NextFunction) => { + try { + const {filter, associatedId} = req.body + switch (filter) { + case "available": return Ok(res, { data: await service.getAvailableChallengeForTeam(associatedId) } ) + case "completed": return Ok(res, { data: await getChallengeFromIds(await service.getCompletedChallengesForTeam(associatedId)) } ) + case "all": return Ok(res, { data: await service.getAllTeamChallenges() } ) + default: Error(res, {msg: "filter '" + filter + "' do not exist."}) + } + } catch (error) { + Error(res, { error }); + } +} + export const createChallenge = async (req: Request, res: Response, next: NextFunction) => { const { name, desc, points } = req.body; name ?? Error(res, { msg: "No name" }); try { - await service.createChallenge(name, desc, points); + //await service.createChallenge(name, desc, points); Created(res, {}) } catch (error) { Error(res, { error }); @@ -38,12 +158,93 @@ export const deleteChallenge = async (req: Request, res: Response, next: NextFun }; export const validateChallenge = async (req: Request, res: Response, next: NextFunction) => { - const { challengeId, factionId } = req.body; + const { challengeId, associatedId, points, text } = req.body; try { - await service.validateChallenge(challengeId, factionId); + await service.validateChallenge(challengeId, associatedId, points, text); Ok(res, { msg: "challenge validated" }); } catch (error) { Error(res, { error }); } } + +export const getAvailableChallengeForTeam = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await service.getAvailableChallengeForTeam(associatedId); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const getAvailableChallengeForFaction = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await service.getAvailableChallengeForFaction(associatedId); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const getAvailableChallengeForStudent = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await service.getAvailableChallengeForStudent(associatedId); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const getCompletedChallengeForTeam = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await getChallengeFromIds(await service.getCompletedChallengesForTeam(associatedId)); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const getCompletedChallengeForFaction = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await getChallengeFromIds(await service.getCompletedChallengesForFaction(associatedId)); + console.log(data) + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const getCompletedChallengeForStudent = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await getChallengeFromIds(await service.getCompletedChallengesForStudent(associatedId)); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const countPointsForTeam = async (req: Request, res: Response, next: NextFunction) => { + const { associatedId } = req.body; + try { + const data = await service.countPointsForTeam(associatedId); + Ok(res, { data: data, msg: "OK" }); + } catch (error) { + Error(res, { error }); + } +} + +export const countPoints = async (req: Request, res: Response, next: NextFunction) => { + + try { + const points = [await service.countPoints(1), await service.countPoints(2)] + Ok(res, {data: points}); + } catch (error) { + Error(res, { error }); + } +} \ No newline at end of file diff --git a/backend/src/controllers/team.controller.ts b/backend/src/controllers/team.controller.ts index f8f63a38d..541674ec1 100644 --- a/backend/src/controllers/team.controller.ts +++ b/backend/src/controllers/team.controller.ts @@ -15,10 +15,21 @@ export const getAllTeams = async (req: Request, res: Response, next: NextFunctio } } +export const getAllTeamsWithPoints = async (req: Request, res: Response, next: NextFunction) => { + console.log("fetch teamdezbyfuezvfuerfyzu") + try { + console.log("fetch team") + const data = await service.getAllTeamsWithPoints(); + Ok(res, { data }); + } catch (error) { + console.log("error") + Error(res, { error }); + } +} + export const getTeam = async (req: Request, res: Response, next: NextFunction) => { const { id } = req.params; const idNumber = parseInt(id, 10); - if (isNaN(idNumber)) return Error(res, { msg : 'Could not parse Id' }); try { @@ -45,7 +56,6 @@ export const createTeam = async (req: Request, res: Response, next: NextFunction export const deleteTeam = async (req: Request, res: Response, next: NextFunction) => { const { id } = req.params; const idNumber = parseInt(id, 10); - if (isNaN(idNumber)) return Error(res, { msg : 'could not parse Id' }); try { diff --git a/backend/src/controllers/user.controller.ts b/backend/src/controllers/user.controller.ts index 13850fc53..a809bdd91 100644 --- a/backend/src/controllers/user.controller.ts +++ b/backend/src/controllers/user.controller.ts @@ -14,6 +14,15 @@ export const getAllUsers = async (req: Request, res: Response, next: NextFunctio } } +export const getAllCe = async (req: Request, res: Response, next: NextFunction) => { + try { + const data = await service.getAllCe(); + Ok(res, { data }); + } catch (error) { + Error(res, { error }); + } +} + export const getAllByPermission= async (req: Request, res: Response, next: NextFunction) => { const {permission} = req.params; @@ -129,6 +138,16 @@ export const addContact = async (req: Request, res: Response, next: NextFunction } }; +export const getInfo = async (req: Request, res: Response, next: NextFunction) => { + const { email } = req.body + try { + const data = await service.getInfo(email) + Ok(res, {data: data, msg: "Ok"}) + } catch (error) { + Error(res, { error }) + } +} + export const changePermission = async (req: Request, res: Response, next: NextFunction) => { const { id, perm } = req.body; diff --git a/backend/src/error/user.ts b/backend/src/error/user.ts new file mode 100644 index 000000000..72bb17b5a --- /dev/null +++ b/backend/src/error/user.ts @@ -0,0 +1,5 @@ + + +export const NoUser = (id: number) => new Error("No user with id '" + id + "'") +export const NoTeam = (id: number | null) => new Error("No team with id '" + id + "'") +export const NoFaction = (id: number) => new Error("No faction with id '" + id + "'") \ No newline at end of file diff --git a/backend/src/middlewares/permissions.ts b/backend/src/middlewares/permissions.ts index 09874eb5e..d8841a341 100644 --- a/backend/src/middlewares/permissions.ts +++ b/backend/src/middlewares/permissions.ts @@ -42,6 +42,26 @@ export const isAdminCE = async (req: Request, res: Response, next: NextFunction) } }; +//TODO: create anim perm +export const isAdminAnim = async (req: Request, res: Response, next: NextFunction) => { + try { + const decodedToken = decodeToken(req); + const user = await getUserByEmail(decodedToken.email); + + if (user === null) { + return Error(res, { msg: "user doesn't exists" }); + } + + if (user.permission === PermType.Admin || user.permission === PermType.RespoCE) { + next(); + } else { + Error(res, { msg: 'Forbidden: Insufficient permissions' }); + } + } catch (error) { + return Error(res, { msg: 'Unauthorized: Invalid token' }); + } +}; + export const isTokenValid = async (req: Request, res: Response, next: NextFunction) => { try { const token = req.headers['authorization']?.split(' ')[1]; diff --git a/backend/src/routes/challenge.routes.ts b/backend/src/routes/challenge.routes.ts new file mode 100644 index 000000000..a7b3b2b07 --- /dev/null +++ b/backend/src/routes/challenge.routes.ts @@ -0,0 +1,27 @@ +import express from 'express'; +import * as fc from '../controllers/challenge.controller'; +import {isAdmin, isAdminAnim, isAdminCE, isTokenValid} from '../middlewares/permissions'; + +const challengeRouter = express.Router(); + +challengeRouter.get('/countPoints', isAdminAnim, fc.countPoints); +challengeRouter.get('/countPointsForTeam', isAdminAnim, fc.countPointsForTeam); +challengeRouter.get('/all', fc.getAllChallengesInDb); +challengeRouter.post('/valid', isAdminAnim, fc.validChallenge); +challengeRouter.post('/validFree', isAdminAnim, fc.validFreeChallenge); +challengeRouter.post('/getCompletedForTeam', isAdminAnim, fc.getCompletedChallengeForTeam); +challengeRouter.post('/getCompletedForFaction', isAdminAnim, fc.getCompletedChallengeForFaction); +challengeRouter.post('/getCompletedForStudent', isAdminAnim, fc.getCompletedChallengeForStudent); +challengeRouter.post('/getAvailableForTeam', isAdminAnim, fc.getAvailableChallengeForTeam); +challengeRouter.post('/getAvailableForStudent', isTokenValid, fc.getAvailableChallengeForStudent); +challengeRouter.post('/getAvailableForFaction', isAdminAnim, fc.getAvailableChallengeForFaction); +challengeRouter.post('/unvalid', isAdminAnim, fc.unvalidChallenge); +challengeRouter.post('/unvalidFree', isAdminAnim, fc.unvalidFreeChallenge); +challengeRouter.post('/allFreeText', isAdminAnim, fc.getAllFreeText) +challengeRouter.post('/allFaction', fc.getAllFactionChallenges); +challengeRouter.post('/allStudent', fc.getAllStudentChallenges); +challengeRouter.post('/allTeam', fc.getAllTeamChallenges); +challengeRouter.post('/allStudentOrCe', fc.getAllCeChallenges); +challengeRouter.post('/allFree', fc.getAllFreeChallenges); + +export default challengeRouter; \ No newline at end of file diff --git a/backend/src/routes/team.routes.ts b/backend/src/routes/team.routes.ts index cc2023d60..aaa0aa1d9 100644 --- a/backend/src/routes/team.routes.ts +++ b/backend/src/routes/team.routes.ts @@ -7,7 +7,8 @@ const teamRouter = express.Router(); teamRouter.post('/register',isTokenValid, tc.registerTeam); teamRouter.post('', isAdminCE, tc.createTeam); teamRouter.get('/all',isTokenValid, tc.getAllTeams); -teamRouter.get('/:id',isTokenValid, tc.getTeam); +teamRouter.get('/teamsWithPoints', isTokenValid, tc.getAllTeamsWithPoints); +teamRouter.get('/:id', isAdminCE, tc.getTeam); teamRouter.delete('/:id', isAdminCE, tc.deleteTeam); teamRouter.put('/addtofaction', isAdminCE, tc.addToFaction); teamRouter.put('/timestamp',isTokenValid, tc.addTimestamp); diff --git a/backend/src/routes/user.routes.ts b/backend/src/routes/user.routes.ts index 817489bd5..703a112d6 100644 --- a/backend/src/routes/user.routes.ts +++ b/backend/src/routes/user.routes.ts @@ -5,6 +5,7 @@ import { isAdmin, isAdminCE, isTokenValid } from '../middlewares/permissions'; const userRouter = express.Router(); userRouter.get('/all', isAdminCE, sc.getAllUsers); +userRouter.get('/ce/all', isAdminCE, sc.getAllCe); userRouter.get('/user/:id', isAdminCE, sc.getUser); userRouter.delete('/delete/:id', isAdmin, sc.deleteUser); userRouter.put('/addtoteam', isAdminCE, sc.addToTeam); @@ -17,6 +18,7 @@ userRouter.get('/getbyteam/:teamId',isAdmin ,sc.getUserbyTeam); userRouter.post('/modifyteam', isAdmin, sc.modifyTeam); userRouter.get('/allbypermission/:permission', isAdmin, sc.getAllByPermission); userRouter.get('/isinrilist/:email', sc.isInRILIst); +userRouter.post('/getInfo', isAdmin, sc.getInfo); export default userRouter; \ No newline at end of file diff --git a/backend/src/schemas/challenge.schema.ts b/backend/src/schemas/challenge.schema.ts index e581dc2d2..e0e94a200 100644 --- a/backend/src/schemas/challenge.schema.ts +++ b/backend/src/schemas/challenge.schema.ts @@ -1,11 +1,50 @@ -import { pgTable, serial, text, integer } from "drizzle-orm/pg-core"; +import {pgTable, serial, text, integer, pgEnum} from "drizzle-orm/pg-core"; import { factionSchema } from "./faction.schema"; +import {newstudentSchema} from "./newstudent.schema"; +import { primaryKey } from 'drizzle-orm/pg-core'; +import {userSchema} from "./user.schema"; +import {teamSchema} from "./team.schema"; + +export enum ChallengeType { + Student = 'Student', + StudentOrCe = 'StudentOrCe', + Team = 'Team', // peut tout faire + Faction = 'Faction', // peut creer des équipes + Free = 'Free' //peut voir les perms +} + +const challengeTypeEnum = pgEnum('challenge_type', [ + ChallengeType.Student, + ChallengeType.StudentOrCe, + ChallengeType.Team, + ChallengeType.Faction, + ChallengeType.Free, +]); + + +export const parseChallType = (chall: string): ChallengeType | undefined => { + switch (chall) { + case 'Student': + return ChallengeType.Student; + case 'StudentOrCe': + return ChallengeType.StudentOrCe; + case 'Team': + return ChallengeType.Team; + case 'Faction': + return ChallengeType.Faction; + case 'Free': + return ChallengeType.Free; + default: + return undefined; + } +} export const challengeSchema = pgTable('challenge', { id: serial('id').primaryKey(), name: text('challenge_name').notNull().unique(), description: text('challenge_desc').notNull(), - points: integer('points').notNull(), + points: text('points').notNull(), + challType: challengeTypeEnum('chall_type').notNull() }); export type challenge = typeof challengeSchema.$inferInsert; @@ -13,6 +52,37 @@ export type challenge = typeof challengeSchema.$inferInsert; export const factionTochallengeSchema = pgTable('factionTochallenge', { factionId: integer('faction_id').notNull().references(() => factionSchema.id), challengeId: integer('challenge_id').notNull().references(() => challengeSchema.id), -}); + attributedPoints: integer('attributed_points').notNull(), +}, (table) => ({ + pk: primaryKey(table.factionId, table.challengeId) // Clé primaire composite +})); export type factionTochallenge = typeof factionTochallengeSchema.$inferInsert; + +export const TeamTochallengeSchema = pgTable('teamTochallenge', { + teamId: integer('team_id').notNull().references(() => teamSchema.id), + challengeId: integer('challenge_id').notNull().references(() => challengeSchema.id), + attributedPoints: integer('attributed_points').notNull(), +}, (table) => ({ + pk: primaryKey(table.teamId, table.challengeId) // Clé primaire composite +})); + +export type teamTochallenge = typeof TeamTochallengeSchema.$inferInsert; + +export const StudentTochallengeSchema = pgTable('studentTochallenge', { + studentId: integer('student_id').notNull().references(() => userSchema.id), + challengeId: integer('challenge_id').notNull().references(() => challengeSchema.id), + attributedPoints: integer('attributed_points').notNull(), +}, (table) => ({ + pk: primaryKey(table.studentId, table.challengeId) // Clé primaire composite +})); + +export type studentTochallenge = typeof StudentTochallengeSchema.$inferInsert; + +export const FreeToChallengeSchema = pgTable('freeToChallenge', { + factionId: integer('faction_id').notNull().references(() => factionSchema.id), + text: text('text').notNull(), + attributedPoints: integer('attributed_points').notNull(), +}); + +export type freeToChallenge = typeof StudentTochallengeSchema.$inferInsert; diff --git a/backend/src/server.ts b/backend/src/server.ts index 542e41e64..e413a0ac8 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -12,6 +12,7 @@ import { init } from "./database/init"; import { api_prefix } from "./utils/secret"; import { log } from "./middlewares/log"; import emailRouter from "./routes/email.routes"; +import challengeRouter from "./routes/challenge.routes"; async function startServer() { const app = express(); @@ -26,6 +27,7 @@ async function startServer() { router.use("/user", userRouter); router.use("/team", teamRouter); router.use("/permanence", permanenceRouter); + router.use("/challenge", challengeRouter); router.use("/faction", factionRouter); router.use("/role", roleRouter); router.use("/event", eventRouter); diff --git a/backend/src/services/auth.service.ts b/backend/src/services/auth.service.ts index 15f1b1425..c2698f109 100644 --- a/backend/src/services/auth.service.ts +++ b/backend/src/services/auth.service.ts @@ -11,12 +11,13 @@ export const validateCASTicket = async (ticket : string) => { const response = await fetch(validateUrl); if (response.ok) { const text = await response.text(); + console.log("====================validateCASTicket") + console.log(text) + console.log("validateCASTicket====================") const isValid = text.includes("authenticationSuccess"); if (isValid) { // User is authenticated return await parseUsernameFromCASResponse(text); - - } else { console.error("CAS ticket validation failed"); } diff --git a/backend/src/services/challenge.service.ts b/backend/src/services/challenge.service.ts index 95649bf59..eb295cb2c 100644 --- a/backend/src/services/challenge.service.ts +++ b/backend/src/services/challenge.service.ts @@ -1,16 +1,85 @@ -import { challengeSchema, challenge, factionTochallengeSchema, factionTochallenge } from "../schemas/challenge.schema" -import { addPoints } from "./faction.service" -import { db } from "../database/db" -import { eq } from 'drizzle-orm' +import { + challenge, + challengeSchema, + ChallengeType, + factionTochallengeSchema, + FreeToChallengeSchema, + StudentTochallengeSchema, + TeamTochallengeSchema +} from "../schemas/challenge.schema" +import {addPoints, removePoints} from "./faction.service" +import {db} from "../database/db" +import {and, eq} from 'drizzle-orm' +import {PermType, userSchema} from "../schemas/user.schema"; +import {teamSchema} from "../schemas/team.schema"; +import {factionSchema} from "../schemas/faction.schema"; +import { + getAllChallenges, + getAllChallengesExcept, + getChallengeFromIds, getChallengesOf, + getFactionFromTeam, + getFactionFromUserId, + getTeamAndFactionFromUserId, isCE +} from "../utils/challenge"; +import {NoFaction} from "../error/user"; -export const getAllChallenges = async () => { +export const getAllFactionChallenges = async () => { try { - return await db.select().from(challengeSchema); + return await db.select().from(challengeSchema).where(eq(challengeSchema.challType, ChallengeType.Faction)); } catch (error) { throw new Error("Failed to fetch challenges. Please try again later."); } } +export const getAllStudentOrCeChallenges = async () => { + try { + return await db.select().from(challengeSchema).where(eq(challengeSchema.challType, ChallengeType.StudentOrCe)); + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getAllTeamChallenges = async () => { + try { + return await db.select().from(challengeSchema).where(eq(challengeSchema.challType, ChallengeType.Team)); + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getAllStudentChallenges = async () => { + try { + return await db.select().from(challengeSchema).where(eq(challengeSchema.challType, ChallengeType.Student)); + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getAllCeChallenges = async () => { + try { + return await db.select().from(challengeSchema).where(eq(challengeSchema.challType, ChallengeType.StudentOrCe)); + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getAllFreeChallenges = async () => { + try { + return await db.select().from(FreeToChallengeSchema) + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getFreeChallenges = async (factionId: number) => { + try { + return await db.select().from(FreeToChallengeSchema).where(eq(FreeToChallengeSchema.factionId, factionId)) + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + + export const getChallenge = async (id: number) => { try { const chall = await db.select().from(challengeSchema).where(eq(challengeSchema.id, id)) @@ -20,8 +89,170 @@ export const getChallenge = async (id: number) => { } } -export const createChallenge = async (name: string, description: string, points: number) => { - const newChallenge: challenge = { name, description, points}; +export const getFactionChallenges = async (factionId: number) => { + try { + const challs = await db.select().from(factionTochallengeSchema).where(eq(factionTochallengeSchema.factionId, factionId)) + return challs; + } catch (error) { + throw new Error("Failed to fetch challenges. Please try again later."); + } +} + +export const getCompletedChallengesForFaction = async (factionId: number): Promise => { + const factionChallenges = await db.select().from(factionTochallengeSchema).where(eq(factionTochallengeSchema.factionId, factionId)) + return factionChallenges.map(chall => chall.challengeId) +} + +export const getCompletedChallengesForTeam = async (teamId: number): Promise => { + const factionId = await getFactionFromTeam(teamId) + const teamChallenges = await db.select().from(TeamTochallengeSchema).where(eq(TeamTochallengeSchema.teamId, teamId)) + const teamChallengeIds = teamChallenges.map(chall => chall.challengeId); + const factionChallenges = await getCompletedChallengesForFaction(factionId) + return [...factionChallenges, ...teamChallengeIds] +} + +export const getCompletedChallengesForStudent = async (studentId: number): Promise => { + const ids = await getTeamAndFactionFromUserId(studentId) + //get regular studentToChallenge + const studentChallenges = await db.select().from(StudentTochallengeSchema).where(eq(StudentTochallengeSchema.studentId, studentId)) + const studentChallengesIds = studentChallenges.map(chall => chall.challengeId) + const teamChallenges = await getCompletedChallengesForTeam(ids.teamId) + const factionChallenges = await getCompletedChallengesForFaction(ids.factionId) + return [...studentChallengesIds, ...teamChallenges, ...factionChallenges] +} + +export const getCompletedChallengesForCe = async (studentId: number): Promise => { + const ids = await getTeamAndFactionFromUserId(studentId) + //get regular studentToChallenge + const studentChallenges = await db.select().from(StudentTochallengeSchema).where(eq(StudentTochallengeSchema.studentId, studentId)) + const studentChallengesIds = studentChallenges.map(chall => chall.challengeId) + const teamChallenges = await getCompletedChallengesForTeam(ids.teamId) + const factionChallenges = await getCompletedChallengesForFaction(ids.factionId) + return [...studentChallengesIds, ...teamChallenges, ...factionChallenges] +} + +export const getAvailableChallengeForStudent = async (studentId: number): Promise => { + const ids = await getTeamAndFactionFromUserId(studentId) + //test if he is CE + let completedChallengesIds = [] + if(await isCE(studentId)) { + completedChallengesIds = + [ + ...await getCompletedChallengesForCe(studentId), + ...await getCompletedChallengesForTeam(ids.teamId), + ...await getCompletedChallengesForFaction(ids.factionId) + ] + } else { + completedChallengesIds = + [ + ...await getCompletedChallengesForStudent(studentId), + ...await getCompletedChallengesForTeam(ids.teamId), + ...await getCompletedChallengesForFaction(ids.factionId) + ] + } + const allChallenges = await getAllChallenges() + const allChallengesIds = allChallenges.map(chall => chall.id as number) + const availableChallengeIds = allChallengesIds.filter(id => !completedChallengesIds.includes(id)); + return getChallengeFromIds(availableChallengeIds) +} + +export const getAvailableChallengeForCe = async (studentId: number): Promise => { + const ids = await getTeamAndFactionFromUserId(studentId) + const completedChallengesIds = + [ + ...await getCompletedChallengesForCe(studentId), + ...await getCompletedChallengesForTeam(ids.teamId), + ...await getCompletedChallengesForFaction(ids.factionId) + ] + const allChallenges = await getAllCeChallenges() + const allChallengesIds = allChallenges.map(chall => chall.id as number) + const availableChallengeIds = allChallengesIds.filter(id => !completedChallengesIds.includes(id)); + return getChallengeFromIds(availableChallengeIds) +} + +export const getAvailableChallengeForTeam = async (teamId: number): Promise => { + const factionId = await getFactionFromTeam(teamId) + const completedChallengesIds = [ + ...await getCompletedChallengesForTeam(teamId), + ...await getCompletedChallengesForFaction(factionId) + ] + const allChallenges = await getAllChallengesExcept(ChallengeType.Student) + const allChallengesIds = allChallenges.map(chall => chall.id as number) + const availableChallengeIds = allChallengesIds.filter(id => !completedChallengesIds.includes(id)); + return getChallengeFromIds(availableChallengeIds) +} + +export const getAvailableChallengeForFaction = async (factionId: number): Promise => { + const completedChallengesIds = await getCompletedChallengesForFaction(factionId) + console.log("completed: " + completedChallengesIds) + const allChallenges = await getChallengesOf(ChallengeType.Faction) + const allChallengesIds = allChallenges.map(chall => chall.id as number) + const availableChallengeIds = allChallengesIds.filter(id => !completedChallengesIds.includes(id)); + console.log("available: " + availableChallengeIds) + return getChallengeFromIds(availableChallengeIds) +} + +export const countPoints = async (factionId: number): Promise => { + //checking faction exist + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, factionId)); + if(!faction || faction.length === 0) throw NoFaction(factionId) + + let points = 0; + + //getting free challenges + const freeChallenges = await db.select().from(FreeToChallengeSchema).where(eq(FreeToChallengeSchema.factionId, factionId)) + freeChallenges.forEach(chall => points += chall.attributedPoints) + + //getting every challenge associated with faction + const factionChallenges = await db.select().from(factionTochallengeSchema).where(eq(factionTochallengeSchema.factionId, factionId)) + factionChallenges.forEach(challenge => points += challenge.attributedPoints) + + //getting every teamId who is associated with factionId + const factionTeams = await db.select().from(teamSchema).where(eq(teamSchema.faction, factionId)) + const teamsId = factionTeams.map(team => team.id) + + //getting every challenge associated with every teams and add points + //also getting every user associated with teamId + for (const teamId of teamsId) { + const challenges = await db.select().from(TeamTochallengeSchema).where(eq(TeamTochallengeSchema.teamId, teamId)); + challenges.forEach(challenge => points += challenge.attributedPoints) + //-----// + const users = await db.select().from(userSchema).where(eq(userSchema.team, teamId)); + //getting challenges associated to users + for(let user of users) { + const userChallenges = await db.select().from(StudentTochallengeSchema).where(eq(StudentTochallengeSchema.studentId, user.id)) + userChallenges.forEach(challenge => points += challenge.attributedPoints) + } + } + + return points +} + +export const countPointsForTeam = async (teamId: number): Promise => { + let points = 0; + + //getting every teamId who is associated with factionId + const factionTeams = await db.select().from(teamSchema).where(eq(teamSchema.id, teamId)) + const teamsId = factionTeams.map(team => team.id) + + //getting every challenge associated with every teams and add points + for (const teamId of teamsId) { + const challenges = await db.select().from(TeamTochallengeSchema).where(eq(TeamTochallengeSchema.teamId, teamId)); + challenges.forEach(challenge => points += challenge.attributedPoints) + //-----// + const users = await db.select().from(userSchema).where(eq(userSchema.team, teamId)); + //getting challenges associated to users + for(let user of users) { + const userChallenges = await db.select().from(StudentTochallengeSchema).where(eq(StudentTochallengeSchema.studentId, user.id)) + userChallenges.forEach(challenge => points += challenge.attributedPoints) + } + } + + return points +} + +export const createChallenge = async (name: string, description: string, points: string, challType: ChallengeType) => { + const newChallenge: challenge = {name: name, description: description, points: points, challType: challType}; try { await db.insert(challengeSchema).values(newChallenge); } catch (error) { @@ -38,16 +269,257 @@ export const deleteChallenge = async (id: number) => { } } -export const validateChallenge = async (challengeId: number, factionId: number) => { +export const validateChallenge = async (challengeId: number, associatedId: number, attributedPoints: number, text: string | null) => { + //First get the type of challenge + const challenge = await db.select().from(challengeSchema).where(eq(challengeSchema.id, challengeId)); + if(!challenge || challenge.length === 0) throw new Error("No challenge with id '" + challengeId + "'") + const challType: ChallengeType = challenge[0].challType + switch (challType) { + case ChallengeType.Student: + await completeChallengeToUser(challengeId, associatedId, attributedPoints, false) + break; + case ChallengeType.StudentOrCe: + await completeChallengeToUser(challengeId, associatedId, attributedPoints, true) + break; + case ChallengeType.Team: + await completeChallengeToTeam(challengeId, associatedId, attributedPoints) + break; + case ChallengeType.Faction: + await completeChallengeToFaction(challengeId, associatedId, attributedPoints) + break; + case ChallengeType.Free: + if(!text) throw new Error("You need to explain why you add points.") + await freeChallengeToFaction(associatedId, attributedPoints, text) + break; + } +} + + +export const unvalidateChallenge = async (challengeId: number, associatedId: number, text?: string) => { + //First get the type of challenge + const challenge = await db.select().from(challengeSchema).where(eq(challengeSchema.id, challengeId)); + if(!challenge || challenge.length === 0) throw new Error("No challenge with id '" + challengeId + "'") + const challType: ChallengeType = challenge[0].challType + switch (challType) { + case ChallengeType.Student: + await unvalidateChallengeToUser(challengeId, associatedId) + break; + case ChallengeType.StudentOrCe: + await unvalidateChallengeToUser(challengeId, associatedId) + break; + case ChallengeType.Team: + await unvalidateChallengeToTeam(challengeId, associatedId) + break; + case ChallengeType.Faction: + await unvalidateChallengeToFaction(challengeId, associatedId) + break; + case ChallengeType.Free: + if(!text) throw new Error("You need to enter text.") + await unvalidateToFaction(text, associatedId) + break; + } +} + +async function unvalidateChallengeToUser(challengeId: number, associatedId: number) { + //Getting the challenge + const associatedChall = await db.select().from(StudentTochallengeSchema) + .where( + and( + eq(StudentTochallengeSchema.challengeId, challengeId), + eq(StudentTochallengeSchema.studentId, associatedId) + ) + ); + if(associatedChall.length === 0) throw new Error("Event not associated with this user. userId '" + associatedId + "'") + const points = associatedChall[0].attributedPoints + //Getting faction + const faction = await getFactionFromUserId(associatedId) + await removePoints(faction, points) + await db.delete(StudentTochallengeSchema) + .where( + and( + eq(StudentTochallengeSchema.challengeId, challengeId), + eq(StudentTochallengeSchema.studentId, associatedId) + ) + ); +} + +async function unvalidateChallengeToTeam(challengeId: number, associatedId: number) { + //Getting the challenge + const associatedChall = await db.select().from(TeamTochallengeSchema) + .where( + and( + eq(TeamTochallengeSchema.challengeId, challengeId), + eq(TeamTochallengeSchema.teamId, associatedId) + ) + ); + if(associatedChall.length === 0) throw new Error("Event not associated with this team. teamId '" + associatedId + "'") + const points = associatedChall[0].attributedPoints + + //Getting team + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, associatedId)); + if(!team || team.length === 0) throw new Error("Team does not exist. id: " + associatedId); + await removePoints(team[0].faction as number, points) + await db.delete(TeamTochallengeSchema) + .where( + and( + eq(TeamTochallengeSchema.challengeId, challengeId), + eq(TeamTochallengeSchema.teamId, associatedId) + ) + ); +} + +async function unvalidateChallengeToFaction(challengeId: number, associatedId: number) { + //Getting the challenge + const associatedChall = await db.select().from(factionTochallengeSchema) + .where( + and( + eq(factionTochallengeSchema.challengeId, challengeId), + eq(factionTochallengeSchema.factionId, associatedId) + ) + ); + if(associatedChall.length === 0) throw new Error("Event not associated with this faction. factionId '" + associatedId + "'") + const points = associatedChall[0].attributedPoints + + //Getting team + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, associatedId)); + if(!faction || faction.length === 0) throw new Error("Faction does not exist. id: " + associatedId); + await removePoints(faction[0].id as number, points) + await db.delete(factionTochallengeSchema) + .where( + and( + eq(factionTochallengeSchema.challengeId, challengeId), + eq(factionTochallengeSchema.factionId, associatedId) + ) + ); +} + +export async function unvalidateToFaction(text: string, associatedId: number) { + //Getting the challenge + const associatedChall = await db.select().from(FreeToChallengeSchema) + .where( + and( + eq(FreeToChallengeSchema.text, text), + eq(FreeToChallengeSchema.factionId, associatedId) + ) + ); + if(associatedChall.length === 0) throw new Error("Event not associated with this faction. factionId '" + associatedId + "'") + const points = associatedChall[0].attributedPoints + + //Getting team + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, associatedId)); + if(!faction || faction.length === 0) throw new Error("Faction does not exist. id: " + associatedId); + await removePoints(faction[0].id as number, points) + await db.delete(FreeToChallengeSchema) + .where( + and( + eq(FreeToChallengeSchema.text, text), + eq(FreeToChallengeSchema.factionId, associatedId) + ) + ); +} + +async function completeChallengeToUser(challengeId: number, associatedId: number, attributedPoints: number, allowCe: boolean) { + //means associatedId is a student + //checking user exist + const user = await db.select().from(userSchema).where(eq(userSchema.id, associatedId)); + if(!user || user.length === 0) throw new Error("No user with id '" + associatedId + "'") + //check user is not CE + if(!allowCe) { + if(user[0].permission === PermType.Student && user[0].team !== null) throw new Error("User is 'CE' he can not complete this challenge.") + } + //Associating the challenge to the user + //checking is event already associated with this user + const associatedChall = await db.select().from(StudentTochallengeSchema) + .where( + and( + eq(StudentTochallengeSchema.challengeId, challengeId), + eq(StudentTochallengeSchema.studentId, associatedId) + ) + ); + + if(associatedChall && associatedChall.length > 0) throw new Error("Event already associated with this user. userId '" + associatedId + "'") + + //get associated faction try { - const newFacToChall: factionTochallenge = { challengeId, factionId}; - const alreadyValidate = await db.select().from(factionTochallengeSchema).where(eq(factionTochallengeSchema, newFacToChall)); - if (alreadyValidate.length === 0) { - const points = (await getChallenge(challengeId)).points; - addPoints(factionId, points); - await db.insert(factionTochallengeSchema).values(newFacToChall); - } + const faction = await getFactionFromTeam(user[0].team as number) + await addPoints(faction, attributedPoints) + //associating the event + await db.insert(StudentTochallengeSchema).values({ + challengeId: challengeId, + studentId: associatedId, + attributedPoints: attributedPoints + }).execute(); } catch (error) { - throw new Error("Failed to create challenge to faction. Please try again later."); + throw error } +} + +async function completeChallengeToTeam(challengeId: number, associatedId: number, attributedPoints: number) { + //means associatedId is a team + //checking team exist + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, associatedId)); + if(!team || team.length === 0) throw new Error("No team with id '" + associatedId + "'") + //Associating the challenge to the team + //checking is event already associated with this team + const associatedChall = await db.select().from(TeamTochallengeSchema) + .where( + and( + eq(TeamTochallengeSchema.challengeId, challengeId), + eq(TeamTochallengeSchema.teamId, associatedId) + ) + ); + + if(associatedChall && associatedChall.length > 0) throw new Error("Event already associated with this team. teamId '" + associatedId + "'") + //associating the event + await db.insert(TeamTochallengeSchema).values({ + challengeId: challengeId, + teamId: associatedId, + attributedPoints: attributedPoints + }).execute(); + + //adding points to the faction also + await addPoints(team[0].faction as number, attributedPoints) +} + +async function completeChallengeToFaction(challengeId: number, associatedId: number, attributedPoints: number) { + //means associatedId is a faction + //checking faction exist + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, associatedId)); + if(!faction || faction.length === 0) throw new Error("No faction with id '" + associatedId + "'") + //Associating the challenge to the faction + //checking is event already associated with this faction + const associatedChall = await db.select().from(factionTochallengeSchema) + .where( + and( + eq(factionTochallengeSchema.challengeId, challengeId), + eq(factionTochallengeSchema.factionId, associatedId) + ) + ); + if(associatedChall && associatedChall.length > 0) throw new Error("Event already associated with this faction. teamId '" + associatedId + "'") + //associating the event + await db.insert(factionTochallengeSchema).values({ + challengeId: challengeId, + factionId: associatedId, + attributedPoints: attributedPoints + }).execute(); + + //adding points to the faction also + await addPoints(faction[0].id, attributedPoints) +} + +export async function freeChallengeToFaction(factionId: number, attributedPoints: number, text: string) { + //means associatedId is a faction + //checking faction exist + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, factionId)); + if(!faction || faction.length === 0) throw new Error("No faction with id '" + faction + "'") + + //associating the event + await db.insert(FreeToChallengeSchema).values({ + factionId: factionId, + text: text, + attributedPoints: attributedPoints + }).execute(); + + //adding points to the faction also + await addPoints(faction[0].id, attributedPoints) } \ No newline at end of file diff --git a/backend/src/services/faction.service.ts b/backend/src/services/faction.service.ts index 120281186..c455a7c92 100644 --- a/backend/src/services/faction.service.ts +++ b/backend/src/services/faction.service.ts @@ -62,3 +62,17 @@ export const addPoints = async (id: number, points: number) => { throw new Error("Failed to add points. Please try again later."); } } + +export const removePoints = async (id: number, points: number) => { + console.log("remove " + id + " " + points) + const current_points = await getPoints(id); + console.log(current_points) + try { + await db.update(factionSchema) + .set({ points: current_points - points }) + .where(eq(factionSchema.id, id)); + } catch (error) { + console.log(error) + throw new Error("Failed to remove points. Please try again later."); + } +} \ No newline at end of file diff --git a/backend/src/services/team.service.ts b/backend/src/services/team.service.ts index c4f5db4fc..d635b984d 100644 --- a/backend/src/services/team.service.ts +++ b/backend/src/services/team.service.ts @@ -2,6 +2,7 @@ import { teamSchema, Team } from "../schemas/team.schema" import { db } from "../database/db" import { eq } from 'drizzle-orm' import { timeEnd, timeStamp } from "console"; +import {countPointsForTeam} from "./challenge.service"; export const getAllTeams = async () => { try { @@ -11,6 +12,21 @@ export const getAllTeams = async () => { } } +export const getAllTeamsWithPoints = async () => { + try { + let result = [] + const teams = await db.select().from(teamSchema); + const ids = teams.map(team => team.id) + for (let i = 0; i < ids.length; i++) { + const points = await countPointsForTeam(ids[i]) + result.push({team: teams[i], points: points}) + } + return result + } catch (error) { + throw new Error("Failed to fetch teams. Please try again later: " + error); + } +} + export const createTeam = async (name: string) => { try { const newTeam: Team = { name, isOfficial: false, faction: null, timeCode: 0}; diff --git a/backend/src/services/user.service.ts b/backend/src/services/user.service.ts index 486932797..8fe781970 100644 --- a/backend/src/services/user.service.ts +++ b/backend/src/services/user.service.ts @@ -3,7 +3,7 @@ import { userSchema, User, PermType } from '../schemas/user.schema'; import { newstudentSchema } from '../schemas/newstudent.schema'; import { roleSchema, userToRoleSchema } from '../schemas/role.schema'; import { db } from "../database/db" -import { eq, and, is } from 'drizzle-orm' +import {eq, and, is, ne, isNotNull} from 'drizzle-orm' import { uuid } from 'drizzle-orm/pg-core'; export const getAllUsers = async () => { @@ -20,7 +20,30 @@ export const getAllUsers = async () => { discord_id: userSchema.discord_id, connection_number: userSchema.connection_number, team_id: userSchema.team, - }).from(userSchema); + }).from(userSchema).where(eq(userSchema.permission, PermType.NewStudent)); + } catch (error) { + throw new Error("Failed to fetch users. Please try again later."); + } +} + +export const getAllCe = async () => { + try { + return await db.select({ + id: userSchema.id, + first_name: userSchema.first_name, + last_name: userSchema.last_name, + email: userSchema.email, + branch: userSchema.branch, + permission: userSchema.permission, + birthday: userSchema.birthday, + contact: userSchema.contact, + discord_id: userSchema.discord_id, + connection_number: userSchema.connection_number, + team_id: userSchema.team, + }).from(userSchema).where(and( + eq(userSchema.permission, PermType.Student), + isNotNull(userSchema.team) + )); } catch (error) { throw new Error("Failed to fetch users. Please try again later."); } @@ -126,7 +149,7 @@ export const updateUser = async (id: number, branch : string, contact: string, d try { await db.update(userSchema).set({ branch: branch, - contact: contact, + contact: contact, discord_id: discord_id}).where(eq(userSchema.id, id)); } catch (error) { throw new Error("Failed to update user. Please try again later."); @@ -135,13 +158,13 @@ export const updateUser = async (id: number, branch : string, contact: string, d export const registerUser = async (first_name: string, last_name: string, email: string, birthday: string | null, branch: string| null, contact: string| null, discord_id: string| null, password: string) => { try { - await db.update(userSchema).set({ + await db.update(userSchema).set({ first_name: first_name, last_name: last_name, birthday: birthday, branch: branch, password: password, - contact: contact, + contact: contact, discord_id: discord_id}).where(eq(userSchema.email, email)); } catch (error) { throw new Error("Failed to update user. Please try again later."); @@ -308,3 +331,85 @@ export const updateUserPassword = async(id: number, password: string) => { throw new Error("Failed to update user password. Please try again later."); } } + +type UserData = { + etu_number: string + first_name: string, + last_name: string, + email: string, + phone: string, + new: boolean, + ce: boolean, + team_number: number | null, + orga: boolean, + mission: string, + major: boolean +} + +export async function getInfo(emails: string[]): Promise { + //checking faction exist + let list = [] + for (let email of emails) { + const user = await db.select().from(userSchema).where(eq(userSchema.email, email)); + if(!user || user.length === 0) throw new Error("No user with mail '" + email + "'") + list.push([ + "", + user[0].first_name, + user[0].last_name, + email, + "", + isNew(user[0]), + isCe(user[0]), + user[0].team, + isOrga(user[0]), + "", + isMajor(user[0]) + ]) + console.log(list) + } + return list +} + +/* + list.push({ + etu_number: "", + first_name: user[0].first_name, + last_name: user[0].last_name, + email: email, + phone: "", + new: isNew(user[0]), + ce: isCe(user[0]), + team_number: user[0].team, + orga: isOrga(user[0]), + mission: "", + major: isMajor(user[0]) + }) + */ + +export function isCe(user: User) { + return user.permission === PermType.Student && user.team !== undefined +} + +function isMajor(user: User): boolean { + if(!user.birthday) return false + const birthDate = new Date(user.birthday); + const today = new Date(); + + let age = today.getFullYear() - birthDate.getFullYear(); + const monthDifference = today.getMonth() - birthDate.getMonth(); + + // Si l'anniversaire n'est pas encore passé cette année, on soustrait 1 + if (monthDifference < 0 || (monthDifference === 0 && today.getDate() < birthDate.getDate())) { + age--; + } + + return age >= 18; +} + +function isOrga(user: User) { + return user.permission !== PermType.NewStudent +} + +function isNew(user: User) { + return user.permission === PermType.NewStudent +} diff --git a/backend/src/utils/challenge.ts b/backend/src/utils/challenge.ts new file mode 100644 index 000000000..61ca2781b --- /dev/null +++ b/backend/src/utils/challenge.ts @@ -0,0 +1,81 @@ +import {db} from "../database/db"; +import {teamSchema} from "../schemas/team.schema"; +import {eq, inArray, ne} from "drizzle-orm"; +import {User, userSchema} from "../schemas/user.schema"; +import {NoFaction, NoTeam, NoUser} from "../error/user"; +import {factionSchema} from "../schemas/faction.schema"; +import { + challenge, + challengeSchema, + ChallengeType, factionTochallenge, factionTochallengeSchema, studentTochallenge, + StudentTochallengeSchema, + teamTochallenge, TeamTochallengeSchema +} from "../schemas/challenge.schema"; +import {isCe} from "../services/user.service"; + +export async function getFactionFromTeam(userTeam: number): Promise { + //get associated faction + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, userTeam)) + if(!team || team.length === 0) throw NoTeam(userTeam) + return team[0].faction as number +} + +export async function getFactionFromUserId(userId: number): Promise { + //get user + const user = await db.select().from(userSchema).where(eq(userSchema.id, userId)) + if(!user || user.length === 0) throw NoUser(userId) + //get associated faction + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, user[0].team as number)) + if(!team || team.length === 0) throw NoTeam(user[0].team) + return team[0].faction as number +} + +export async function getFactionFromUser(user: User): Promise { + //get associated faction + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, user.team as number)) + if(!team || team.length === 0) throw NoTeam(team[0].id) + return team[0].faction as number +} + +export async function getChallengeFromIds(challengesIds: number[]): Promise { + if(!challengesIds || challengesIds.length === 0) return [] + return db.select() + .from(challengeSchema) + .where(inArray(challengeSchema.id, challengesIds)); +} + +export async function getAllChallenges(): Promise { + return db.select().from(challengeSchema) +} + +export async function getChallengesOf(type: ChallengeType): Promise { + return db.select().from(challengeSchema).where(eq(challengeSchema.challType, type)) +} + +export async function getAllChallengesExcept(type: ChallengeType): Promise { + return db.select().from(challengeSchema).where(ne(challengeSchema.challType, type)) +} + +export async function getTeamAndFactionFromUser(user: User): Promise<{teamId: number, factionId: number}> { + //get associated faction + const team = await db.select().from(teamSchema).where(eq(teamSchema.id, user.team as number)) + if(!team || team.length === 0) throw NoTeam(team[0].id) + //get faction + const faction = await db.select().from(factionSchema).where(eq(factionSchema.id, team[0].faction as number)) + if(!faction || faction.length === 0) throw NoFaction(team[0].id) + return {teamId: team[0].id, factionId: faction[0].id} +} + +export async function getTeamAndFactionFromUserId(user: number): Promise<{teamId: number, factionId: number}> { + //get user + const userdb = await db.select().from(userSchema).where(eq(userSchema.id, user)) + if(!userdb || userdb.length === 0) throw NoUser(user) + return await getTeamAndFactionFromUser(userdb[0]) +} + +export async function isCE(studentId: number): Promise { + //get user + const userdb = await db.select().from(userSchema).where(eq(userSchema.id, studentId)) + if(!userdb || userdb.length === 0) throw NoUser(studentId) + return isCe(userdb[0]) +} \ No newline at end of file diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 000000000..2eea525d8 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/frontend/src/components/admin/users/Actions.tsx b/frontend/src/components/admin/users/Actions.tsx index 807fb1765..86be27c24 100644 --- a/frontend/src/components/admin/users/Actions.tsx +++ b/frontend/src/components/admin/users/Actions.tsx @@ -10,6 +10,7 @@ import { getAllUsers } from '../../../services/requests' import { toTable } from '../../utils/Tables' import { deleteNewStudent, getAllNewStudent, syncNewStudent } from '../../../services/requests/newstudent'; import { resetPasswordAdmin } from '../../../services/requests/auth'; +import {api} from "../../../services/api"; export const AddToTeam = () => { const [users, setUsers] = useState([] as any) @@ -45,6 +46,59 @@ export const AddToTeam = () => { ) } +//to get data for wei bus distribution +export const GetDatas = () => { + const [users, setUsers] = useState([] as any[]); + const [team, setTeam] = useState({} as any); + + // Fonction pour gérer le chargement du fichier + const handleFileUpload = async (event: React.ChangeEvent) => { + const file = event.target.files?.[0]; + if (!file) return; + + const reader = new FileReader(); + reader.onload = (e) => { + const content = e.target?.result as string; + console.log(content) + const lines = content.split('\n').map(line => line.trim()).filter(line => line); + setUsers(lines); + }; + reader.readAsText(file); + }; + + const Submit = async () => { + const t = await api.post("user/getInfo", {email: users}) + const data = t.data.data + let stringContent = "" + for (const line of data) { + stringContent += (line.toString() + "\n") + } + const blob = new Blob([stringContent], { type: 'text/plain' }); // Utilisation de 'text/plain' pour du texte brut + const url = URL.createObjectURL(blob); + + const link = document.createElement('a'); + link.href = url; + link.download = 'user_info.txt'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + // Réinitialisation des états après soumission + setUsers([]); + setTeam({}); + }; + + return ( +
+
+ +
+ + +
+ ); +}; + export const ChangePermission = () => { const [user, setUser] = useState({} as any) const [perm, setPerm] = useState({} as any) diff --git a/frontend/src/components/admin/users/UserAdminSection.tsx b/frontend/src/components/admin/users/UserAdminSection.tsx index 31f283573..48ae21629 100644 --- a/frontend/src/components/admin/users/UserAdminSection.tsx +++ b/frontend/src/components/admin/users/UserAdminSection.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import AdminSection from '../AdminSection'; -import { AddToTeam, ChangePermission, DeleteUser, ManageNewStudents, PasswordReset, TableNewStudents, TableUser } from './Actions'; +import { GetDatas, AddToTeam, ChangePermission, DeleteUser, ManageNewStudents, PasswordReset, TableNewStudents, TableUser } from './Actions'; import { AdminAction } from '../AdminSection'; import { getRole } from '../../../services/requests'; @@ -55,6 +55,11 @@ const UserAdminSection: React.FC = () => { title: 'Affichage des nouveaux', form: , }, + { + title: 'Récupération données WEI', + form: , + }, + ]; const filteredActions = actions.filter(action => { diff --git a/frontend/src/components/auth/Login.tsx b/frontend/src/components/auth/Login.tsx index 7c6ea0bf7..6b23b08e2 100644 --- a/frontend/src/components/auth/Login.tsx +++ b/frontend/src/components/auth/Login.tsx @@ -92,16 +92,18 @@ const LoginForm = () => { }; const TryLogin = async () => { - localStorage.setItem("tryLogin", "false"); try { //CAS CONNEXTION const urlParams = new URLSearchParams(window.location.search); const ticket = urlParams.get("ticket"); - + console.log("coucou") if(ticket){ const {token} = await handleCASTicket(ticket); + console.log(token) + localStorage.setItem("tryLogin", "false"); localStorage.setItem("authToken", token); + console.log("redirect /Home") window.location.href = "/Home"; } @@ -142,7 +144,6 @@ const LoginForm = () => { } - const getContainerClass = () => { if (stateNewLogin) return "active login"; if (stateNewRegister) return "active register"; diff --git a/frontend/src/components/challenge/AnimAction.tsx b/frontend/src/components/challenge/AnimAction.tsx new file mode 100644 index 000000000..9ea05870e --- /dev/null +++ b/frontend/src/components/challenge/AnimAction.tsx @@ -0,0 +1,126 @@ +import React, {useEffect, useState} from 'react'; +import Select from 'react-select' +import {ToastContainer} from 'react-toastify'; +import "react-toastify/dist/ReactToastify.css"; +import {Challenge, ChallType} from "../../services/interfaces"; +import {toTable} from "../utils/Tables"; +import {getChallenges, unvalidChallenge, validChallenge} from "../../services/requests/challenges"; +import {handleError} from "../utils/Submit"; +import {Ces, Challenges, Choice, Factions, Teams, Users} from "../utils/Select"; + +interface TableChallengeType { + type: ChallType +} + +export const TableChallenge: React.FC = ({ type }) => { + + const [challenges, setChallenges] = useState([]); + + useEffect(() => { + const fetchChallenges = async () => { + try { + const teams = await getChallenges(type, Choice.ALL, undefined); + setChallenges(teams) + } catch (error) { + console.error('Error fetching challenges:', error); + } + }; + fetchChallenges(); + }, []); + return challenges.length > 0 ? toTable(challenges) : null; +} + +export const ValidChallenge: React.FC<{type: ChallType}> = ({type}) => { + const [value, setValue] = useState({} as any) + const [challenge, setChallenge] = useState({} as any) + const [choices, setChoices] = useState({} as any) + const [points, setPoints] = useState(0) + const [text, setText] = useState("") + + const Submit = async () => { + await handleError("Challenge validé !", "Challenge déjà complété.", validChallenge, value.value, challenge.value, points, text) + setValue({}) + setChallenge({}) + setPoints(0) + setText("") + } + + return ( +
+
+ { + setText(chall.description + " : " + chall.points) + setChallenge(chall) + }} + value={challenge} + /> + +
+
+
+ + setPoints(Number(e.target.value))} + /> +
+ + {/* Input pour le texte */} +
+ + setText(e.target.value)} + /> +
+
+ + +
+ ) +} +export const UnvalidChallenge: React.FC<{type: ChallType}> = ({type}) => { + const [value, setValue] = useState({} as any) + const [challenge, setChallenge] = useState({} as any) + + const Submit = async () => { + await handleError("Challenge unvalidé !", "Challenge non complété.", unvalidChallenge, challenge.value, value.value) + setValue({}) + setChallenge({}) + } + + return ( +
+
+ setChallenge(chall)} + value={challenge} + /> + +
+ + +
+ ) +} \ No newline at end of file diff --git a/frontend/src/components/challenge/BaseAnimSection.tsx b/frontend/src/components/challenge/BaseAnimSection.tsx new file mode 100644 index 000000000..3d2873c04 --- /dev/null +++ b/frontend/src/components/challenge/BaseAnimSection.tsx @@ -0,0 +1,39 @@ +import React, { useState } from 'react'; + +export interface AnimAction { + title: string; + form: JSX.Element; +} + +export interface SectionProps { + actions: AnimAction[]; +} + +const BaseAnimSection: React.FC = ({ actions }) => { + const [selectedAction, setSelectedAction] = useState(null); + + const handleActionClick = (action: AnimAction) => { + setSelectedAction(action); + }; + + return ( +
+
+ {actions.map((action, index) => ( +
+ +
+ ))} +
+
+ {selectedAction && ( + selectedAction.form + )} +
+
+ ); +}; + +export default BaseAnimSection; diff --git a/frontend/src/components/challenge/faction/ChallFactionSection.tsx b/frontend/src/components/challenge/faction/ChallFactionSection.tsx new file mode 100644 index 000000000..8531c66a7 --- /dev/null +++ b/frontend/src/components/challenge/faction/ChallFactionSection.tsx @@ -0,0 +1,50 @@ +import React, {useEffect, useState} from 'react'; +import {getRole} from '../../../services/requests'; +import BaseAnimSection from "../BaseAnimSection"; +import {AdminAction} from "../../admin/AdminSection"; +import {ChallType} from "../../../services/interfaces"; +import {TableChallenge, UnvalidChallenge, ValidChallenge} from "../AnimAction"; + +const ChallFactionSection: React.FC = () => { + + const [clicked, setClicked] = useState(false); + const [role, setRole] = useState(null); + + const handleClick = () => { + setClicked(!clicked); + } + + useEffect(() => { + const fetchRole = async () => { + try { + const role = await getRole(); + setRole(role); + } catch (error) { + console.error('Error fetching role:', error); + } + }; + + fetchRole(); + }, []); + + const actions: AdminAction[] = [ + { + title: 'Valider challenge', + form: , + }, + { + title: 'Unvalider challenge', + form: , + }, + { + title: 'Affichage challenges', + form: , + } + ]; + + return ( + + ); +}; + +export default ChallFactionSection; diff --git a/frontend/src/components/challenge/free/ChallFreeSection.tsx b/frontend/src/components/challenge/free/ChallFreeSection.tsx new file mode 100644 index 000000000..d5acd33a8 --- /dev/null +++ b/frontend/src/components/challenge/free/ChallFreeSection.tsx @@ -0,0 +1,50 @@ +import React, {useEffect, useState} from 'react'; +import {TableChallenge, UnvalidChallenge, ValidChallenge} from './FreeActions'; +import {getRole} from '../../../services/requests'; +import BaseAnimSection from "../BaseAnimSection"; +import {AdminAction} from "../../admin/AdminSection"; +import {ChallType} from "../../../services/interfaces"; + +const ChallFreeSection: React.FC = () => { + + const [clicked, setClicked] = useState(false); + const [role, setRole] = useState(null); + + const handleClick = () => { + setClicked(!clicked); + } + + useEffect(() => { + const fetchRole = async () => { + try { + const role = await getRole(); + setRole(role); + } catch (error) { + console.error('Error fetching role:', error); + } + }; + + fetchRole(); + }, []); + + const actions: AdminAction[] = [ + { + title: 'Valider challenge', + form: , + }, + { + title: 'Unvalider challenge', + form: , + }, + { + title: 'Affichage challenges', + form: , + } + ]; + + return ( + + ); +}; + +export default ChallFreeSection; diff --git a/frontend/src/components/challenge/free/FreeActions.tsx b/frontend/src/components/challenge/free/FreeActions.tsx new file mode 100644 index 000000000..305596253 --- /dev/null +++ b/frontend/src/components/challenge/free/FreeActions.tsx @@ -0,0 +1,124 @@ +import React, {useEffect, useState} from 'react'; +import Select from 'react-select' +import {ToastContainer} from 'react-toastify'; +import "react-toastify/dist/ReactToastify.css"; +import {Challenge, ChallType} from "../../../services/interfaces"; +import {toTable} from "../../utils/Tables"; +import {getChallenges, unvalidFreeChallenge, validFreeChallenge} from "../../../services/requests/challenges"; +import {handleError, toId} from "../../utils/Submit"; +import {Choice, Factions, getFreeChallengeText} from "../../utils/Select"; + +interface TableChallengeType { + type: ChallType +} + +export const TableChallenge: React.FC = ({ type }) => { + + const [challenges, setChallenges] = useState([]); + + useEffect(() => { + const fetchChallenges = async () => { + try { + const teams = await getChallenges(type, Choice.ALL, undefined); + setChallenges(teams) + } catch (error) { + console.error('Error fetching challenges:', error); + } + }; + fetchChallenges(); + }, []); + return challenges.length > 0 ? toTable(challenges) : null; +} + +export const ValidChallenge: React.FC<{type: ChallType}> = ({type}) => { + const [faction, setFaction] = useState({} as any) + const [challenge, setChallenge] = useState({} as any) + const [points, setPoints] = useState(0) + const [text, setText] = useState("") + + const Submit = async () => { + const id = toId(faction) + await handleError("Challenge validé !", "Challenge déjà complété.", validFreeChallenge, faction.value, points, text) + setFaction({}) + setChallenge({}) + setPoints(0) + setText("") + } + + return ( +
+
+ setPoints(Number(e.target.value))} + /> +
+ + {/* Input pour le texte */} +
+ + setText(e.target.value)} + /> +
+
+ + + + ) +} + +export const UnvalidChallenge: React.FC = () => { + const [faction, setFaction] = useState({} as any) + const [challenge, setChallenge] = useState({} as any) + const [options, setOptions] = useState([]) + + const Submit = async () => { + await handleError("Challenge unvalidé !", "Challenge non complété.", unvalidFreeChallenge, faction.value, challenge.value) + setFaction({}) + setChallenge({}) + } + + useEffect(() => { + getFreeChallengeText(faction.value) + .then(value => { + setOptions(value)}) + }, [faction]); + + return ( +
+
+ setChallenge(chall)} + value={challenge} + /> + +
+ + +
+ ) +} \ No newline at end of file diff --git a/frontend/src/components/challenge/student/ChallStudentSection.tsx b/frontend/src/components/challenge/student/ChallStudentSection.tsx new file mode 100644 index 000000000..2579d78d8 --- /dev/null +++ b/frontend/src/components/challenge/student/ChallStudentSection.tsx @@ -0,0 +1,51 @@ +import React, {useEffect, useState} from 'react'; +import {getRole} from '../../../services/requests'; +import BaseAnimSection from "../BaseAnimSection"; +import {AdminAction} from "../../admin/AdminSection"; +import {ChallType} from "../../../services/interfaces"; +import {TableChallenge, UnvalidChallenge, ValidChallenge} from "../AnimAction"; + + +const ChallStudentSection: React.FC = () => { + + const [clicked, setClicked] = useState(false); + const [role, setRole] = useState(null); + + const handleClick = () => { + setClicked(!clicked); + } + + useEffect(() => { + const fetchRole = async () => { + try { + const role = await getRole(); + setRole(role); + } catch (error) { + console.error('Error fetching role:', error); + } + }; + + fetchRole(); + }, []); + + const actions: AdminAction[] = [ + { + title: 'Valider challenge', + form: , + }, + { + title: 'Unvalider challenge', + form: , + }, + { + title: 'Affichage challenges', + form: , + } + ]; + + return ( + + ); +}; + +export default ChallStudentSection; diff --git a/frontend/src/components/challenge/student_or_ce/ChallStudentCeSection.tsx b/frontend/src/components/challenge/student_or_ce/ChallStudentCeSection.tsx new file mode 100644 index 000000000..6e68b0f53 --- /dev/null +++ b/frontend/src/components/challenge/student_or_ce/ChallStudentCeSection.tsx @@ -0,0 +1,51 @@ +import React, {useEffect, useState} from 'react'; +import {getRole} from '../../../services/requests'; +import BaseAnimSection from "../BaseAnimSection"; +import {AdminAction} from "../../admin/AdminSection"; +import {ChallType} from "../../../services/interfaces"; +import {TableChallenge, UnvalidChallenge, ValidChallenge} from "../AnimAction"; + + +const ChallStudentCeSection: React.FC = () => { + + const [clicked, setClicked] = useState(false); + const [role, setRole] = useState(null); + + const handleClick = () => { + setClicked(!clicked); + } + + useEffect(() => { + const fetchRole = async () => { + try { + const role = await getRole(); + setRole(role); + } catch (error) { + console.error('Error fetching role:', error); + } + }; + + fetchRole(); + }, []); + + const actions: AdminAction[] = [ + { + title: 'Valider challenge', + form: , + }, + { + title: 'Unvalider challenge', + form: , + }, + { + title: 'Affichage challenges', + form: , + } + ]; + + return ( + + ); +}; + +export default ChallStudentCeSection; diff --git a/frontend/src/components/challenge/team/ChallTeamSection.tsx b/frontend/src/components/challenge/team/ChallTeamSection.tsx new file mode 100644 index 000000000..708bfc886 --- /dev/null +++ b/frontend/src/components/challenge/team/ChallTeamSection.tsx @@ -0,0 +1,50 @@ +import React, {useEffect, useState} from 'react'; +import {getRole} from '../../../services/requests'; +import BaseAnimSection from "../BaseAnimSection"; +import {AdminAction} from "../../admin/AdminSection"; +import {ChallType} from "../../../services/interfaces"; +import {TableChallenge, UnvalidChallenge, ValidChallenge} from "../AnimAction"; + +const ChallTeamSection: React.FC = () => { + + const [clicked, setClicked] = useState(false); + const [role, setRole] = useState(null); + + const handleClick = () => { + setClicked(!clicked); + } + + useEffect(() => { + const fetchRole = async () => { + try { + const role = await getRole(); + setRole(role); + } catch (error) { + console.error('Error fetching role:', error); + } + }; + + fetchRole(); + }, []); + + const actions: AdminAction[] = [ + { + title: 'Valider challenge', + form: , + }, + { + title: 'Unvalider challenge', + form: , + }, + { + title: 'Affichage challenges', + form: , + } + ]; + + return ( + + ); +}; + +export default ChallTeamSection; diff --git a/frontend/src/components/factions/FactionsAffichage.tsx b/frontend/src/components/factions/FactionsAffichage.tsx index 0a427ae4e..74724796d 100644 --- a/frontend/src/components/factions/FactionsAffichage.tsx +++ b/frontend/src/components/factions/FactionsAffichage.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react'; import { Faction, Team } from '../../services/interfaces'; import "./Factions.css"; -import { getAllTeams } from '../../services/requests/teams'; +import {getAllTeams, getAllTeamsWithPoints} from '../../services/requests/teams'; interface FactionsAffichageProps { faction: Faction; @@ -9,19 +9,19 @@ interface FactionsAffichageProps { const FactionsAffichage: React.FC = ({ faction }) => { - const [allTeams, setAllTeams] = useState([]); + const [allTeams, setAllTeams] = useState<{team: Team, points: number}[]>(); useEffect(() => { const fetchData = async () => { try { - const response = await getAllTeams(); - const filteredTeams = response.filter((team:Team) => team.faction === faction.id); + const response = await getAllTeamsWithPoints(); + const filteredTeams = response.filter((team:{team: Team, points: number}) => team.team.faction === faction.id); setAllTeams(filteredTeams); } catch (error) { console.error('Error fetching data:', error); } }; - fetchData(); + fetchData().then(); }, []); return ( @@ -29,9 +29,9 @@ const FactionsAffichage: React.FC = ({ faction }) => {

Equipes

- {allTeams.length > 0 ? ( - allTeams.map((team: Team, index: number) => ( -

{team.name}

+ {!allTeams ?

Chargement...

: allTeams.length > 0 ? ( + allTeams.map((team: {team: Team, points: number}, index: number) => ( +

{team.team.name} - {team.points}

)) ) : (

La faction ne comprend pas d'équipe

diff --git a/frontend/src/components/profil/Profil.tsx b/frontend/src/components/profil/Profil.tsx index 944ec5f64..ec2fc879c 100644 --- a/frontend/src/components/profil/Profil.tsx +++ b/frontend/src/components/profil/Profil.tsx @@ -3,11 +3,12 @@ import { getCurrentUser, updateUser } from '../../services/requests/users'; import { handleError } from '../utils/Submit'; import { ToastContainer, toast } from 'react-toastify'; import './Profil.css'; -import { Faction, Team, User } from '../../services/interfaces'; +import {ChallType, Faction, Team, User} from '../../services/interfaces'; import { getAllMembersTeam, getTeam } from '../../services/requests/teams'; import { getFaction } from '../../services/requests/factions'; import Select from "react-select"; import { Option } from "../../services/interfaces"; +import {getAvailableChallengeForUser} from "../../services/requests/challenges"; export const ProfilForm: React.FC = () => { const [firstName, setFirstName] = useState(''); @@ -209,4 +210,137 @@ export const TeamDisplay: React.FC = () => {
); +}; + +export const PossibleChallengeDisplay: React.FC = () => { + const [userTeam, setTeam] = useState(); + const [teamMembers, setTeamMembers] = useState([]); + const [userFaction, setFaction] = useState(); + const [permission, setPermission] = useState(""); + const [challenges, setChallenges] = useState([]) + const [challengesTeam, setChallengesTeam] = useState([]) + const [challengesFaction, setChallengesFaction] = useState([]) + + useEffect(() => { + const fetchUserTeamData = async () => { + try { + const currentUser = await getCurrentUser(); + const permission = currentUser.permission; + const team = await getTeam(currentUser.team_id); + setTeam(team); + if (team) { + setFaction(await getFaction(team.faction)); + setTeamMembers(await getAllMembersTeam(team.id)); + } + if(permission){ + setPermission(permission); + } + //get challenge + const challenges = await getAvailableChallengeForUser(currentUser.id as number) + console.log(challenges) + setChallenges(challenges.filter((chall: any) => chall.challType === ChallType.Student)) + setChallengesTeam(challenges.filter((chall: any) => chall.challType === ChallType.Team)) + setChallengesFaction(challenges.filter((chall: any) => chall.challType === ChallType.Faction)) + console.log(challenges) + } catch (error) { + console.error('Error fetching data:', error); + } + }; + fetchUserTeamData(); + }, []); + + return ( + <> +
+

Challenges Individuels

+
+ + + + + + + + + + {challenges?.length !== 0 ? ( + challenges?.map((chall: any) => ( + + + + + + )) + ) : ( + + + + )} + +
NOMDESCRIPTIONPOINTS
{chall.name}{chall.description}{chall.points}
Chargement...
+
+ +
+
+

Challenges d'équipes

+
+ + + + + + + + + + {challengesTeam?.length !== 0 ? ( + challengesTeam?.map((chall: any) => ( + + + + + + )) + ) : ( + + + + )} + +
NOMDESCRIPTIONPOINTS
{chall.name}{chall.description}{chall.points}
Chargement...
+
+ +
+
+

Challenges de factions

+
+ + + + + + + + + + {challengesFaction?.length !== 0 ? ( + challengesFaction?.map((chall: any) => ( + + + + + + )) + ) : ( + + + + )} + +
NOMDESCRIPTIONPOINTS
{chall.name}{chall.description}{chall.points}
Chargement...
+
+ +
+ + ); }; \ No newline at end of file diff --git a/frontend/src/components/utils/Select.tsx b/frontend/src/components/utils/Select.tsx index 096d562c3..d7c7a7f9c 100644 --- a/frontend/src/components/utils/Select.tsx +++ b/frontend/src/components/utils/Select.tsx @@ -1,11 +1,12 @@ -import { useState, useEffect } from "react" -import { Role, Faction, User, Team, Event, newStudent, Perm } from '../../services/interfaces' -import { getAllFactions, getAllTeams, getAllUsers } from '../../services/requests' +import React, { useState, useEffect } from "react" +import {Role, Faction, User, Team, Event, newStudent, Perm, Challenge, ChallType} from '../../services/interfaces' +import {getAllCe, getAllFactions, getAllTeams, getAllUsers} from '../../services/requests' import { getAllRoles } from "../../services/requests/roles" import { getActiveEvents, getInactiveEvents } from "../../services/requests/events" import { getAllNewStudent } from "../../services/requests/newstudent" import { getAllPerms } from "../../services/requests/perms" import { getAllByPermission } from "../../services/requests/users" +import {getAllChallenges, getAllFreeChallengesTexts, getChallenges} from "../../services/requests/challenges"; export const Roles = () => { const [options, setOptions] = useState([]) @@ -100,6 +101,61 @@ export const Teams = () => { return options } +export enum Choice { + ALL = "all", + AVAILABLE = "available", + COMPLETED = "completed" +} + +export const Challenges = (challType: ChallType, filter: Choice, associateId: number | undefined) => { + const [options, setOptions] = useState([]) + + useEffect(() => { + const fetchData = async () => { + try { + const response = await getChallenges(challType, filter, associateId) + const challOptions = response.map((chall: Challenge) => { + return { + value: chall.id, + label: chall.name, + description: chall.description, + points: chall.points + } + }) + setOptions(challOptions) + } catch (error) { + console.error('Error fetching data:', error) + } + } + + fetchData() + }, [associateId]) + + return options +} + +export const getFreeChallengeText = async (factionId: number): Promise<{value: string, label: string}[]> => { + + return await getAllFreeChallengesTexts(factionId) + .then(data => { + if(!data || data.length === 0) return [] + const response = data.map((chall: Challenge) => { + if(!chall) return {value: "", label: "undefined"} + console.log(chall) + return { + value: chall, + label: chall, + } + }) + return response + }) + .catch(error => { + console.log(error) + }) + +} + + export const Users = () => { const [options, setOptions] = useState([]) @@ -124,6 +180,30 @@ export const Users = () => { return options } +export const Ces = () => { + const [options, setOptions] = useState([]) + console.log("get ce") + useEffect(() => { + const fetchData = async () => { + try { + const response = await getAllCe() + const usersOptions = response.map((user: User) => ({ + value: user.id, + label: `${user.first_name} ${user.last_name}`, + email : user.email, + })) + setOptions(usersOptions) + } catch (error) { + console.error('Error fetching data:', error) + } + } + + fetchData() + }, []) + + return options +} + export const NewStudents = () => { const [options, setOptions] = useState([]) diff --git a/frontend/src/screens/Challenges.tsx b/frontend/src/screens/Challenges.tsx index 18f49996d..9fd4e4726 100644 --- a/frontend/src/screens/Challenges.tsx +++ b/frontend/src/screens/Challenges.tsx @@ -1,19 +1,30 @@ -import { Navbar } from "../components/shared/Navbar" -import { useEffect } from "react"; -import { Section } from "../components/shared/Section"; -import { Default } from "../components/shared/Default"; -import { getCurrentUser } from "../services/requests/users"; +import {Navbar} from "../components/shared/Navbar" +import {useEffect, useState} from "react"; +import {Section} from "../components/shared/Section"; +import {getCurrentUser} from "../services/requests/users"; +import ChallFactionSection from "../components/challenge/faction/ChallFactionSection"; +import ChallTeamSection from "../components/challenge/team/ChallTeamSection"; +import ChallStudentSection from "../components/challenge/student/ChallStudentSection"; +import {ChallType} from "../services/interfaces"; +import ChallStudentCeSection from "../components/challenge/student_or_ce/ChallStudentCeSection"; +import ChallFreeSection from "../components/challenge/free/ChallFreeSection"; export const Defis = () => { + const [permission, setPermission] = useState(null); + useEffect(() => { const fetchUser = async () => { try { const user = await getCurrentUser(); - const permission = user.permission - if (!permission) { - window.location.href = '/'; + const permission = user.permission; + + if ((permission !== ('Admin') && permission !== 'Anim')) { + console.log(permission) + window.location.href = '/Home'; return null; } + setPermission(permission); + } catch (error) { console.error('Error fetching permission:', error); } @@ -22,10 +33,21 @@ export const Defis = () => { fetchUser(); }, []); + //TODO: factoriser. j'ai essayé vite fait mais ça fait longtemps j'ai pas fait de react mdr return ( -
- -
+
+ +
+
+
+
+
) -} \ No newline at end of file +} + +/* +
+
+
+ */ \ No newline at end of file diff --git a/frontend/src/screens/Profil.tsx b/frontend/src/screens/Profil.tsx index e9eddc5b6..d34dd5f18 100644 --- a/frontend/src/screens/Profil.tsx +++ b/frontend/src/screens/Profil.tsx @@ -1,6 +1,6 @@ import { Navbar } from "../components/shared/Navbar" import { Section } from "../components/shared/Section" -import { ProfilForm, TeamDisplay } from "../components/profil/Profil" +import {PossibleChallengeDisplay, ProfilForm, TeamDisplay} from "../components/profil/Profil" import { useEffect } from "react"; import { getRole } from "../services/requests"; import { getCurrentUser } from "../services/requests/users"; @@ -29,6 +29,7 @@ export const Profil = () => {
+
) } diff --git a/frontend/src/services/interfaces.ts b/frontend/src/services/interfaces.ts index 70d739f29..c335239c1 100644 --- a/frontend/src/services/interfaces.ts +++ b/frontend/src/services/interfaces.ts @@ -24,6 +24,22 @@ export interface Team { type: Text; } +export enum ChallType { + Student = "Student", + StudentOrCe = "StudentOrCe", + Team = "Team", + Faction = "Faction", + Free = "Free" +} + +export interface Challenge { + id: number; + name: string; + description: string; + points: string; + chall_type: ChallType; +} + export interface Faction { id: number; name: string; diff --git a/frontend/src/services/requests.ts b/frontend/src/services/requests.ts index 6ea1828e4..d1525c9b8 100644 --- a/frontend/src/services/requests.ts +++ b/frontend/src/services/requests.ts @@ -1,11 +1,18 @@ import { api } from './api'; // Obtention de la liste des Utilisateurs enregistrés dans la db +//NE RETOURNE PAS LES CE export const getAllUsers = async () => { const response = await api.get('user/all') return response?.data.data } +// Obtention de la liste des Ce enregistrés dans la db +export const getAllCe = async () => { + const response = await api.get('user/ce/all') + return response?.data.data +} + // Obtention de la liste des équipes enregistrées dans la db export const getAllTeams = async () => { const response = await api.get('team/all') @@ -85,3 +92,10 @@ export const getWishUsers = async (roleId: string) => { const response = await api.get('/wish/' + roleId + '/users'); return response?.data.data; } + +// Compte les points d'une faction +export const countPoints = async () => { + const response = await api.get('/challenge/countPoints/'); + console.log(response?.data.data) + return response?.data.data; +} diff --git a/frontend/src/services/requests/auth.ts b/frontend/src/services/requests/auth.ts index 4f2148dc0..3699cddd7 100644 --- a/frontend/src/services/requests/auth.ts +++ b/frontend/src/services/requests/auth.ts @@ -6,7 +6,7 @@ export const isTokenValid = async (token: string) => { } export const handleCASTicket = async (ticket: string)=>{ - const response = await api.get('auth/handlecasticket/', { + const response = await api.get('auth/handlecasticket/', { params:{ "ticket" :ticket } diff --git a/frontend/src/services/requests/challenges.ts b/frontend/src/services/requests/challenges.ts new file mode 100644 index 000000000..974bc3ec2 --- /dev/null +++ b/frontend/src/services/requests/challenges.ts @@ -0,0 +1,58 @@ +import {api} from "../api"; +import {ChallType} from "../interfaces"; +import {Choice} from "../../components/utils/Select"; + +// Obtention de la liste des challenges enregistrées dans la db +export const getAllChallenges = async () => { + const response = await api.get("challenge/all"); + return response.data.data; +}; + +export const getChallenges = async (type: ChallType, filter: Choice, associatedId: number | undefined) => { + if(filter !== Choice.ALL && associatedId === undefined) return [] + const response = await api.post("challenge/all" + type, {filter: filter, associatedId: associatedId}); + return response.data.data; +}; + +export const getAvailableChallengeForUser = async (studentId: number) => { + const response = await api.post("challenge/getAvailableForStudent", { associatedId: studentId}); + return response.data.data; +}; + +export const getAllFreeChallengesTexts = async (factionId: number) => { + const response = await api.post("challenge/allFreeText", { + factionId + }); + return response.data.data; +}; + +export const validChallenge = async (associatedId: number, challId: number, attributedPoints: number, text: string|null) => { + return await api.post('challenge/valid', { + associatedId, + challId, + attributedPoints, + text + }) +} + +export const validFreeChallenge = async (associatedId: number, attributedPoints: number, text: string|null) => { + return await api.post('challenge/validFree', { + associatedId, + attributedPoints, + text + }) +} + +export const unvalidFreeChallenge = async (factionId: number, text: number) => { + return await api.post('challenge/unvalidFree', { + factionId, + text + }) +} + +export const unvalidChallenge = async (challId: number, associatedId: number) => { + return await api.post('challenge/unvalid', { + challId, + associatedId + }) +} diff --git a/frontend/src/services/requests/teams.ts b/frontend/src/services/requests/teams.ts index e534175d0..6a6f17dc6 100644 --- a/frontend/src/services/requests/teams.ts +++ b/frontend/src/services/requests/teams.ts @@ -1,4 +1,5 @@ import { api } from "../api"; +import {ChallType} from "../interfaces"; export const createTeam = async (name: string) => { return await api.post("team", { name }); @@ -51,6 +52,11 @@ export const getAllTeams = async () => { return response.data.data; }; +export const getAllTeamsWithPoints = async () => { + const response = await api.get("team/teamsWithPoints"); + return response.data.data; +}; + export const getAllMembersTeam = async (id : number) => { const response = await api.get("team/getallmembers/"+id);