This project uses bun for package management. Install it here
bun install # Install dependencies
bun dev # Run the development server
bun run build # Builds server, checks lintingThis project uses drizzle to manage migrations safely. To test changes in development, we can create database branches.
The migrations directory tracks the history for the main branch only. This is for safety reasons. In development, you can push schema changes directly to your database branch. When we merge into main, we perform the migration manually and save the migration files to git.
- Create a branch in the Neon Console.
- Copy the connection string into your
.env.developmentfile. You should have 2 changesDATABASE_URLandDATABASE_URL_UNPOOLEDfor the pooled and non-pooled connections, respectively. - Make changes to schema, add new schemas, etc.
- To reflect these changes in your development branch on neon, run
bun db:push. This is a command which essentially performs a database migration without saving the migration files. See more details here. This is considered unsafe for the main database instance, but it's ok for development. - Commit your changes and publish your branch. Ensure that you have not committed any new files in src/db/migrations.
- Open a Pull Request back to the parent branch.
We only need to do this if there are necessary schema changes to the production database. If our changes only access the database, but don't change the schema declarations, then we don't have to do this.
- Ensure you have the file
.env.productionwith the connection string of the main branch in neon. - Run
bun db:generateto create new migration files. - Run
bun db:migrateto run these migration files on the main database branch. - Commit and push to trigger a new production deployment on Vercel.