Updating your Next.js Drizzle Starter Kit
Learn how to update your Next.js Drizzle Starter Kit to the latest version and resolve merge conflicts.
This guide will walk you through the process of updating your codebase by pulling the latest changes from the GitHub repository and merging them into your project. This ensures you're always equipped with the latest features and bug fixes.
If you've been following along with our previous guides, you should already have a Git repository set up for your project, with an upstream remote pointing to the original repository.
Updating your project involves fetching the latest changes from the upstream remote and merging them into your project. Let's dive into the steps!
Steps to update your codebase
Learn how to update your Next.js Drizzle Starter Kit to the latest version.
0. Stashing your changes (if any)
If you have uncommited changes, before updating your project, it's a good idea to stash your changes to avoid any conflicts during the update process. You can stash your changes by running:
git stashThis will save your changes temporarily, allowing you to update your project without any conflicts. Once you've updated your project, you can apply your changes back by running:
git stash popIf you don't have any changes to stash, you can skip this step and proceed with the update process.
Alternatively, you can commit your changes.
1. Refresh the upstream remote
Create a new branch for your updates from the main branch:
git checkout -b update-codebase-<date>In this way, you can keep track of your updates and visualize the changes in the branch before merging them into your main branch.
Now, fetch the latest changes from the upstream remote. You can do this by running the following command:
git pull upstream mainWhen prompted the first time, opt for merging instead of rebasing.
Now, run pnpm i to update the dependencies:
pnpm i2. Resolve any conflicts
Encountered conflicts during the merge? No worries! You'll need to resolve them manually. Git will highlight the files with conflicts, and you can edit them to resolve the issues.
Recommended tools for conflict resolution:
- WebStorm/IDE diff tools - WebStorm and other JetBrains IDEs have excellent built-in merge conflict resolution tools. Use
Git > Resolve Conflictsto visually compare and merge changes. - AI assistants - Tools like GitHub Copilot, Claude, or Cursor can help resolve conflicts. However, always review AI-suggested resolutions carefully to ensure they preserve your custom logic and don't introduce bugs.
2.1 Conflicts in the lock file "pnpm-lock.yaml"
If you find conflicts in the pnpm-lock.yaml file, accept either of the two changes (avoid manual edits) or just delete the file, then run the install command to update the dependencies:
pnpm iYour lock file will now reflect both your changes and the updates from the upstream repository.
2.2 Conflicts in Drizzle schema or migrations
If you have modified the Drizzle schema files or created your own migrations in packages/database/src/schema/, you may encounter conflicts.
For schema conflicts:
- Carefully review both versions of the schema files (
.tsfiles) - Merge the changes manually, ensuring you keep both your additions and the upstream changes
- After resolving, generate new migrations if needed:
pnpm --filter "@kit/database" drizzle:generate- Then apply the migrations:
pnpm --filter "@kit/database" drizzle:migrateFor migration conflicts:
Drizzle migrations (.sql files) are stored alongside schema files in packages/database/src/schema/. If you encounter conflicts:
- Accept both sets of migrations (yours and upstream)
- Ensure migration file names don't clash (they have numeric prefixes like
0000_,0001_) - Check the migration order is correct (migrations run in alphabetical/numeric order)
- If the database state is inconsistent, you may need to reset and re-migrate:
pnpm run db:resetpnpm --filter "@kit/database" drizzle:migrateWarning: Resetting the database will delete all data. Only do this in development.
Run a health check on your project after resolving conflicts
After resolving the conflicts, it's time to test your project to ensure everything is working as expected. Run your project locally and navigate through the various features to verify that everything is functioning correctly.
You can run the following commands for a quick health check:
pnpm run typecheckAnd lint your code with:
pnpm run lint3. Merge the changes
If everything looks good, commit the changes and push them to your remote repository:
git commit -m "COMMIT_MESSAGE"git push origin update-codebase-<date>Once the changes are pushed, you can create a pull request to merge the changes into the main branch, assuming all is working fine.
Your project is now up to date with the latest changes from the upstream repository.
Best Practices for Avoiding Conflicts
- Pull frequently - The more often you pull from upstream, the smaller and easier the merges will be
- Keep customizations isolated - When possible, extend rather than modify core files
- Document your changes - Keep track of which files you've modified to make conflict resolution easier
- Use feature branches - Work on features in separate branches, making it easier to isolate and resolve conflicts
- Review changelogs - Check the MakerKit changelog before updating to understand what's changed
Previous: Running the Project →