diff --git a/package-lock.json b/package-lock.json index 9aeef9e..26d4997 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "express": "^4.18.2", "node-cron": "^3.0.3", "openai": "^4.104.0", + "pnpm": "^10.29.2", "pokersolver": "^2.1.4", "prisma": "^6.19.2", "socket.io": "^4.8.1", @@ -740,6 +741,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1651,6 +1653,7 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -3323,6 +3326,22 @@ "pathe": "^2.0.3" } }, + "node_modules/pnpm": { + "version": "10.29.2", + "resolved": "https://registry.npmjs.org/pnpm/-/pnpm-10.29.2.tgz", + "integrity": "sha512-vvQ/p1nZH9LaSzGaWg0T73pFu5haPXNCBYRw+dIFGjuoZ05ilnJlRobvlEOtE6gtor657rPgIhyHuBVP/510uA==", + "license": "MIT", + "bin": { + "pnpm": "bin/pnpm.cjs", + "pnpx": "bin/pnpx.cjs" + }, + "engines": { + "node": ">=18.12" + }, + "funding": { + "url": "https://opencollective.com/pnpm" + } + }, "node_modules/pokersolver": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/pokersolver/-/pokersolver-2.1.4.tgz", @@ -3364,6 +3383,7 @@ "integrity": "sha512-XTKeKxtQElcq3U9/jHyxSPgiRgeYDKxWTPOf6NkXA0dNj5j40MfEsZkMbyNpwDWCUv7YBFUl7I2VK/6ALbmhEg==", "hasInstallScript": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@prisma/config": "6.19.2", "@prisma/engines": "6.19.2" diff --git a/package.json b/package.json index 4fd17a9..a009a26 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "express": "^4.18.2", "node-cron": "^3.0.3", "openai": "^4.104.0", + "pnpm": "^10.29.2", "pokersolver": "^2.1.4", "prisma": "^6.19.2", "socket.io": "^4.8.1", diff --git a/prisma/migrations/20260210015517_use_current_timestamp_defaults/migration.sql b/prisma/migrations/20260210015517_use_current_timestamp_defaults/migration.sql deleted file mode 100644 index 95c8a2e..0000000 --- a/prisma/migrations/20260210015517_use_current_timestamp_defaults/migration.sql +++ /dev/null @@ -1,67 +0,0 @@ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_bids" ( - "id" TEXT NOT NULL PRIMARY KEY, - "bidder_id" TEXT NOT NULL, - "market_offer_id" TEXT NOT NULL, - "offer_amount" INTEGER NOT NULL, - "offered_at" TEXT DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "bids_bidder_id_fkey" FOREIGN KEY ("bidder_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "bids_market_offer_id_fkey" FOREIGN KEY ("market_offer_id") REFERENCES "market_offers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_bids" ("bidder_id", "id", "market_offer_id", "offer_amount", "offered_at") SELECT "bidder_id", "id", "market_offer_id", "offer_amount", "offered_at" FROM "bids"; -DROP TABLE "bids"; -ALTER TABLE "new_bids" RENAME TO "bids"; -CREATE TABLE "new_logs" ( - "id" TEXT NOT NULL PRIMARY KEY, - "user_id" TEXT NOT NULL, - "action" TEXT, - "target_user_id" TEXT, - "coins_amount" INTEGER, - "user_new_amount" INTEGER, - "created_at" TEXT DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "logs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "logs_target_user_id_fkey" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_logs" ("action", "coins_amount", "created_at", "id", "target_user_id", "user_id", "user_new_amount") SELECT "action", "coins_amount", "created_at", "id", "target_user_id", "user_id", "user_new_amount" FROM "logs"; -DROP TABLE "logs"; -ALTER TABLE "new_logs" RENAME TO "logs"; -CREATE TABLE "new_market_offers" ( - "id" TEXT NOT NULL PRIMARY KEY, - "skin_uuid" TEXT NOT NULL, - "seller_id" TEXT NOT NULL, - "starting_price" INTEGER NOT NULL, - "buyout_price" INTEGER, - "final_price" INTEGER, - "status" TEXT NOT NULL, - "posted_at" TEXT DEFAULT CURRENT_TIMESTAMP, - "opening_at" TEXT NOT NULL, - "closing_at" TEXT NOT NULL, - "buyer_id" TEXT, - CONSTRAINT "market_offers_skin_uuid_fkey" FOREIGN KEY ("skin_uuid") REFERENCES "skins" ("uuid") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "market_offers_seller_id_fkey" FOREIGN KEY ("seller_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - CONSTRAINT "market_offers_buyer_id_fkey" FOREIGN KEY ("buyer_id") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_market_offers" ("buyer_id", "buyout_price", "closing_at", "final_price", "id", "opening_at", "posted_at", "seller_id", "skin_uuid", "starting_price", "status") SELECT "buyer_id", "buyout_price", "closing_at", "final_price", "id", "opening_at", "posted_at", "seller_id", "skin_uuid", "starting_price", "status" FROM "market_offers"; -DROP TABLE "market_offers"; -ALTER TABLE "new_market_offers" RENAME TO "market_offers"; -CREATE TABLE "new_transactions" ( - "id" TEXT NOT NULL PRIMARY KEY, - "session_id" TEXT NOT NULL, - "user_id" TEXT NOT NULL, - "coins_amount" INTEGER NOT NULL, - "amount_cents" INTEGER NOT NULL, - "currency" TEXT NOT NULL DEFAULT 'eur', - "customer_email" TEXT, - "customer_name" TEXT, - "payment_status" TEXT NOT NULL, - "created_at" TEXT DEFAULT CURRENT_TIMESTAMP, - CONSTRAINT "transactions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); -INSERT INTO "new_transactions" ("amount_cents", "coins_amount", "created_at", "currency", "customer_email", "customer_name", "id", "payment_status", "session_id", "user_id") SELECT "amount_cents", "coins_amount", "created_at", "currency", "customer_email", "customer_name", "id", "payment_status", "session_id", "user_id" FROM "transactions"; -DROP TABLE "transactions"; -ALTER TABLE "new_transactions" RENAME TO "transactions"; -CREATE UNIQUE INDEX "transactions_session_id_key" ON "transactions"("session_id"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/0_init/migration.sql b/prisma/migrations/20260210172326_init/migration.sql similarity index 92% rename from prisma/migrations/0_init/migration.sql rename to prisma/migrations/20260210172326_init/migration.sql index 3bf510d..3e53e44 100644 --- a/prisma/migrations/0_init/migration.sql +++ b/prisma/migrations/20260210172326_init/migration.sql @@ -40,9 +40,9 @@ CREATE TABLE "market_offers" ( "buyout_price" INTEGER, "final_price" INTEGER, "status" TEXT NOT NULL, - "posted_at" TEXT DEFAULT '', - "opening_at" TEXT NOT NULL, - "closing_at" TEXT NOT NULL, + "posted_at" DATETIME DEFAULT CURRENT_TIMESTAMP, + "opening_at" DATETIME NOT NULL, + "closing_at" DATETIME NOT NULL, "buyer_id" TEXT, CONSTRAINT "market_offers_skin_uuid_fkey" FOREIGN KEY ("skin_uuid") REFERENCES "skins" ("uuid") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "market_offers_seller_id_fkey" FOREIGN KEY ("seller_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, @@ -55,7 +55,7 @@ CREATE TABLE "bids" ( "bidder_id" TEXT NOT NULL, "market_offer_id" TEXT NOT NULL, "offer_amount" INTEGER NOT NULL, - "offered_at" TEXT DEFAULT '', + "offered_at" DATETIME DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "bids_bidder_id_fkey" FOREIGN KEY ("bidder_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "bids_market_offer_id_fkey" FOREIGN KEY ("market_offer_id") REFERENCES "market_offers" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); @@ -68,7 +68,7 @@ CREATE TABLE "logs" ( "target_user_id" TEXT, "coins_amount" INTEGER, "user_new_amount" INTEGER, - "created_at" TEXT DEFAULT '', + "created_at" DATETIME DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "logs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "logs_target_user_id_fkey" FOREIGN KEY ("target_user_id") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); @@ -85,7 +85,7 @@ CREATE TABLE "games" ( "p1_new_elo" INTEGER, "p2_new_elo" INTEGER, "type" TEXT, - "timestamp" TEXT, + "timestamp" DATETIME DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "games_p1_fkey" FOREIGN KEY ("p1") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT "games_p2_fkey" FOREIGN KEY ("p2") REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE ); @@ -129,10 +129,9 @@ CREATE TABLE "transactions" ( "customer_email" TEXT, "customer_name" TEXT, "payment_status" TEXT NOT NULL, - "created_at" TEXT DEFAULT '', + "created_at" DATETIME DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "transactions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE ); -- CreateIndex CREATE UNIQUE INDEX "transactions_session_id_key" ON "transactions"("session_id"); - diff --git a/prisma/schema.prisma b/prisma/schema.prisma index fac087b..da65b26 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -64,9 +64,9 @@ model MarketOffer { buyoutPrice Int? @map("buyout_price") finalPrice Int? @map("final_price") status String - postedAt String? @default(dbgenerated("CURRENT_TIMESTAMP")) @map("posted_at") - openingAt String @map("opening_at") - closingAt String @map("closing_at") + postedAt DateTime? @default(now()) @map("posted_at") + openingAt DateTime @map("opening_at") + closingAt DateTime @map("closing_at") buyerId String? @map("buyer_id") skin Skin @relation(fields: [skinUuid], references: [uuid]) @@ -82,7 +82,7 @@ model Bid { bidderId String @map("bidder_id") marketOfferId String @map("market_offer_id") offerAmount Int @map("offer_amount") - offeredAt String? @default(dbgenerated("CURRENT_TIMESTAMP")) @map("offered_at") + offeredAt DateTime? @default(now()) @map("offered_at") bidder User @relation(fields: [bidderId], references: [id]) marketOffer MarketOffer @relation(fields: [marketOfferId], references: [id]) @@ -97,7 +97,7 @@ model Log { targetUserId String? @map("target_user_id") coinsAmount Int? @map("coins_amount") userNewAmount Int? @map("user_new_amount") - createdAt String? @default(dbgenerated("CURRENT_TIMESTAMP")) @map("created_at") + createdAt DateTime? @default(now()) @map("created_at") user User @relation("UserLogs", fields: [userId], references: [id]) targetUser User? @relation("TargetUserLogs", fields: [targetUserId], references: [id]) @@ -116,7 +116,7 @@ model Game { p1NewElo Int? @map("p1_new_elo") p2NewElo Int? @map("p2_new_elo") type String? - timestamp String? + timestamp DateTime? @default(now()) @map("timestamp") player1 User @relation("Player1", fields: [p1], references: [id]) player2 User? @relation("Player2", fields: [p2], references: [id]) @@ -167,7 +167,7 @@ model Transaction { customerEmail String? @map("customer_email") customerName String? @map("customer_name") paymentStatus String @map("payment_status") - createdAt String? @default(dbgenerated("CURRENT_TIMESTAMP")) @map("created_at") + createdAt DateTime? @default(now()) @map("created_at") user User @relation(fields: [userId], references: [id])