Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"watch": ["dist"],
"ignore": []
"watch": ["src"],
"ignore": ["dist", "node_modules"],
"ext": "ts,js,json",
"exec": "node --experimental-loader tsc-module-loader dist/index.js"
}
2,392 changes: 1,069 additions & 1,323 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@
"license": "ISC",
"dependencies": {
"@apollo/server": "^4.9.5",
"@prisma/client": "^5.10.2",
"@prisma/client": "^5.14.0",
"@types/bcrypt": "^5.0.2",
"bc": "^0.1.1",
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"express": "^4.18.2",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"next": "^14.1.0",
"jsonwebtoken": "^9.0.2"
"jsonwebtoken": "^9.0.2",
"next": "^14.1.0"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
"@types/jsonwebtoken": "^9.0.6",
"@types/node": "^20.11.21",
Expand Down
159 changes: 159 additions & 0 deletions prisma/migrations/20240425194555_add_default/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*
Warnings:

- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `createdAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `id` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `User` table. All the data in the column will be lost.
- You are about to drop the `Playlist` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `PlaylistToSong` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Products` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Song` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail.
- Added the required column `email` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `shippingAddressLine1` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `shippingAddressLine2` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `shippingCity` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `shippingCountry` to the `User` table without a default value. This is not possible if the table is not empty.
- Added the required column `shippingZip` to the `User` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "OrderStatus" AS ENUM ('PENDING', 'COMPLETED');

-- DropForeignKey
ALTER TABLE "Playlist" DROP CONSTRAINT "Playlist_userId_fkey";

-- DropForeignKey
ALTER TABLE "PlaylistToSong" DROP CONSTRAINT "PlaylistToSong_playlistId_fkey";

-- DropForeignKey
ALTER TABLE "PlaylistToSong" DROP CONSTRAINT "PlaylistToSong_songId_fkey";

-- AlterTable
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
DROP COLUMN "createdAt",
DROP COLUMN "id",
DROP COLUMN "updatedAt",
ADD COLUMN "Id" SERIAL NOT NULL,
ADD COLUMN "email" TEXT NOT NULL,
ADD COLUMN "password" TEXT NOT NULL,
ADD COLUMN "shippingAddressLine1" TEXT NOT NULL,
ADD COLUMN "shippingAddressLine2" TEXT NOT NULL,
ADD COLUMN "shippingCity" TEXT NOT NULL,
ADD COLUMN "shippingCountry" TEXT NOT NULL,
ADD COLUMN "shippingZip" TEXT NOT NULL,
ALTER COLUMN "name" DROP NOT NULL,
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("Id");

-- DropTable
DROP TABLE "Playlist";

-- DropTable
DROP TABLE "PlaylistToSong";

-- DropTable
DROP TABLE "Products";

-- DropTable
DROP TABLE "Song";

-- CreateTable
CREATE TABLE "Inventory" (
"id" SERIAL NOT NULL,
"inventoryId" INTEGER NOT NULL,
"availableQuantity" INTEGER NOT NULL,
"costOfProduction" INTEGER NOT NULL,
"loadTime" INTEGER NOT NULL,
"reorderPoint" INTEGER NOT NULL,
"reorderQuantity" INTEGER NOT NULL,
"safetyStock" INTEGER NOT NULL,
"stockOnOrder" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "Order" (
"id" SERIAL NOT NULL,
"customerName" TEXT NOT NULL,
"customerEmail" TEXT NOT NULL,
"customerPhoneNum" TEXT NOT NULL,
"billingAddressLine1" TEXT NOT NULL,
"billingAddressLine2" TEXT NOT NULL,
"billingCity" TEXT NOT NULL,
"billingZip" TEXT NOT NULL,
"billingCountry" TEXT NOT NULL,
"shippingAddressLine1" TEXT NOT NULL,
"shippingAddressLine2" TEXT NOT NULL,
"shippingCity" TEXT NOT NULL,
"shippingZip" TEXT NOT NULL,
"shippingCountry" TEXT NOT NULL,
"status" "OrderStatus" NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "Product" (
"id" SERIAL NOT NULL,
"name" TEXT,
"price" INTEGER NOT NULL,
"description" TEXT NOT NULL,
"details" TEXT NOT NULL,
"weight" INTEGER NOT NULL,
"height" INTEGER NOT NULL,
"width" INTEGER NOT NULL,
"depth" INTEGER NOT NULL,
"specialLabelNeeded" BOOLEAN NOT NULL,

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

-- CreateTable
CREATE TABLE "ProductToOrder" (
"productId" INTEGER NOT NULL,
"orderId" INTEGER NOT NULL,
"quantity" INTEGER NOT NULL,

CONSTRAINT "ProductToOrder_pkey" PRIMARY KEY ("productId","orderId")
);

-- CreateTable
CREATE TABLE "ProductoToTag" (
"productId" INTEGER NOT NULL,
"tagName" TEXT NOT NULL,

CONSTRAINT "ProductoToTag_pkey" PRIMARY KEY ("productId")
);

-- CreateTable
CREATE TABLE "Tag" (
"name" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "Inventory_inventoryId_key" ON "Inventory"("inventoryId");

-- CreateIndex
CREATE UNIQUE INDEX "Tag_name_key" ON "Tag"("name");

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- AddForeignKey
ALTER TABLE "Inventory" ADD CONSTRAINT "Inventory_inventoryId_fkey" FOREIGN KEY ("inventoryId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductToOrder" ADD CONSTRAINT "ProductToOrder_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductToOrder" ADD CONSTRAINT "ProductToOrder_orderId_fkey" FOREIGN KEY ("orderId") REFERENCES "Order"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductoToTag" ADD CONSTRAINT "ProductoToTag_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductoToTag" ADD CONSTRAINT "ProductoToTag_tagName_fkey" FOREIGN KEY ("tagName") REFERENCES "Tag"("name") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- CreateTable
CREATE TABLE "Authentication" (
"id" SERIAL NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "Authentication_email_key" ON "Authentication"("email");
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Warnings:

- The primary key for the `Authentication` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `Inventory` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Inventory` table. All the data in the column will be lost.
- The primary key for the `Order` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `Order` table. All the data in the column will be lost.
- The primary key for the `Product` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `ProductToOrder` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `ProductoToTag` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The required column `orderId` was added to the `Order` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.

*/
-- DropForeignKey
ALTER TABLE "Inventory" DROP CONSTRAINT "Inventory_inventoryId_fkey";

-- DropForeignKey
ALTER TABLE "ProductToOrder" DROP CONSTRAINT "ProductToOrder_orderId_fkey";

-- DropForeignKey
ALTER TABLE "ProductToOrder" DROP CONSTRAINT "ProductToOrder_productId_fkey";

-- DropForeignKey
ALTER TABLE "ProductoToTag" DROP CONSTRAINT "ProductoToTag_productId_fkey";

-- DropIndex
DROP INDEX "Inventory_inventoryId_key";

-- AlterTable
ALTER TABLE "Authentication" DROP CONSTRAINT "Authentication_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "Authentication_pkey" PRIMARY KEY ("id");
DROP SEQUENCE "Authentication_id_seq";

-- AlterTable
ALTER TABLE "Inventory" DROP CONSTRAINT "Inventory_pkey",
DROP COLUMN "id",
ALTER COLUMN "inventoryId" SET DATA TYPE TEXT,
ADD CONSTRAINT "Inventory_pkey" PRIMARY KEY ("inventoryId");

-- AlterTable
ALTER TABLE "Order" DROP CONSTRAINT "Order_pkey",
DROP COLUMN "id",
ADD COLUMN "orderId" TEXT NOT NULL,
ADD CONSTRAINT "Order_pkey" PRIMARY KEY ("orderId");

-- AlterTable
ALTER TABLE "Product" DROP CONSTRAINT "Product_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ADD CONSTRAINT "Product_pkey" PRIMARY KEY ("id");
DROP SEQUENCE "Product_id_seq";

-- AlterTable
ALTER TABLE "ProductToOrder" DROP CONSTRAINT "ProductToOrder_pkey",
ALTER COLUMN "productId" SET DATA TYPE TEXT,
ALTER COLUMN "orderId" SET DATA TYPE TEXT,
ADD CONSTRAINT "ProductToOrder_pkey" PRIMARY KEY ("productId", "orderId");

-- AlterTable
ALTER TABLE "ProductoToTag" DROP CONSTRAINT "ProductoToTag_pkey",
ALTER COLUMN "productId" SET DATA TYPE TEXT,
ADD CONSTRAINT "ProductoToTag_pkey" PRIMARY KEY ("productId");

-- AlterTable
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
ALTER COLUMN "Id" DROP DEFAULT,
ALTER COLUMN "Id" SET DATA TYPE TEXT,
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("Id");
DROP SEQUENCE "User_Id_seq";

-- AddForeignKey
ALTER TABLE "Inventory" ADD CONSTRAINT "Inventory_inventoryId_fkey" FOREIGN KEY ("inventoryId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductToOrder" ADD CONSTRAINT "ProductToOrder_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductToOrder" ADD CONSTRAINT "ProductToOrder_orderId_fkey" FOREIGN KEY ("orderId") REFERENCES "Order"("orderId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ProductoToTag" ADD CONSTRAINT "ProductoToTag_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:

- A unique constraint covering the columns `[password]` on the table `Authentication` will be added. If there are existing duplicate values, this will fail.

*/
-- CreateIndex
CREATE UNIQUE INDEX "Authentication_password_key" ON "Authentication"("password");
5 changes: 5 additions & 0 deletions prisma/models/Authentication.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
model Authentication {
id String @id @default(cuid())
email String @unique
password String @unique
}
11 changes: 11 additions & 0 deletions prisma/models/Inventory.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
model Inventory {
id String @id @default(cuid())
available_quantity Int
cost_of_production Int
load_time Int
reorder_point Int
reorder_quantity Int
safety_stock Int
stock_on_order Int
}

26 changes: 26 additions & 0 deletions prisma/models/Order.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
enum OrderStatus{
PENDING
COMPLETED
}


model Order {
orderId String @id @default(uuid())
customer_name String
customer_email String
customer_phone_num String
billing_address_line_1 String
billing_address_line_2 String
billing_city String
billing_zip String
billing_country String
shipping_address_line_1 String
shipping_address_line_2 String
shipping_city String
shipping_zip String
shipping_country String
status OrderStatus
created_at DateTime @default(now())

}

23 changes: 12 additions & 11 deletions prisma/models/Product.prisma
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
model Products {
id String @id @default(uuid())
name String
price Int
description String
details String
weight Int
height Int
width Int
depth Int
special_label_needed Boolean
model Product {
id String @id @default(cuid())
name String?
price Int
description String
details String
weight Int
height Int
width Int
depth Int
special_label_needed Boolean
}

6 changes: 6 additions & 0 deletions prisma/models/ProductToOrder.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
model ProductToOrder {
product_id String @id @default(uuid())
order_id String
quantity Int
}

3 changes: 3 additions & 0 deletions prisma/models/Tag.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
model Tag {
name String @id @default(cuid())
}
12 changes: 12 additions & 0 deletions prisma/models/User.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
model User {
id String @id @default(cuid())
name String?
email String @unique
password String
shipping_address_line_1 String
shipping_address_line_2 String
shipping_city String
shipping_zip String
shipping_country String

}
Loading