hPiBot openclaw ve Opencode ilk versiyonu[B
This commit is contained in:
BIN
backend/prisma/dev.db
Normal file
BIN
backend/prisma/dev.db
Normal file
Binary file not shown.
@@ -0,0 +1,220 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `users` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`username` VARCHAR(191) NOT NULL,
|
||||
`firstName` VARCHAR(191) NOT NULL,
|
||||
`lastName` VARCHAR(191) NOT NULL,
|
||||
`password` VARCHAR(191) NULL,
|
||||
`avatar` VARCHAR(191) NULL,
|
||||
`googleId` VARCHAR(191) NULL,
|
||||
`authProvider` VARCHAR(191) NOT NULL DEFAULT 'local',
|
||||
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
||||
`isAdmin` BOOLEAN NOT NULL DEFAULT false,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
`lastLoginAt` DATETIME(3) NULL,
|
||||
|
||||
UNIQUE INDEX `users_email_key`(`email`),
|
||||
UNIQUE INDEX `users_username_key`(`username`),
|
||||
UNIQUE INDEX `users_googleId_key`(`googleId`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `device_tokens` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`token` VARCHAR(191) NOT NULL,
|
||||
`platform` VARCHAR(191) NOT NULL,
|
||||
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `device_tokens_token_key`(`token`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `shopping_lists` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`description` VARCHAR(191) NULL,
|
||||
`color` VARCHAR(191) NOT NULL DEFAULT '#2196F3',
|
||||
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
||||
`ownerId` VARCHAR(191) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `list_members` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`listId` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`role` VARCHAR(191) NOT NULL DEFAULT 'member',
|
||||
`joinedAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
UNIQUE INDEX `list_members_listId_userId_key`(`listId`, `userId`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `list_invitations` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`listId` VARCHAR(191) NOT NULL,
|
||||
`email` VARCHAR(191) NOT NULL,
|
||||
`role` VARCHAR(191) NOT NULL DEFAULT 'member',
|
||||
`token` VARCHAR(191) NOT NULL,
|
||||
`isUsed` BOOLEAN NOT NULL DEFAULT false,
|
||||
`expiresAt` DATETIME(3) NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
UNIQUE INDEX `list_invitations_token_key`(`token`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `categories` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`description` VARCHAR(191) NULL,
|
||||
`icon` VARCHAR(191) NULL,
|
||||
`color` VARCHAR(191) NOT NULL DEFAULT '#757575',
|
||||
`sortOrder` INTEGER NOT NULL DEFAULT 0,
|
||||
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `categories_name_key`(`name`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `products` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NOT NULL,
|
||||
`description` VARCHAR(191) NULL,
|
||||
`barcode` VARCHAR(191) NULL,
|
||||
`brand` VARCHAR(191) NULL,
|
||||
`unit` VARCHAR(191) NULL,
|
||||
`categoryId` VARCHAR(191) NULL,
|
||||
`image` VARCHAR(191) NULL,
|
||||
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `products_barcode_key`(`barcode`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `list_items` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`listId` VARCHAR(191) NOT NULL,
|
||||
`productId` VARCHAR(191) NULL,
|
||||
`customName` VARCHAR(191) NULL,
|
||||
`quantity` DOUBLE NOT NULL DEFAULT 1,
|
||||
`unit` VARCHAR(191) NOT NULL DEFAULT 'adet',
|
||||
`price` DECIMAL(10, 2) NULL,
|
||||
`note` VARCHAR(191) NULL,
|
||||
`isPurchased` BOOLEAN NOT NULL DEFAULT false,
|
||||
`purchasedAt` DATETIME(3) NULL,
|
||||
`purchasedBy` VARCHAR(191) NULL,
|
||||
`priority` INTEGER NOT NULL DEFAULT 0,
|
||||
`sortOrder` INTEGER NOT NULL DEFAULT 0,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `price_history` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`productId` VARCHAR(191) NOT NULL,
|
||||
`price` DECIMAL(10, 2) NOT NULL,
|
||||
`store` VARCHAR(191) NULL,
|
||||
`location` VARCHAR(191) NULL,
|
||||
`source` VARCHAR(191) NOT NULL DEFAULT 'user',
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `notifications` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`title` VARCHAR(191) NOT NULL,
|
||||
`message` VARCHAR(191) NOT NULL,
|
||||
`type` VARCHAR(191) NOT NULL,
|
||||
`data` JSON NULL,
|
||||
`isRead` BOOLEAN NOT NULL DEFAULT false,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `activities` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`listId` VARCHAR(191) NOT NULL,
|
||||
`userId` VARCHAR(191) NOT NULL,
|
||||
`action` VARCHAR(191) NOT NULL,
|
||||
`details` JSON NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `settings` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`key` VARCHAR(191) NOT NULL,
|
||||
`value` VARCHAR(191) NOT NULL,
|
||||
`type` VARCHAR(191) NOT NULL DEFAULT 'string',
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `settings_key_key`(`key`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `device_tokens` ADD CONSTRAINT `device_tokens_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `shopping_lists` ADD CONSTRAINT `shopping_lists_ownerId_fkey` FOREIGN KEY (`ownerId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `list_members` ADD CONSTRAINT `list_members_listId_fkey` FOREIGN KEY (`listId`) REFERENCES `shopping_lists`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `list_members` ADD CONSTRAINT `list_members_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `list_invitations` ADD CONSTRAINT `list_invitations_listId_fkey` FOREIGN KEY (`listId`) REFERENCES `shopping_lists`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `products` ADD CONSTRAINT `products_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `categories`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `list_items` ADD CONSTRAINT `list_items_listId_fkey` FOREIGN KEY (`listId`) REFERENCES `shopping_lists`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `list_items` ADD CONSTRAINT `list_items_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `products`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `price_history` ADD CONSTRAINT `price_history_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `products`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `notifications` ADD CONSTRAINT `notifications_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `activities` ADD CONSTRAINT `activities_listId_fkey` FOREIGN KEY (`listId`) REFERENCES `shopping_lists`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `activities` ADD CONSTRAINT `activities_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
3
backend/prisma/migrations/migration_lock.toml
Normal file
3
backend/prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (i.e. Git)
|
||||
provider = "mysql"
|
||||
232
backend/prisma/schema.prisma
Normal file
232
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,232 @@
|
||||
// HMarket Veritabanı Şeması
|
||||
// MySQL için Prisma ORM konfigürasyonu
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// Kullanıcı modeli
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
username String @unique
|
||||
firstName String
|
||||
lastName String
|
||||
password String? // OAuth kullanıcıları için opsiyonel
|
||||
avatar String?
|
||||
googleId String? @unique // Google OAuth ID
|
||||
authProvider String @default("local") // "local", "google"
|
||||
isActive Boolean @default(true)
|
||||
isAdmin Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lastLoginAt DateTime?
|
||||
|
||||
// İlişkiler
|
||||
ownedLists ShoppingList[] @relation("ListOwner")
|
||||
sharedLists ListMember[]
|
||||
notifications Notification[]
|
||||
deviceTokens DeviceToken[]
|
||||
activities Activity[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// Cihaz token'ları (Push notification için)
|
||||
model DeviceToken {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
token String @unique
|
||||
platform String // "ios", "android", "web"
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("device_tokens")
|
||||
}
|
||||
|
||||
// Alışveriş listesi modeli
|
||||
model ShoppingList {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
color String @default("#2196F3") // Hex renk kodu
|
||||
isActive Boolean @default(true)
|
||||
ownerId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// İlişkiler
|
||||
owner User @relation("ListOwner", fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
members ListMember[]
|
||||
items ListItem[]
|
||||
activities Activity[]
|
||||
invitations ListInvitation[]
|
||||
|
||||
@@map("shopping_lists")
|
||||
}
|
||||
|
||||
// Liste üyeleri (çoklu kullanıcı desteği)
|
||||
model ListMember {
|
||||
id String @id @default(cuid())
|
||||
listId String
|
||||
userId String
|
||||
role String @default("member") // "admin", "member", "viewer"
|
||||
joinedAt DateTime @default(now())
|
||||
|
||||
// İlişkiler
|
||||
list ShoppingList @relation(fields: [listId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([listId, userId])
|
||||
@@map("list_members")
|
||||
}
|
||||
|
||||
// Liste davetleri
|
||||
model ListInvitation {
|
||||
id String @id @default(cuid())
|
||||
listId String
|
||||
email String
|
||||
role String @default("member")
|
||||
token String @unique
|
||||
isUsed Boolean @default(false)
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
list ShoppingList @relation(fields: [listId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("list_invitations")
|
||||
}
|
||||
|
||||
// Ürün kategorileri
|
||||
model Category {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
description String?
|
||||
icon String? // Icon adı veya URL
|
||||
color String @default("#757575")
|
||||
sortOrder Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// İlişkiler
|
||||
products Product[]
|
||||
|
||||
@@map("categories")
|
||||
}
|
||||
|
||||
// Ürün modeli
|
||||
model Product {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
barcode String? // barkod opsiyonel
|
||||
brand String?
|
||||
unit String? // Ürün varsayılan birimi
|
||||
categoryId String?
|
||||
image String?
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// İlişkiler
|
||||
category Category? @relation(fields: [categoryId], references: [id], onDelete: SetNull)
|
||||
listItems ListItem[]
|
||||
priceHistory PriceHistory[]
|
||||
|
||||
@@map("products")
|
||||
}
|
||||
|
||||
// Liste öğeleri
|
||||
model ListItem {
|
||||
id String @id @default(cuid())
|
||||
listId String
|
||||
productId String?
|
||||
customName String? // Ürün yoksa manuel isim
|
||||
quantity Float @default(1)
|
||||
unit String @default("adet") // "kg", "lt", "adet", vb.
|
||||
price Decimal? // SQLite: Decimal stored as String
|
||||
note String?
|
||||
isPurchased Boolean @default(false)
|
||||
purchasedAt DateTime?
|
||||
purchasedBy String?
|
||||
priority Int @default(0) // 0: normal, 1: önemli, 2: acil
|
||||
sortOrder Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
// İlişkiler
|
||||
list ShoppingList @relation(fields: [listId], references: [id], onDelete: Cascade)
|
||||
product Product? @relation(fields: [productId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@map("list_items")
|
||||
}
|
||||
|
||||
// Fiyat geçmişi
|
||||
model PriceHistory {
|
||||
id String @id @default(cuid())
|
||||
productId String
|
||||
price Decimal // SQLite: Decimal stored as String
|
||||
store String? // Mağaza adı
|
||||
location String? // Konum bilgisi
|
||||
source String @default("user") // "user", "api", "scraping"
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// İlişkiler
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("price_history")
|
||||
}
|
||||
|
||||
// Bildirimler
|
||||
model Notification {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
title String
|
||||
message String
|
||||
type String // "list_shared", "item_added", "item_purchased", "price_alert"
|
||||
data String? // Ek veri (JSON format - SQLite String olarak saklanır)
|
||||
isRead Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// İlişkiler
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("notifications")
|
||||
}
|
||||
|
||||
// Aktivite logu (gerçek zamanlı güncellemeler için)
|
||||
model Activity {
|
||||
id String @id @default(cuid())
|
||||
listId String
|
||||
userId String
|
||||
action String // "item_added", "item_removed", "item_updated", "item_purchased"
|
||||
details String? // Aktivite detayları (JSON - SQLite String olarak saklanır)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// İlişkiler
|
||||
list ShoppingList @relation(fields: [listId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("activities")
|
||||
}
|
||||
|
||||
// Sistem ayarları
|
||||
model Setting {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
value String
|
||||
type String @default("string") // "string", "number", "boolean", "json"
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("settings")
|
||||
}
|
||||
139
backend/prisma/seed.js
Normal file
139
backend/prisma/seed.js
Normal file
@@ -0,0 +1,139 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
console.log('Örnek veriler ekleniyor...')
|
||||
|
||||
// Kullanıcılar
|
||||
const user1 = await prisma.user.create({
|
||||
data: {
|
||||
email: 'mustafa@example.com',
|
||||
username: 'mustafa',
|
||||
firstName: 'Mustafa',
|
||||
lastName: 'ÖZKAYA',
|
||||
password: '$2a$10$dummy',
|
||||
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=mustafa',
|
||||
}
|
||||
})
|
||||
|
||||
const user2 = await prisma.user.create({
|
||||
data: {
|
||||
email: 'ahmet@example.com',
|
||||
username: 'ahmet',
|
||||
firstName: 'Ahmet',
|
||||
lastName: 'Yılmaz',
|
||||
password: '$2a$10$dummy',
|
||||
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=ahmet',
|
||||
}
|
||||
})
|
||||
|
||||
const user3 = await prisma.user.create({
|
||||
data: {
|
||||
email: 'ayse@example.com',
|
||||
username: 'ayse',
|
||||
firstName: 'Ayşe',
|
||||
lastName: 'Kaya',
|
||||
password: '$2a$10$dummy',
|
||||
avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=ayse',
|
||||
}
|
||||
})
|
||||
|
||||
console.log('✅ Kullanıcılar oluşturuldu')
|
||||
|
||||
// Kategoriler
|
||||
const cat1 = await prisma.category.create({ data: { name: 'Sebze & Meyve', icon: '🥬', color: '#4CAF50' } })
|
||||
const cat2 = await prisma.category.create({ data: { name: 'Et & Tavuk', icon: '🥩', color: '#F44336' } })
|
||||
const cat3 = await prisma.category.create({ data: { name: 'Süt & Süt Ürünleri', icon: '🥛', color: '#2196F3' } })
|
||||
const cat4 = await prisma.category.create({ data: { name: 'Ekmek & Unlu Mamüller', icon: '🍞', color: '#FF9800' } })
|
||||
const cat5 = await prisma.category.create({ data: { name: 'İçecekler', icon: '🥤', color: '#9C27B0' } })
|
||||
const cat6 = await prisma.category.create({ data: { name: 'Temizlik', icon: '🧹', color: '#607D8B' } })
|
||||
const cat7 = await prisma.category.create({ data: { name: 'Atıştırmalık', icon: '🍪', color: '#795548' } })
|
||||
const cat8 = await prisma.category.create({ data: { name: 'Dondurma', icon: '🍦', color: '#E91E63' } })
|
||||
|
||||
console.log('✅ Kategoriler oluşturuldu')
|
||||
|
||||
// Ürünler
|
||||
const products = await Promise.all([
|
||||
prisma.product.create({ data: { name: 'Domates', categoryId: cat1.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Soğan', categoryId: cat1.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Salatalık', categoryId: cat1.id, unit: 'adet' } }),
|
||||
prisma.product.create({ data: { name: 'Tavuk Göğsü', categoryId: cat2.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Kıyma', categoryId: cat2.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Kırmızı Et', categoryId: cat2.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Süt', categoryId: cat3.id, unit: 'L' } }),
|
||||
prisma.product.create({ data: { name: 'Yoğurt', categoryId: cat3.id, unit: 'adet' } }),
|
||||
prisma.product.create({ data: { name: 'Ekmek', categoryId: cat4.id, unit: 'adet' } }),
|
||||
prisma.product.create({ data: { name: 'Cola', categoryId: cat5.id, unit: 'adet' } }),
|
||||
prisma.product.create({ data: { name: 'Bulaşık Deterjanı', categoryId: cat6.id, unit: 'adet' } }),
|
||||
prisma.product.create({ data: { name: 'Baklava', categoryId: cat7.id, unit: 'kg' } }),
|
||||
prisma.product.create({ data: { name: 'Dondurma', categoryId: cat8.id, unit: 'L' } }),
|
||||
])
|
||||
|
||||
console.log('✅ Ürünler oluşturuldu')
|
||||
|
||||
// Market Listeleri
|
||||
const list1 = await prisma.shoppingList.create({
|
||||
data: {
|
||||
name: 'Haftalık Market',
|
||||
description: 'Bu hafta alınacaklar',
|
||||
color: '#4CAF50',
|
||||
ownerId: user1.id,
|
||||
}
|
||||
})
|
||||
|
||||
// Listeye üye ekle
|
||||
await prisma.listMember.create({
|
||||
data: {
|
||||
userId: user2.id,
|
||||
listId: list1.id,
|
||||
role: 'admin'
|
||||
}
|
||||
})
|
||||
|
||||
// Liste Öğeleri (productId kullan)
|
||||
await prisma.listItem.create({ data: { productId: products[0].id, quantity: 2, unit: 'kg', listId: list1.id } }) // Domates
|
||||
await prisma.listItem.create({ data: { productId: products[1].id, quantity: 1, unit: 'kg', listId: list1.id } }) // Soğan
|
||||
await prisma.listItem.create({ data: { productId: products[2].id, quantity: 3, unit: 'adet', listId: list1.id, isPurchased: true } }) // Salatalık
|
||||
await prisma.listItem.create({ data: { productId: products[3].id, quantity: 1, unit: 'kg', listId: list1.id } }) // Tavuk
|
||||
await prisma.listItem.create({ data: { productId: products[4].id, quantity: 0.5, unit: 'kg', listId: list1.id } }) // Kıyma
|
||||
await prisma.listItem.create({ data: { productId: products[6].id, quantity: 2, unit: 'L', listId: list1.id, isPurchased: true } }) // Süt
|
||||
await prisma.listItem.create({ data: { productId: products[7].id, quantity: 4, unit: 'adet', listId: list1.id } }) // Yoğurt
|
||||
await prisma.listItem.create({ data: { productId: products[8].id, quantity: 2, unit: 'adet', listId: list1.id } }) // Ekmek
|
||||
await prisma.listItem.create({ data: { productId: products[9].id, quantity: 6, unit: 'adet', listId: list1.id } }) // Cola
|
||||
await prisma.listItem.create({ data: { productId: products[10].id, quantity: 1, unit: 'adet', listId: list1.id, isPurchased: true } }) // Deterjan
|
||||
|
||||
console.log('✅ İlk liste oluşturuldu')
|
||||
|
||||
// İkinci liste
|
||||
const list2 = await prisma.shoppingList.create({
|
||||
data: {
|
||||
name: 'Bayram Alışverişi',
|
||||
description: 'Bayram için gerekli malzemeler',
|
||||
color: '#E91E63',
|
||||
ownerId: user1.id,
|
||||
}
|
||||
})
|
||||
|
||||
await prisma.listItem.create({ data: { productId: products[5].id, quantity: 2, unit: 'kg', listId: list2.id } }) // Kırmızı Et
|
||||
await prisma.listItem.create({ data: { productId: products[11].id, quantity: 1, unit: 'kg', listId: list2.id } }) // Baklava
|
||||
await prisma.listItem.create({ data: { productId: products[12].id, quantity: 2, unit: 'L', listId: list2.id } }) // Dondurma
|
||||
|
||||
console.log('✅ İkinci liste oluşturuldu')
|
||||
|
||||
console.log('\n🎉 Örnek veriler başarıyla eklendi!')
|
||||
console.log(` - 3 kullanıcı`)
|
||||
console.log(` - 8 kategori`)
|
||||
console.log(` - ${await prisma.product.count()} ürün`)
|
||||
console.log(` - 2 liste`)
|
||||
console.log(` - 13 liste öğesi`)
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
Reference in New Issue
Block a user