diff --git a/.gitignore b/.gitignore index 3b462cb..dc11607 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ node_modules # Output +.idea .output .vercel .netlify diff --git a/LOCAL_DATABASE_LOCATION.md b/LOCAL_DATABASE_LOCATION.md new file mode 100644 index 0000000..8e798bf --- /dev/null +++ b/LOCAL_DATABASE_LOCATION.md @@ -0,0 +1,263 @@ +# πŸ“ Cloudflare D1 둜컬 λ°μ΄ν„°λ² μ΄μŠ€ 파일 μœ„μΉ˜ + +## πŸ—‚οΈ λ°μ΄ν„°λ² μ΄μŠ€ 파일 μœ„μΉ˜ + +Cloudflare Workers의 둜컬 개발 ν™˜κ²½(`pnpm cf:dev`)μ—μ„œ μ‚¬μš©ν•˜λŠ” D1 λ°μ΄ν„°λ² μ΄μŠ€λŠ” λ‹€μŒ μœ„μΉ˜μ— μ €μž₯λ©λ‹ˆλ‹€: + +``` +C:\giteat\dd\.wrangler\state\v3\d1\miniflare-D1DatabaseObject\ +└── e833abeb83abd38e60de8166ab13bbd4d7a5636dc148a7fd8ec47b7678c87854.sqlite +``` + +### 전체 경둜 +``` +ν”„λ‘œμ νŠΈν΄λ”\.wrangler\state\v3\d1\miniflare-D1DatabaseObject\[ν•΄μ‹œ].sqlite +``` + +## πŸ“Š ν˜„μž¬ λ°μ΄ν„°λ² μ΄μŠ€ 정보 + +### 파일 크기 +- **20,480 bytes** (μ•½ 20 KB) + +### ν¬ν•¨λœ ν…Œμ΄λΈ” +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ name β”‚ +β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +β”‚ users β”‚ ← μš°λ¦¬κ°€ μƒμ„±ν•œ ν…Œμ΄λΈ” +β”‚ sqlite_sequence β”‚ ← SQLite λ‚΄λΆ€ ν…Œμ΄λΈ” (AUTO_INCREMENT 관리) +β”‚ _cf_METADATA β”‚ ← Cloudflare 메타데이터 +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +## πŸ” μ™œ ν”„λ‘œμ νŠΈ ν΄λ”μ—μ„œ 찾을 수 μ—†λ‚˜μš”? + +### 1. μˆ¨κΉ€ 디렉토리 +`.wrangler` λ””λ ‰ν† λ¦¬λŠ” μ•žμ— 점(`.`)이 μžˆμ–΄μ„œ 기본적으둜 μˆ¨κ²¨μ§„ ν΄λ”μž…λ‹ˆλ‹€. + +### 2. Wranglerκ°€ μžλ™ 관리 +`wrangler dev` μ‹€ν–‰ μ‹œ μžλ™μœΌλ‘œ μƒμ„±λ˜κ³  κ΄€λ¦¬λ©λ‹ˆλ‹€. + +### 3. gitignore에 포함 +일반적으둜 `.gitignore`에 ν¬ν•¨λ˜μ–΄ Git에 μ»€λ°‹λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. + +## πŸ“ 전체 .wrangler ꡬ쑰 + +``` +.wrangler/ +β”œβ”€β”€ state/ +β”‚ └── v3/ +β”‚ β”œβ”€β”€ d1/ # D1 λ°μ΄ν„°λ² μ΄μŠ€ +β”‚ β”‚ └── miniflare-D1DatabaseObject/ +β”‚ β”‚ └── [ν•΄μ‹œ].sqlite # ← μ—¬κΈ°! +β”‚ β”œβ”€β”€ do/ # Durable Objects +β”‚ β”‚ └── dd-CounterDurableObject/ +β”‚ β”‚ β”œβ”€β”€ [ν•΄μ‹œ].sqlite +β”‚ β”‚ β”œβ”€β”€ [ν•΄μ‹œ].sqlite-shm +β”‚ β”‚ └── [ν•΄μ‹œ].sqlite-wal +β”‚ β”œβ”€β”€ cache/ # Cache API +β”‚ β”‚ └── miniflare-CacheObject/ +β”‚ β”‚ └── [ν•΄μ‹œ].sqlite +β”‚ └── workflows/ # Workflows (λΉ„μ–΄μžˆμŒ) +└── tmp/ # μž„μ‹œ 파일 +``` + +## πŸ› οΈ λ°μ΄ν„°λ² μ΄μŠ€ 파일 직접 μ ‘κ·Ό + +### 방법 1: Wrangler CLI μ‚¬μš© (ꢌμž₯) + +```bash +# ν…Œμ΄λΈ” 쑰회 +pnpm wrangler d1 execute auth-db --local --command="SELECT * FROM users" + +# μŠ€ν‚€λ§ˆ 확인 +pnpm wrangler d1 execute auth-db --local --command="PRAGMA table_info(users)" + +# λͺ¨λ“  ν…Œμ΄λΈ” 쑰회 +pnpm wrangler d1 execute auth-db --local --command="SELECT name FROM sqlite_master WHERE type='table'" +``` + +### 방법 2: SQLite CLI 도ꡬ μ‚¬μš© + +```bash +# SQLite CLIκ°€ μ„€μΉ˜λ˜μ–΄ μžˆλ‹€λ©΄ +sqlite3 .wrangler\state\v3\d1\miniflare-D1DatabaseObject\[ν•΄μ‹œ].sqlite + +# SQLite ν”„λ‘¬ν”„νŠΈμ—μ„œ +sqlite> .tables +sqlite> SELECT * FROM users; +sqlite> .schema users +``` + +### 방법 3: DB Browser for SQLite (GUI) + +1. [DB Browser for SQLite](https://sqlitebrowser.org/) λ‹€μš΄λ‘œλ“œ +2. 파일 μ—΄κΈ°: `.wrangler\state\v3\d1\miniflare-D1DatabaseObject\[ν•΄μ‹œ].sqlite` +3. GUI둜 데이터 확인 및 νŽΈμ§‘ + +### 방법 4: Drizzle Studio (ꢌμž₯!) + +```bash +pnpm db:studio +``` + +λΈŒλΌμš°μ €μ—μ„œ μžλ™μœΌλ‘œ 열리며 λ°μ΄ν„°λ² μ΄μŠ€λ₯Ό μ‹œκ°μ μœΌλ‘œ 관리할 수 μžˆμŠ΅λ‹ˆλ‹€. + +## πŸ” ν•΄μ‹œ 파일λͺ…μ˜ 의미 + +파일λͺ…인 `e833abeb83abd38e60de8166ab13bbd4d7a5636dc148a7fd8ec47b7678c87854.sqlite`λŠ”: + +- **λ°μ΄ν„°λ² μ΄μŠ€ ID의 ν•΄μ‹œκ°’** +- `wrangler.jsonc`의 `database_id: "local-db"`λ₯Ό 기반으둜 생성 +- 각 λ°μ΄ν„°λ² μ΄μŠ€λ§ˆλ‹€ κ³ μœ ν•œ ν•΄μ‹œλ₯Ό 가짐 + +## πŸ“ λ°μ΄ν„°λ² μ΄μŠ€ 파일 관리 + +### λ°μ΄ν„°λ² μ΄μŠ€ μ΄ˆκΈ°ν™” (리셋) + +둜컬 λ°μ΄ν„°λ² μ΄μŠ€λ₯Ό μ™„μ „νžˆ μ΄ˆκΈ°ν™”ν•˜κ³  μ‹Άλ‹€λ©΄: + +```bash +# 방법 1: .wrangler 폴더 μ‚­μ œ +rmdir /s /q .wrangler + +# 방법 2: D1 ν΄λ”λ§Œ μ‚­μ œ +rmdir /s /q .wrangler\state\v3\d1 + +# κ·Έ ν›„ λ‹€μ‹œ λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ μ‹€ν–‰ +pnpm db:push +``` + +### λ°μ΄ν„°λ² μ΄μŠ€ λ°±μ—… + +```bash +# λ°±μ—… 디렉토리 생성 +mkdir backups + +# λ°μ΄ν„°λ² μ΄μŠ€ 파일 볡사 +copy .wrangler\state\v3\d1\miniflare-D1DatabaseObject\*.sqlite backups\local-db-backup.sqlite + +# λ˜λŠ” SQL λ€ν”„λ‘œ λ°±μ—… +pnpm wrangler d1 export auth-db --local --output=backups\backup.sql +``` + +### λ°μ΄ν„°λ² μ΄μŠ€ 볡원 + +```bash +# SQL 파일둜 볡원 +pnpm wrangler d1 execute auth-db --local --file=backups\backup.sql +``` + +## πŸ†š 둜컬 vs ν”„λ‘œλ•μ…˜ λ°μ΄ν„°λ² μ΄μŠ€ + +### 둜컬 개발 (`--local`) +``` +μœ„μΉ˜: .wrangler\state\v3\d1\miniflare-D1DatabaseObject\[ν•΄μ‹œ].sqlite +μ ‘κ·Ό: pnpm wrangler d1 execute auth-db --local --command="..." +``` + +### ν”„λ‘œλ•μ…˜ (`--remote`) +``` +μœ„μΉ˜: Cloudflare ν΄λΌμš°λ“œ (물리적 μ ‘κ·Ό λΆˆκ°€) +μ ‘κ·Ό: pnpm wrangler d1 execute auth-db --remote --command="..." +``` + +## 🎯 NPM 슀크립트둜 μ‰½κ²Œ μ ‘κ·Ό + +`package.json`에 이미 μΆ”κ°€λœ 슀크립트: + +```json +{ + "scripts": { + "db:query": "wrangler d1 execute auth-db --local --command=\"SELECT * FROM users\"", + "db:query:remote": "wrangler d1 execute auth-db --remote --command=\"SELECT * FROM users\"", + "db:studio": "drizzle-kit studio" + } +} +``` + +μ‚¬μš©λ²•: +```bash +# 둜컬 μ‚¬μš©μž 쑰회 +pnpm db:query + +# ν”„λ‘œλ•μ…˜ μ‚¬μš©μž 쑰회 +pnpm db:query:remote + +# Drizzle Studio μ‹€ν–‰ +pnpm db:studio +``` + +## πŸ” ν˜„μž¬ 데이터 확인 + +둜컬 λ°μ΄ν„°λ² μ΄μŠ€μ˜ ν˜„μž¬ μ‚¬μš©μžλ₯Ό ν™•μΈν•˜λ €λ©΄: + +```bash +pnpm db:query +``` + +λ˜λŠ”: + +```bash +pnpm wrangler d1 execute auth-db --local --command="SELECT id, email, nickname, datetime(created_at, 'unixepoch') as created_at FROM users" +``` + +## πŸ“Š λ°μ΄ν„°λ² μ΄μŠ€ 톡계 + +```bash +# μ‚¬μš©μž 수 확인 +pnpm wrangler d1 execute auth-db --local --command="SELECT COUNT(*) as user_count FROM users" + +# λ°μ΄ν„°λ² μ΄μŠ€ 크기 확인 +pnpm wrangler d1 execute auth-db --local --command="SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size()" + +# λ§ˆμ§€λ§‰ μƒμ„±λœ μ‚¬μš©μž +pnpm wrangler d1 execute auth-db --local --command="SELECT * FROM users ORDER BY created_at DESC LIMIT 1" +``` + +## 🚨 μ£Όμ˜μ‚¬ν•­ + +### 1. 직접 파일 μˆ˜μ • κΈˆμ§€ +SQLite νŒŒμΌμ„ 직접 νŽΈμ§‘ν•˜λŠ” 것은 ꢌμž₯ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 항상 Wrangler CLIλ‚˜ Drizzle Studioλ₯Ό μ‚¬μš©ν•˜μ„Έμš”. + +### 2. 개발 쀑 데이터 손싀 주의 +`.wrangler` ν΄λ”λŠ” κ°œλ°œμš©μ΄λ―€λ‘œ μ€‘μš”ν•œ 데이터λ₯Ό μ €μž₯ν•˜μ§€ λ§ˆμ„Έμš”. ν”„λ‘œλ•μ…˜μ—λŠ” `--remote`λ₯Ό μ‚¬μš©ν•˜μ„Έμš”. + +### 3. Git에 μ»€λ°‹ν•˜μ§€ μ•ŠκΈ° +`.gitignore`에 `.wrangler` 포함 확인: +```gitignore +.wrangler/ +``` + +### 4. νŒ€μ›κ³Ό DB 곡유 λΆˆκ°€ +각 κ°œλ°œμžλŠ” μžμ‹ μ˜ 둜컬 DBλ₯Ό κ°€μ§‘λ‹ˆλ‹€. μŠ€ν‚€λ§ˆλŠ” λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ 파일(`drizzle/`)둜 κ³΅μœ λ©λ‹ˆλ‹€. + +## πŸŽ“ 정리 + +**질문:** `cf:dev`μ—μ„œ λ™μž‘ν•  λ•Œ 둜컬 μ„œλ²„κ°€ 바라보고 μžˆλŠ” db νŒŒμΌμ€ 어디에 μžˆλ‚˜μš”? + +**λ‹΅λ³€:** +``` +C:\giteat\dd\.wrangler\state\v3\d1\miniflare-D1DatabaseObject\ +└── e833abeb83abd38e60de8166ab13bbd4d7a5636dc148a7fd8ec47b7678c87854.sqlite +``` + +**μ‰½κ²Œ μ ‘κ·Όν•˜λŠ” 방법:** +```bash +# Drizzle Studio (GUI) +pnpm db:studio + +# CLI둜 쿼리 +pnpm db:query + +# 직접 SQL μ‹€ν–‰ +pnpm wrangler d1 execute auth-db --local --command="SELECT * FROM users" +``` + +**μž‘λ™μ΄ 정상인 이유:** +- Wranglerκ°€ μžλ™μœΌλ‘œ `.wrangler` 폴더에 SQLite νŒŒμΌμ„ μƒμ„±ν•˜κ³  관리 +- `wrangler.jsonc`의 D1 바인딩 섀정에 따라 μžλ™μœΌλ‘œ μ—°κ²° +- λ§ˆμ΄κ·Έλ ˆμ΄μ…˜ 파일(`drizzle/`)을 μ‹€ν–‰ν•˜μ—¬ ν…Œμ΄λΈ” 생성 μ™„λ£Œ + +즐거운 개발 λ˜μ„Έμš”! πŸš€ + diff --git a/MCP_AGENTS.md b/MCP_AGENTS.md new file mode 100644 index 0000000..a403e8a --- /dev/null +++ b/MCP_AGENTS.md @@ -0,0 +1,27 @@ +You are able to use the Svelte MCP server, Cloudflare Documentation MCP server where you have access to comprehensive Svelte 5 and SvelteKit documentation and cloudflare documentation Here's how to use the available tools effectively: + +## Available MCP Tools: + +### 1. cloudflare Documentation server (cloudflare) +Get up to date reference information on Cloudflare +μ‚¬μš©μžμ˜ μš”μ²­μ΄ cloudflare 와 관련이 μžˆμ„λ•Œ 이것을 톡해 cloudflare κ³΅μ‹λ¬Έμ„œμ˜ μ΅œμ‹ μžλ£Œλ₯Ό μ°Έκ³ ν•˜μ—¬ μž‘μ—…μ„ 진행함. + +### 2. list-sections (svelte) + +Use this FIRST to discover all available documentation sections. Returns a structured list with titles, use_cases, and paths. +When asked about Svelte or SvelteKit topics, ALWAYS use this tool at the start of the chat to find relevant sections. + +### 3. get-documentation (svelte) + +Retrieves full documentation content for specific sections. Accepts single or multiple sections. +After calling the list-sections tool, you MUST analyze the returned documentation sections (especially the use_cases field) and then use the get-documentation tool to fetch ALL documentation sections that are relevant for the user's task. + +### 4. svelte-autofixer (svelte) + +Analyzes Svelte code and returns issues and suggestions. +You MUST use this tool whenever writing Svelte code before sending it to the user. Keep calling it until no issues or suggestions are returned. + +### 5. playground-link (svelte) + +Generates a Svelte Playground link with the provided code. +After completing the code, ask the user if they want a playground link. Only call this tool after user confirmation and NEVER if code was written to files in their project. \ No newline at end of file diff --git a/drizzle/0000_omniscient_lady_mastermind.sql b/drizzle/0000_omniscient_lady_mastermind.sql new file mode 100644 index 0000000..271f242 --- /dev/null +++ b/drizzle/0000_omniscient_lady_mastermind.sql @@ -0,0 +1,9 @@ +CREATE TABLE `users` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `email` text NOT NULL, + `password_hash` text NOT NULL, + `nickname` text NOT NULL, + `created_at` integer DEFAULT (strftime('%s', 'now')) NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..65be648 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,72 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "83c12a3c-ec11-4135-b526-261771d6ede4", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "nickname": { + "name": "nickname", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(strftime('%s', 'now'))" + } + }, + "indexes": { + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..9eebdf4 --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "sqlite", + "entries": [ + { + "idx": 0, + "version": "6", + "when": 1763435039243, + "tag": "0000_omniscient_lady_mastermind", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/src/lib/server/db-old.ts b/src/lib/server/db-old.ts new file mode 100644 index 0000000..e69de29