๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ

(79)
์•„๋Š” ๊ฒƒ์ด๋ž€ ๋ณดํ˜ธ๋˜์–ด ์žˆ๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.
๋žœ๋ค ๋ฌธ์ž์—ด ์ƒ์„ฑํ•˜๊ธฐ 32 ๋ฐ”์ดํŠธ ๋žœ๋ค๊ฐ’ ์ƒ์„ฑํ•˜๊ธฐ
[ํ”Œ์ ๊ธฐ๋ก] NextAuth๋กœ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„ํ•˜๊ธฐ (with Prisma) ๋ณดํ˜ธ๋˜์–ด ์žˆ๋Š” ๊ธ€์ž…๋‹ˆ๋‹ค.
[ํ”Œ์ ๊ธฐ๋ก] Prisma Seeding ๐ŸŒฑ ์š”์ฆ˜ Prisma๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰์ค‘์ธ๋ฐ ์ฒ˜์Œ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋‹ˆ ์ƒˆ๋กœ ๋ฐฐ์šฐ๋Š” ๊ฒƒ๋“ค์ด ๋งŽ๋‹ค. Seeding๋„ ๊ทธ ์ค‘ ํ•œ ๊ฐ€์ง€์ธ๋ฐ ํŠœํ† ๋ฆฌ์–ผ ๋™์˜์ƒ๊ณผ ๊ธ€๋“ค์„ ๋ณด๋‹ค๋ณด๋‹ˆ seeding, seed๋ผ๋Š” ๋‹จ์–ด๊ฐ€ ์ž์ฃผ ๋‚˜์™”๋‹ค. ๋‹น์žฅ ํ•„์š”ํ•ด๋ณด์ด์ง€๋Š” ์•Š์•„์„œ ๋‚˜์ค‘์— ํ•„์š”ํ•  ๋•Œ์— ๋ด์•ผ์ง€ ํ•˜๊ณ  ์ง€๋‚˜์ณค๋Š”๋ฐ ํ•„์š”ํ•œ ์ˆœ๊ฐ„์ด ์™”๋‹ค. (์œ„์—์„œ ์–ธ๊ธ‰ํ–ˆ๋‹ค์‹œํ”ผ Prisma๋ฅผ ์ฒ˜์Œ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋‹ˆ Prisma, Prisma seeding์— ๋Œ€ํ•œ ๋‚˜์˜ ์ดํ•ด๊ฐ€ ์ œํ•œ์ ์ผ ์ˆ˜ ์žˆ๊ณ  ์ด ๊ธ€์ด ๊ณต์‹ ๋ฌธ์„œ์— ๊ธฐ์ดˆํ•ด ์žˆ๊ธดํ•˜์ง€๋งŒ ๋” ์ •ํ™•ํ•œ ๋‚ด์šฉ์€ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜๊ธฐ ๋ฐ”๋ž€๋‹ค.) Prisma์˜ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด ์ด ๋งํฌ๋ฅผ ํ™•์ธํ•˜๋ผ. Seeding your database Learn how to seed your database using Prism..
[ํ”Œ์ ๊ธฐ๋ก] PlanetScale branch ๋ณ€๊ฒฝ ๋ฐ deploy request (Prisma String์˜ default ๊ฐ’) [ํ”Œ์ ๊ธฐ๋ก] Next.js + Prisma + PlanetScale ์„ธํŒ…ํ•˜๊ธฐ (Vercel ๋ฐฐํฌ) ์ด ๊ธ€์€ ๋‹จ์ˆœํžˆ ์„ธํŒ…๋งŒ์„ ์œ„ํ•œ ๊ธ€์ด์ง€ ๋‚ด๋ถ€์ ์ธ ๋กœ์ง์ด๋‚˜ ์Šคํ‚ค๋งˆ ๋“ฑ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์ „ํ˜€ ํฌํ•จ๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฉฐ, ์–ด๋– ํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„ ์—ญ์‹œ ๋‹ค๋ฃจ์ง€ ์•Š๋Š”๋‹ค. PlanetScale์˜ https://planetscal birdmee.tistory.com ์ง€๋‚œ ์„ธํŒ…ํŽธ์—์„œ 8๋ฒˆ์— "promote ํ›„์— main ๋ธŒ๋žœ์น˜๋Š” production์„ ์œ„ํ•œ ๋ธŒ๋žœ์น˜๊ฐ€ ๋˜๊ณ  main ๋ธŒ๋žœ์น˜์— ๋Œ€ํ•ด ์ง์ ‘์ ์ธ ์Šคํ‚ค๋งˆ ๋ณ€๊ฒฝ์ด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค. ์ด ๊ธ€์„ ์ž‘์„ฑํ•˜๊ธฐ ์ „์— ํ…Œ์ŠคํŠธ ์‚ผ์•„ ๋งŒ๋“ค์–ด ๋ณธ DB์—์„œ ์ด ๋ธŒ๋žœ์น˜์— ๋Œ€ํ•œ ๊ฐœ๋…์„ ์ž˜ ๋ชจ๋ฅด๊ณ  promoteํ•œ ์ƒํƒœ์—์„œ ์Šคํ‚ค๋งˆ๋ฅผ ๋ณ€๊ฒฝํ•˜๋ ค๊ณ  ํ•ด์„œ ์—๋Ÿฌ๋กœ ๋‹นํ™ฉํ–ˆ๋˜ ์ ์ด ์žˆ๋‹ค. " ๋ผ๊ณ  ์ž‘์„ฑํ–ˆ์—ˆ๋‹ค. ๊ทธ๋Ÿผ..
npx prisma format Prisma schema ํฌ๋งท ๊ณต์‹ Docs: https://www.prisma.io/docs/reference/api-reference/command-reference#format ๊ณต์‹ ๋ฌธ์„œ์˜ format ๋ช…๋ น์–ด์— ๋Œ€ํ•œ ์„ค๋ช… Formats the Prisma schema file, which includes validating, formatting, and persisting the schema. ์ƒˆ๋กœ์šด ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ Prisma๋ฅผ ์ฒ˜์Œ ์‚ฌ์šฉํ•ด๋ณด๋‹ค๋ณด๋‹ˆ schema ์ƒ์„ฑ๋ถ€ํ„ฐ ๊ณ„์† ์—๋Ÿฌ๊ฐ€ ๋–ด๋‹ค. @relation์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ ํ…Œ์ด๋ธ” ํ•œ ์ชฝ์—๋งŒ @relation์„ ๋ช…์‹œํ•ด์ฃผ๊ณ  ๋‹ค๋ฅธ ํ•œ ์ชฝ์—์„  ํ•„๋“œ๋ฅผ ์ ์–ด์ฃผ์ง€ ์•Š์•˜๋”๋‹ˆ ์—๋Ÿฌ๊ฐ€ ๋‚œ ๊ฒƒ์ด์—ˆ๋Š”๋ฐ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€์— ์นœ์ ˆํ•˜๊ฒŒ๋„ ์ง์ ‘ ์ถ”๊ฐ€ํ•ด์ฃผ๋“ ์ง€ prisma f..
[ํ”Œ์ ๊ธฐ๋ก] Next.js + Prisma + PlanetScale ์„ธํŒ…ํ•˜๊ธฐ (Vercel ๋ฐฐํฌ) ์ด ๊ธ€์€ ๋‹จ์ˆœํžˆ ์„ธํŒ…๋งŒ์„ ์œ„ํ•œ ๊ธ€์ด์ง€ ๋‚ด๋ถ€์ ์ธ ๋กœ์ง์ด๋‚˜ ์Šคํ‚ค๋งˆ ๋“ฑ์— ๋Œ€ํ•œ ์„ค๋ช…์ด ์ „ํ˜€ ํฌํ•จ๋˜์–ด ์žˆ์ง€ ์•Š์œผ๋ฉฐ, ์–ด๋– ํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„ ์—ญ์‹œ ๋‹ค๋ฃจ์ง€ ์•Š๋Š”๋‹ค. PlanetScale์˜ https://planetscale.com/blog/how-to-setup-next-js-with-prisma-and-planetscale ๊ธ€์— ๊ธฐ์ดˆํ•œ ๋‚ด์šฉ์ด๋ฉฐ ํ•ด๋‹น ๊ธ€์˜ ๋™์˜์ƒ ๋ฒ„์ „(๋งํฌ) ๋„ ์ฐธ์กฐํ–ˆ๋‹ค. How to set up Next.js with Prisma and PlanetScale A step-by-step guide for using PlanetScale and Prisma with Next.js. planetscale.com 1. PlanetScale ๊ฐ€์ž… / ๋กœ๊ทธ์ธ ํ›„ Create New Database..
[ํ”Œ์ ๊ณ„ํš] ์ƒˆ๋กœ์šด ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•ด๋ณด์ž ์ƒˆ๋กœ์šด ์‚ฌ์ด๋“œ ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•  ์‹œ๊ฐ„์ด๋‹ค. ๋ฌด์—‡์ด๋“  ์ง์ ‘ํ•ด๋ด์•ผ ๋Š๋ผ๋Š” ๊ฒƒ๋„ ๋งŽ๊ณ  ๋ฐฐ์šฐ๋Š” ๊ฒƒ๋„ ๋งŽ์€ ๊ฒƒ ๊ฐ™๋‹ค. ์ด๋ฒˆ์—๋Š” ์–ด๋–ค ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ค์–ด๋ด์•ผ์ง€ ๋ณด๋‹ค ์–ด๋–ค ์Šคํƒ์„ ์‚ฌ์šฉํ•ด๋ณด๊ณ  ์‹ถ๋‹ค๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค๋ฉด์„œ ์‹œ์ž‘ํ•ด๋ณด๊ณ ์ž ๋ถ€๋ฆ‰๋ถ€๋ฆ‰ ์‹œ๋™์„ ๊ฑด๋‹ค. ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ์Šคํƒ / ๊ธฐ์ˆ  ๋ฐ ์ด์œ  Next.js : ์ง€๋‚œ ํ”„๋กœ์ ํŠธ ๋•Œ ์ฒ˜์Œ ์ ‘ํ•ด๋ดค๋Š”๋ฐ ๋” ๊ณต๋ถ€ํ•ด๋ณด๊ณ  ์‹ถ์—ˆ๋‹ค. ๋˜ ๊ณต์‹๋ฌธ์„œ๊ฐ€ ๋งค์šฐ ์นœ์ ˆํ•˜๋‹ค(๊ณ  ํ•œ๋‹ค๋ผ๊ณ  ์–ด๋””์„œ ๋“ค์€ ๊ฒƒ ๊ฐ™์€๋ฐ ์‹ค์ œ๋กœ ๊ทธ๋ ‡๊ฒŒ ๋Š๊ปด์ ธ ๋ธ”๋กœ๊ทธ์˜ Next.js ์นดํ…Œ๊ณ ๋ฆฌ์— ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ผ๋ถ€ ๋ฒˆ์—ญํ•ด๋†“๊ธฐ๋„ ํ•˜์˜€๋‹ค.). PlanetScale : Serverless DB Platform์œผ๋กœ ์ตœ๊ทผ์— Stackoverflow ํŒŸ์บ์ŠคํŠธ๋ฅผ ๋“ฃ๋‹ค๊ฐ€ Next.js CEO์™€ PlanetScale CEO๊ฐ€ ์ด์•ผ๊ธฐ ๋‚˜๋ˆ„๋Š” ๊ฒƒ์„ ๋“ฃ๊ณ  ์ฒ˜์Œ ..