Skip to content

Montreal-Dev/next-drizzle-mysql

Repository files navigation

screencapture-localhost-3000-en-2023-12-21-01-10-11.png

📙About

Create instant MySql gratification with a light, types safe ORM offering time saving tools. Pain-pleasure principle am I right?

⚙️Installation

[Step - 1 Create]

Deploy with Vercel
Or
npx create-next-app https://github.com/lnxAv/next-drizzle-mysql

[Step - 2 Connect]

I'm using Vercel

1. In your browser, go to your deployment settings > Environment Variables
2. Fill the following variable accordingly
( Note: You can separate production & development env's for security purpose )
DATABASE_USER, DATABASE_PASSWORD, DATABASE_HOST, DATABASE_PORT, DATABASE_SCHEMA
3. In your project terminal type
Vercel env pull
( Note: You can also type "vercel env ls" to list them )

I'm using npm create-next-app

1. In your project root add a `.env.local` file
2. Copy paste and fill accordingly
    # Development variables
    DATABASE_USER="root"
    DATABASE_PASSWORD="admin"
    DATABASE_SCHEMA="database"
    DATABASE_HOST="localhost"
    DATABASE_PORT="3306"
  


[Step - 3 Migrate]

I'm using a new database

1. Push the example tables in your new database with
npx drizzle-kit push:mysql
2. Populate your database with the magic button
3. Read the documentation below and enjoy :)

I'm using my own database

1. Pull your database DDL with
npm run pull-db
2. Copy/Paste the content From => To
database/drizzle/schema.ts => database/db_tables.ts
2. Get your data by modifying the example in
app/api/route.ts
4. If needed, modify the "magicAction" to populate your database.
5. Read the documentation below and enjoy :)

🔰Database Setup

For unfamilliar users, you can easily deploy your own database,
Grab a coffee and learn the basics in 17 minutes.
MySQL - The Basics // Learn SQL in 23 Easy Step
MySQL - The Basics // Learn SQL in 23 Easy Step

🤖Commands

npm run Description
dev Launch the project in development mode
build Build the project, great to see package size
start Launch the built project
prettier Clean files according to .prettierrrc.json
lint Verify files according to .eslintrc.json
Migrate Run the migrations with Drizzle
drop Lets you delete previously generated migrations from migrations folder
pull-db Lets you pull DDL from existing database and generate a schema.ts
push-db Lets you push your schema changes directly to the database
studio-db Drizzle Studio is a new way for you to explore SQL database on Drizzle projects.

🛠️Tools documentation

Categories Links
Cores Next.js, Vercel, Drizzle ORM
Traductions next-international
Providers Next-Themes
Fetcher SWR.js
Animation Motion.dev
Dev Dependencies husky, dotenv, drizzle-kit
Total: 50kb