Skip to content

Commit

Permalink
Feat/migrate to postgres (#52)
Browse files Browse the repository at this point in the history
* remove old migrations

* Update database configuration to use PostgreSQL

* Update database configuration to use PostgreSQL

* Update database connection and migration to use PostgreSQL

* Update database URL and remove unused code

* Update lucia Drizzle adapter to use PostgreSQL

* Update DATABASE_PREFIX constant

* Update database description in landing page

* Update database name in README
  • Loading branch information
iamtouha authored Apr 6, 2024
1 parent 84529e2 commit 6e5af36
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 630 deletions.
7 changes: 3 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
# When adding additional environment variables, the schema in "/src/env.js"
# should be updated accordingly.

# Drizzle
# Get the Database URL from the "prisma" dropdown selector in PlanetScale.
# Change the query params at the end of the URL to "?ssl={"rejectUnauthorized":true}"
DATABASE_URL='mysql://YOUR_MYSQL_URL_HERE?ssl={"rejectUnauthorized":true}'
# Drizzle
DATABASE_URL='postgres://YOUR_DATABASE_URL_HERE'

SMTP_HOST='smtp.example-host.com'
SMTP_PORT=25
SMTP_USER='smtp_example_username'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: pnpm run typecheck && pnpm run lint
env:
# use dummy env variables to bypass t3-env check
DATABASE_URL: mysql://test:xxxx@xxxxxxxxx:3306/test
DATABASE_URL: postgres://test:xxxx@xxxxxxxxx:3306/test
SMTP_HOST: host
SMTP_PORT: 587
SMTP_USER: user
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Lucia is less opinionated than NextAuth, offering greater flexibility for custom
- **Lucia + tRPC:** 🔄 Similar to NextAuth with tRPC, granting access to sessions and user information through tRPC procedures.
- **Stripe Payment:** 💳 Setup user subscriptions seamlessly with stripe.
- **Email template with react-email:** ✉️ Craft your email templates using React.
- **MySQL Database:** 🛢️ Utilize a MySQL database (Planetscale) set up using Drizzle for enhanced performance and type safety.
- **PostgreSQL Database:** 🛢️ Utilize a PostgreSQL database set up using Drizzle for enhanced performance and type safety.
- **Database Migration:** 🚀 Included migration script to extend the database schema according to your project needs.

## Tech Stack
Expand All @@ -26,7 +26,7 @@ Lucia is less opinionated than NextAuth, offering greater flexibility for custom
- [Lucia](https://lucia-auth.com/)
- [tRPC](https://trpc.io)
- [Drizzle ORM](https://orm.drizzle.team/)
- [Planetscale](https://planetscale.com/)
- [PostgreSQL](https://www.postgresql.org/)
- [Stripe](https://stripe.com/)
- [Tailwind CSS](https://tailwindcss.com)
- [Shadcn UI](https://ui.shadcn.com/)
Expand All @@ -47,7 +47,7 @@ Lucia is less opinionated than NextAuth, offering greater flexibility for custom

- [ ] Update Password
- [x] Stripe Integration
- [x] API Rate-Limiting see branch - [upstash-ratelimiting](https://github.com/iamtouha/next-lucia-auth/tree/upstash-ratelimiting)
<!-- - [x] API Rate-Limiting see branch - [upstash-ratelimiting](https://github.com/iamtouha/next-lucia-auth/tree/upstash-ratelimiting) -->
- [ ] Admin Dashboard (under consideration)
- [ ] Role-Based Access Policy (under consideration)

Expand Down
4 changes: 2 additions & 2 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { DATABASE_PREFIX } from "@/lib/constants";
export default defineConfig({
schema: "./src/server/db/schema.ts",
out: "./drizzle",
driver: "mysql2",
driver: "pg",
dbCredentials: {
uri: process.env.DATABASE_URL!,
connectionString: process.env.DATABASE_URL!,
},
tablesFilter: [`${DATABASE_PREFIX}_*`],
});
63 changes: 0 additions & 63 deletions drizzle/0000_lovely_vivisector.sql

This file was deleted.

Loading

0 comments on commit 6e5af36

Please sign in to comment.