Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6b331e8
fix: package.json scripts
blarth May 28, 2022
1904856
feat:prod branch
blarth May 28, 2022
8b1fe46
feat: model db
blarth May 28, 2022
dc6dbe4
fix:delete files
blarth May 28, 2022
7b95d9c
fix: conflict resolved
blarth May 28, 2022
cb6acf9
feat: tickets
blarth May 31, 2022
e852369
fix: hotelPrice nullable
blarth May 31, 2022
9cbce3b
fix: tests
blarth May 31, 2022
16e4c6d
Merge pull request #1 from blarth/fix/tickets
vinifreitass May 31, 2022
ca5c6b6
fix: change hotelPrice to event table
blarth Jun 2, 2022
01445a3
fix: test adjusted to new db model
blarth Jun 2, 2022
73e1018
Merge pull request #2 from blarth/fix/hotelPrice
ThaisFrancaG Jun 2, 2022
e5f4bc0
fix: withHotel added to enrollmentTickets
blarth Jun 2, 2022
98cbf7a
fix: migration for the db change
blarth Jun 2, 2022
0056ae4
Merge pull request #3 from blarth/fix/withHotel
SarahBezerra Jun 2, 2022
4026a35
feat: ticket purchase persistence
SarahBezerra Jun 3, 2022
2eba26a
Merge pull request #4 from blarth/feat/paymnet-persistence
blarth Jun 4, 2022
f84a9b7
test: ticket integration tests added
blarth Jun 4, 2022
da736c5
fix: return of the function that persists the ticket purchase
SarahBezerra Jun 4, 2022
aebb9c2
Merge pull request #5 from blarth/test/ticket-integration
vinifreitass Jun 4, 2022
ba81c1e
Merge branch 'dev' of github.com:blarth/drivent-back into feat/paymne…
SarahBezerra Jun 4, 2022
304ff02
Merge pull request #6 from blarth/feat/paymnet-persistence
vinifreitass Jun 4, 2022
08194a0
test: enrollment ticket integration test
SarahBezerra Jun 4, 2022
b6602fa
test: enrollment ticket unit test
SarahBezerra Jun 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,424 changes: 892 additions & 532 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@
"test:migration:run": "npm run test:load-envs prisma migrate deploy",
"test:migration:generate": "npm run test:load-envs prisma migrate dev",
"test:watch": "jest --watch --passWithNoTests --runInBand",
"test:docker": "npm run test:compose -- up",
"test:docker": "npm run test:compose -- up --build",
"test:compose": "docker-compose -f docker-compose.test.yml --env-file .env.test",
"test:postgres": "npm run test:compose -- up -d drivent-postgres-test",
"test:postgres:down": "npm run test:compose -- down -v",
"test:load-envs": "dotenv -e .env.test",
"test:docker:migration:run": "npm dev:compose -- drivent-development npm run test:load-envs prisma migrate deploy",
"test:docker:migration:run": "npm run test:compose -- run drivent-test npm run test:load-envs prisma migrate deploy",
"test:docker:migration:generate": "npm run test:load-envs prisma migrate dev",
"test:docker:seed": "npm run test:compose -- run drivent-test npm run test:load-envs prisma db seed",
"dev:compose": "docker-compose -f docker-compose.development.yml --env-file .env.development",
"dev:postgres": "npm run dev:compose -- up -d drivent-postgres-development",
"dev:postgres:down": "npm run dev:compose -- down",
"dev:load-envs": "dotenv -e .env.development",
"dev:migration:run": "npm run dev:compose -- run drivent-development npm run dev:load-envs prisma migrate deploy",
"dev:migration:generate": "npm run dev:compose -- drivent-development npm run dev:load-envs prisma migrate dev",
"dev:prisma:studio": "npm run dev:compose -- drivent-development npm run dev:load-envs prisma studio",
"dev:migration:generate": "npm run dev:compose -- run drivent-development npm run dev:load-envs prisma migrate dev",
"dev:prisma:studio": "npm run dev:compose run -- drivent-development npm run dev:load-envs prisma studio",
"dev:seed": "npm run dev:compose -- run drivent-development npm run dev:load-envs prisma db seed",
"dev:docker": "npm run dev:compose -- up",
"dev:docker:down": "npm run dev:compose -- down",
Expand Down
204 changes: 204 additions & 0 deletions prisma/migrations/20220528175917_db_model/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/*
Warnings:

- You are about to drop the `Address` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Enrollment` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Event` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Session` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "Address" DROP CONSTRAINT "Address_enrollmentId_fkey";

-- DropForeignKey
ALTER TABLE "Enrollment" DROP CONSTRAINT "Enrollment_userId_fkey";

-- DropForeignKey
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";

-- DropTable
DROP TABLE "Address";

-- DropTable
DROP TABLE "Enrollment";

-- DropTable
DROP TABLE "Event";

-- DropTable
DROP TABLE "Session";

-- DropTable
DROP TABLE "User";

-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"email" VARCHAR(255) NOT NULL,
"password" VARCHAR(255) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "sessions" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"token" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "events" (
"id" SERIAL NOT NULL,
"title" VARCHAR(255) NOT NULL,
"backgroundImageUrl" VARCHAR(255) NOT NULL,
"logoImageUrl" VARCHAR(255) NOT NULL,
"startsAt" TIMESTAMP(3) NOT NULL,
"endsAt" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "enrollments" (
"id" SERIAL NOT NULL,
"name" VARCHAR(255) NOT NULL,
"cpf" VARCHAR(255) NOT NULL,
"birthday" TIMESTAMP(3) NOT NULL,
"phone" VARCHAR(255) NOT NULL,
"userId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "adresses" (
"id" SERIAL NOT NULL,
"cep" VARCHAR(255) NOT NULL,
"street" VARCHAR(255) NOT NULL,
"city" VARCHAR(255) NOT NULL,
"state" VARCHAR(255) NOT NULL,
"number" VARCHAR(255) NOT NULL,
"neighborhood" VARCHAR(255) NOT NULL,
"addressDetail" VARCHAR(255),
"enrollmentId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "tickets" (
"id" SERIAL NOT NULL,
"isVirtual" BOOLEAN NOT NULL,
"description" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "eventTickets" (
"id" SERIAL NOT NULL,
"eventId" INTEGER NOT NULL,
"ticketId" INTEGER NOT NULL,
"price" INTEGER NOT NULL,
"name" TEXT,
"hotelPrice" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "enrollmentTicket" (
"id" SERIAL NOT NULL,
"enrollmentId" INTEGER NOT NULL,
"eventTicketId" INTEGER NOT NULL,
"roomId" INTEGER,

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

-- CreateTable
CREATE TABLE "rooms" (
"id" SERIAL NOT NULL,
"hotelId" INTEGER NOT NULL,
"number" TEXT NOT NULL,
"styleId" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "roomStyle" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"beds" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "hotels" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"imagePath" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");

-- CreateIndex
CREATE UNIQUE INDEX "enrollments_userId_key" ON "enrollments"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "adresses_enrollmentId_key" ON "adresses"("enrollmentId");

-- CreateIndex
CREATE UNIQUE INDEX "roomStyle_name_key" ON "roomStyle"("name");

-- CreateIndex
CREATE UNIQUE INDEX "hotels_name_key" ON "hotels"("name");

-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "enrollments" ADD CONSTRAINT "enrollments_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "adresses" ADD CONSTRAINT "adresses_enrollmentId_fkey" FOREIGN KEY ("enrollmentId") REFERENCES "enrollments"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "eventTickets" ADD CONSTRAINT "eventTickets_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "events"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "eventTickets" ADD CONSTRAINT "eventTickets_ticketId_fkey" FOREIGN KEY ("ticketId") REFERENCES "tickets"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "enrollmentTicket" ADD CONSTRAINT "enrollmentTicket_enrollmentId_fkey" FOREIGN KEY ("enrollmentId") REFERENCES "enrollments"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "enrollmentTicket" ADD CONSTRAINT "enrollmentTicket_eventTicketId_fkey" FOREIGN KEY ("eventTicketId") REFERENCES "eventTickets"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "enrollmentTicket" ADD CONSTRAINT "enrollmentTicket_roomId_fkey" FOREIGN KEY ("roomId") REFERENCES "rooms"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "rooms" ADD CONSTRAINT "rooms_styleId_fkey" FOREIGN KEY ("styleId") REFERENCES "roomStyle"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "rooms" ADD CONSTRAINT "rooms_hotelId_fkey" FOREIGN KEY ("hotelId") REFERENCES "hotels"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "eventTickets" ALTER COLUMN "hotelPrice" DROP NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:

- You are about to drop the column `hotelPrice` on the `eventTickets` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "eventTickets" DROP COLUMN "hotelPrice";

-- AlterTable
ALTER TABLE "events" ADD COLUMN "hotelPrice" INTEGER;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- Added the required column `withHotel` to the `enrollmentTicket` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE "enrollmentTicket" ADD COLUMN "withHotel" BOOLEAN NOT NULL;
Loading