diff --git a/Websites/nextjs-dashboard/bun.lockb b/Websites/nextjs-dashboard/bun.lockb index 9ae4cff..0b82772 100755 Binary files a/Websites/nextjs-dashboard/bun.lockb and b/Websites/nextjs-dashboard/bun.lockb differ diff --git a/Websites/nextjs-dashboard/package.json b/Websites/nextjs-dashboard/package.json index a1bfd46..0642628 100644 --- a/Websites/nextjs-dashboard/package.json +++ b/Websites/nextjs-dashboard/package.json @@ -1,19 +1,24 @@ { "private": true, "scripts": { - "build": "next build", + "build": "prisma generate && next build", "dev": "next dev", - "start": "next start" + "start": "next start", + "introspect": "drizzle-kit introspect: pg --config=drizzle.config.ts", + "generate": "drizzle-kit generate:pg --config=drizzle.config.ts" + }, + "prisma":{ + "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" }, "dependencies": { "@heroicons/react": "^2.0.18", + "@prisma/client": "5.5.2", "@tailwindcss/forms": "^0.5.6", "@types/node": "^20.8.9", "@vercel/postgres": "^0.5.0", "autoprefixer": "10.4.15", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", - "drizzle-orm": "^0.28.6", "lucide-react": "^0.290.0", "next": "^14.0.0", "postcss": "8.4.31", @@ -26,15 +31,12 @@ "tailwindcss": "3.3.3", "tailwindcss-animate": "^1.0.7", "typescript": "^5.2.2", - "zod": "^3.22.2", - "dotenv":"16.3.1" + "zod": "^3.22.2" }, "devDependencies": { "@types/bcrypt": "^5.0.1", "@types/react": "18.2.21", "@types/react-dom": "18.2.14", - "dotenv": "^16.3.1", - "drizzle-kit": "^0.19.13", "prettier": "^3.0.3", "ts-node": "^10.9.1" }, diff --git a/Websites/nextjs-dashboard/prisma/migrations/20231029075620_init/migration.sql b/Websites/nextjs-dashboard/prisma/migrations/20231029075620_init/migration.sql new file mode 100644 index 0000000..9d65242 --- /dev/null +++ b/Websites/nextjs-dashboard/prisma/migrations/20231029075620_init/migration.sql @@ -0,0 +1,9 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" SERIAL NOT NULL, + "email" TEXT NOT NULL, + "password" TEXT NOT NULL, + "name" TEXT, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); diff --git a/Websites/nextjs-dashboard/prisma/migrations/20231029083932_init/migration.sql b/Websites/nextjs-dashboard/prisma/migrations/20231029083932_init/migration.sql new file mode 100644 index 0000000..5e77f8e --- /dev/null +++ b/Websites/nextjs-dashboard/prisma/migrations/20231029083932_init/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[email]` on the table `User` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); diff --git a/Websites/nextjs-dashboard/prisma/migrations/migration_lock.toml b/Websites/nextjs-dashboard/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..fbffa92 --- /dev/null +++ b/Websites/nextjs-dashboard/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "postgresql" \ No newline at end of file diff --git a/Websites/nextjs-dashboard/prisma/schema.prisma b/Websites/nextjs-dashboard/prisma/schema.prisma index d205f42..bf79b82 100644 --- a/Websites/nextjs-dashboard/prisma/schema.prisma +++ b/Websites/nextjs-dashboard/prisma/schema.prisma @@ -9,3 +9,10 @@ datasource db { provider = "postgresql" url = env("DATABASE_URL") } + +model User { + id Int @id @default(autoincrement()) + email String @unique + password String + name String? +} diff --git a/Websites/nextjs-dashboard/prisma/seed.ts b/Websites/nextjs-dashboard/prisma/seed.ts new file mode 100644 index 0000000..47336c0 --- /dev/null +++ b/Websites/nextjs-dashboard/prisma/seed.ts @@ -0,0 +1,23 @@ +import { PrismaClient } from '@prisma/client' + +const prisma = new PrismaClient() + +async function main() { + const user = await prisma.user.upsert({ + where: { email: 'test@test.com' }, + update: {}, + create: { + email: 'test@test.com', + name: 'Test User', + password: `testing1234` + } + }) + console.log({ user }) +} +main() + .then(() => prisma.$disconnect()) + .catch(async (e) => { + console.error(e) + await prisma.$disconnect() + process.exit(1) + }) \ No newline at end of file diff --git a/Websites/nextjs-dashboard/schema.ts b/Websites/nextjs-dashboard/schema.ts deleted file mode 100644 index 8d0924b..0000000 --- a/Websites/nextjs-dashboard/schema.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { integer, serial, text, pgTable } from 'drizzle-orm/pg-core'; -import { relations } from 'drizzle-orm'; - -export const users = pgTable('users', { - id: serial('id').primaryKey(), - name: text('name').notNull(), -}); - -export const usersRelations = relations(users, ({ many }) => ({ - posts: many(posts), -})); - -export const posts = pgTable('posts', { - id: serial('id').primaryKey(), - content: text('content').notNull(), - authorId: integer('author_id').notNull(), -}); - -export const postsRelations = relations(posts, ({ one }) => ({ - author: one(users, { fields: [posts.authorId], references: [users.id] }), -})); \ No newline at end of file