Skip to content

Commit 0307553

Browse files
committed
Revert "Merge pull request #269 from codeableorg/branch-Jeff5"
This reverts commit 0200e5a, reversing changes made to 3689831.
1 parent 0200e5a commit 0307553

File tree

27 files changed

+250
-938
lines changed

27 files changed

+250
-938
lines changed

.react-router/types/+register.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ type Params = {
2929
"/account/orders": {};
3030
"/not-found": {};
3131
"/verify-email": {};
32-
"/chat": {};
3332
};

api/gemini-chat.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

api/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

prisma/initial_data.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,6 @@ export const categories = [
2929
},
3030
];
3131

32-
export const productVariant = [
33-
// Ejemplo para un producto Polo
34-
{ productTitle: "Polo React", sizes: ["small", "medium", "large"] },
35-
{ productTitle: "Polo JavaScript", sizes: ["small", "medium", "large"] },
36-
{ productTitle: "Polo Node.js", sizes: ["small", "medium", "large"] },
37-
{ productTitle: "Polo TypeScript", sizes: ["small", "medium", "large"] },
38-
{ productTitle: "Polo Backend Developer", sizes: ["small", "medium", "large"] },
39-
{ productTitle: "Polo Frontend Developer", sizes: ["small", "medium", "large"] },
40-
{ productTitle: "Polo Full-Stack Developer", sizes: ["small", "medium", "large"] },
41-
{ productTitle: "Polo It's A Feature", sizes: ["small", "medium", "large"] },
42-
{ productTitle: "Polo It Works On My Machine", sizes: ["small", "medium", "large"] },
43-
];
44-
45-
export const stickersVariant = [
46-
{ productTitle: "Sticker JavaScript", measure: ["3*3", "5*5", "10*10"] },
47-
{ productTitle: "Sticker React", measure: ["3*3", "5*5", "10*10"] },
48-
{ productTitle: "Sticker Git", measure: ["3*3", "5*5", "10*10"] },
49-
{ productTitle: "Sticker Docker", measure: ["3*3", "5*5", "10*10"] },
50-
{ productTitle: "Sticker Linux", measure: ["3*3", "5*5", "10*10"] },
51-
{ productTitle: "Sticker VS Code", measure: ["3*3", "5*5", "10*10"] },
52-
{ productTitle: "Sticker GitHub", measure: ["3*3", "5*5", "10*10"] },
53-
{ productTitle: "Sticker HTML", measure: ["3*3", "5*5", "10*10"] },
54-
];
55-
5632
export const products = [
5733
{
5834
title: "Polo React",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- CreateTable
2+
CREATE TABLE "users" (
3+
"id" SERIAL NOT NULL,
4+
"email" TEXT NOT NULL,
5+
"name" TEXT,
6+
"password" TEXT,
7+
"is_guest" BOOLEAN NOT NULL DEFAULT true,
8+
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
9+
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10+
11+
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
12+
);
13+
14+
-- CreateIndex
15+
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- AlterTable
2+
ALTER TABLE "users" ALTER COLUMN "created_at" SET DATA TYPE TIMESTAMP(0),
3+
ALTER COLUMN "updated_at" SET DATA TYPE TIMESTAMP(0);

prisma/migrations/20250826163128_init/migration.sql renamed to prisma/migrations/20250621053111_proposed_schema/migration.sql

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
-- CreateEnum
2-
CREATE TYPE "CategorySlug" AS ENUM ('polos', 'tazas', 'stickers');
3-
4-
-- CreateTable
5-
CREATE TABLE "users" (
6-
"id" SERIAL NOT NULL,
7-
"email" TEXT NOT NULL,
8-
"name" TEXT,
9-
"password" TEXT,
10-
"is_guest" BOOLEAN NOT NULL DEFAULT true,
11-
"created_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
12-
"updated_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
13-
14-
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
15-
);
16-
171
-- CreateTable
182
CREATE TABLE "categories" (
193
"id" SERIAL NOT NULL,
204
"title" TEXT NOT NULL,
21-
"slug" "CategorySlug" NOT NULL,
5+
"slug" TEXT NOT NULL,
226
"img_src" TEXT,
237
"alt" TEXT,
248
"description" TEXT,
@@ -45,25 +29,6 @@ CREATE TABLE "products" (
4529
CONSTRAINT "products_pkey" PRIMARY KEY ("id")
4630
);
4731

48-
-- CreateTable
49-
CREATE TABLE "ProductVariant" (
50-
"id" SERIAL NOT NULL,
51-
"productId" INTEGER NOT NULL,
52-
"size" TEXT NOT NULL,
53-
54-
CONSTRAINT "ProductVariant_pkey" PRIMARY KEY ("id")
55-
);
56-
57-
-- CreateTable
58-
CREATE TABLE "stickersVariant" (
59-
"id" SERIAL NOT NULL,
60-
"productId" INTEGER NOT NULL,
61-
"measure" TEXT NOT NULL,
62-
"price" DECIMAL(10,2) NOT NULL,
63-
64-
CONSTRAINT "stickersVariant_pkey" PRIMARY KEY ("id")
65-
);
66-
6732
-- CreateTable
6833
CREATE TABLE "carts" (
6934
"id" SERIAL NOT NULL,
@@ -78,11 +43,8 @@ CREATE TABLE "carts" (
7843
-- CreateTable
7944
CREATE TABLE "cart_items" (
8045
"id" SERIAL NOT NULL,
81-
"cartId" INTEGER NOT NULL,
82-
"productId" INTEGER NOT NULL,
83-
"productVariantId" INTEGER,
84-
"stickersVariantId" INTEGER,
85-
"price" DECIMAL(10,2) NOT NULL,
46+
"cart_id" INTEGER NOT NULL,
47+
"product_id" INTEGER NOT NULL,
8648
"quantity" INTEGER NOT NULL,
8749
"created_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
8850
"updated_at" TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -96,7 +58,6 @@ CREATE TABLE "orders" (
9658
"user_id" INTEGER NOT NULL,
9759
"total_amount" DECIMAL(10,2) NOT NULL,
9860
"email" TEXT NOT NULL,
99-
"payment_id" TEXT,
10061
"first_name" TEXT NOT NULL,
10162
"last_name" TEXT NOT NULL,
10263
"company" TEXT,
@@ -127,41 +88,26 @@ CREATE TABLE "order_items" (
12788
CONSTRAINT "order_items_pkey" PRIMARY KEY ("id")
12889
);
12990

130-
-- CreateIndex
131-
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
132-
13391
-- CreateIndex
13492
CREATE UNIQUE INDEX "categories_slug_key" ON "categories"("slug");
13593

13694
-- CreateIndex
13795
CREATE UNIQUE INDEX "carts_session_cart_id_key" ON "carts"("session_cart_id");
13896

13997
-- CreateIndex
140-
CREATE UNIQUE INDEX "cart_items_cartId_productId_productVariantId_stickersVarian_key" ON "cart_items"("cartId", "productId", "productVariantId", "stickersVariantId");
98+
CREATE UNIQUE INDEX "cart_items_cart_id_product_id_key" ON "cart_items"("cart_id", "product_id");
14199

142100
-- AddForeignKey
143101
ALTER TABLE "products" ADD CONSTRAINT "products_category_id_fkey" FOREIGN KEY ("category_id") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;
144102

145-
-- AddForeignKey
146-
ALTER TABLE "ProductVariant" ADD CONSTRAINT "ProductVariant_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
147-
148-
-- AddForeignKey
149-
ALTER TABLE "stickersVariant" ADD CONSTRAINT "stickersVariant_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
150-
151103
-- AddForeignKey
152104
ALTER TABLE "carts" ADD CONSTRAINT "carts_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
153105

154106
-- AddForeignKey
155-
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_cartId_fkey" FOREIGN KEY ("cartId") REFERENCES "carts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
156-
157-
-- AddForeignKey
158-
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
159-
160-
-- AddForeignKey
161-
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_productVariantId_fkey" FOREIGN KEY ("productVariantId") REFERENCES "ProductVariant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
107+
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_cart_id_fkey" FOREIGN KEY ("cart_id") REFERENCES "carts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
162108

163109
-- AddForeignKey
164-
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_stickersVariantId_fkey" FOREIGN KEY ("stickersVariantId") REFERENCES "stickersVariant"("id") ON DELETE SET NULL ON UPDATE CASCADE;
110+
ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
165111

166112
-- AddForeignKey
167113
ALTER TABLE "orders" ADD CONSTRAINT "orders_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- CreateEnum
2+
CREATE TYPE "CategorySlug" AS ENUM ('polos', 'tazas', 'stickers');
3+
4+
-- AlterTable: Add temporary column
5+
ALTER TABLE "categories" ADD COLUMN "slug_new" "CategorySlug";
6+
7+
-- Update data: Convert existing string values to enum
8+
UPDATE "categories" SET "slug_new" =
9+
CASE
10+
WHEN "slug" = 'polos' THEN 'polos'::"CategorySlug"
11+
WHEN "slug" = 'tazas' THEN 'tazas'::"CategorySlug"
12+
WHEN "slug" = 'stickers' THEN 'stickers'::"CategorySlug"
13+
ELSE 'polos'::"CategorySlug" -- default fallback
14+
END;
15+
16+
-- Make the new column NOT NULL
17+
ALTER TABLE "categories" ALTER COLUMN "slug_new" SET NOT NULL;
18+
19+
-- Drop the old column
20+
ALTER TABLE "categories" DROP COLUMN "slug";
21+
22+
-- Rename the new column
23+
ALTER TABLE "categories" RENAME COLUMN "slug_new" TO "slug";
24+
25+
-- Add unique constraint
26+
ALTER TABLE "categories" ADD CONSTRAINT "categories_slug_key" UNIQUE ("slug");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "orders" ADD COLUMN "payment_id" TEXT;

prisma/schema.prisma

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,17 @@ model Category {
5151
}
5252

5353
model Product {
54-
id Int @id @default(autoincrement())
54+
id Int @id @default(autoincrement())
5555
title String
56-
imgSrc String @map("img_src")
56+
imgSrc String @map("img_src")
5757
alt String?
58-
price Decimal @db.Decimal(10, 2)
58+
price Decimal @db.Decimal(10, 2)
5959
description String?
60-
categoryId Int? @map("category_id")
61-
isOnSale Boolean @default(false) @map("is_on_sale")
60+
categoryId Int? @map("category_id")
61+
isOnSale Boolean @default(false) @map("is_on_sale")
6262
features String[]
63-
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
64-
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
65-
variants ProductVariant[]
66-
stickersVariants stickersVariant[]
63+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
64+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
6765
6866
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
6967
cartItems CartItem[]
@@ -72,25 +70,6 @@ model Product {
7270
@@map("products")
7371
}
7472

75-
model ProductVariant {
76-
id Int @id @default(autoincrement())
77-
product Product @relation(fields: [productId], references: [id])
78-
productId Int
79-
size String // 'small', 'medium', 'large'
80-
81-
cartItems CartItem[] @relation("CartItemToProductVariant")
82-
}
83-
84-
model stickersVariant {
85-
id Int @id @default(autoincrement())
86-
product Product @relation(fields: [productId], references: [id])
87-
productId Int
88-
measure String // '3*3', '5*5', '10*10'
89-
price Decimal @db.Decimal(10, 2)
90-
91-
cartItems CartItem[] @relation("CartItemTostickersVariant")
92-
}
93-
9473
model Cart {
9574
id Int @id @default(autoincrement())
9675
sessionCartId String @unique @default(dbgenerated("gen_random_uuid()")) @map("session_cart_id") @db.Uuid
@@ -105,22 +84,17 @@ model Cart {
10584
}
10685

10786
model CartItem {
108-
id Int @id @default(autoincrement())
109-
cartId Int
110-
productId Int
111-
productVariantId Int?
112-
stickersVariantId Int?
113-
price Decimal @db.Decimal(10, 2)
114-
quantity Int
115-
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
116-
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
87+
id Int @id @default(autoincrement())
88+
cartId Int @map("cart_id")
89+
productId Int @map("product_id")
90+
quantity Int
91+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0)
92+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamp(0)
11793
118-
cart Cart @relation(fields: [cartId], references: [id], onDelete: Cascade)
119-
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
120-
productVariant ProductVariant? @relation("CartItemToProductVariant", fields: [productVariantId], references: [id])
121-
stickersVariant stickersVariant? @relation("CartItemTostickersVariant", fields: [stickersVariantId], references: [id])
94+
cart Cart @relation(fields: [cartId], references: [id], onDelete: Cascade)
95+
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
12296
123-
@@unique([cartId, productId, productVariantId, stickersVariantId], name: "unique_cart_item")
97+
@@unique([cartId, productId], name: "unique_cart_item")
12498
@@map("cart_items")
12599
}
126100

0 commit comments

Comments
 (0)