This is the Sveltekit project for the Admin site of Freyza Employee System.
The tech stack is:
- SvelteKit
- TypeScript
- Drizzle ORM
- Supabase (PostgreSQL)
This project also uses supabase cli setup for local development. All values in .env.local should refer to local instances.
We use the drizzle postgres user with all drizzle queries. It is created automatically when running supabase db reset via the supabase/roles.sql.
Edit the file to update the password, and DON'T COMMIT WITH THE PASSWORD (revert it back). Use the set password in .env.local.
- Always create new branches to work on from the
previewbranch. - Install Supabase CLI and run
bun supabase:startto start all the supabase services. - Take a note of addresses and keys in the output or
bun supabase:statusoutput. Update.env.local - Run
bun supabase db resetto reset the database and apply the migrations. - Run
./drizzle/seed.shto seed in all the values (will merge into supabase seed later). - Run
bun devto start the development vite server.
Using drizzle and supabase cli can be cumbersome together, but i have this flow...
- Update
./src/lib/db/schema.tsaccordingly. - Add new types to
./src/lib/types.tsand./src/lib/constants.tsif needed. - Run
bun db:generateto generate the new schema. - Run
bun supabase:migrateto apply the migrations to the local db. - Run
bun db:studioto open the drizzle studio or open the local supabase dashboard.
NOTE: We use drizzle to generate the migration files into ./supabase/migrations, and then let supabase handle the actual migration process. NEVER use drizzle to apply migrations.
All preview deployments are sourced from the preview branch here on github, deployed to the preview vercel project with migrations pushed to the preview supabase project.
Never push directly to the preview branch. Use other branches to work (no builds are created for commits to those branches), and open a PR to the preview branch.
Vercel will create a preview deployment for each PR automatically. Upon merging a PR, the preview deployment will be promoted to the preview environment.
With that, the supabase-preview workflow will run and apply any pending migrations to the preview supabase project.
All new development branches should be created on the preview branch.
Always seed only ONCE to the preview db running bun run --env-file=.env.preview ./src/lib/server/seed/location.ts
When merging a PR to preview, do squash and merge (or rebase if want to save commits) using GitHub's UI.
Create a PR from preview to main and merge once okay. This will NOT create any preview deployments.
Upon merging, vercel deploys the build to the prod vercel project with migrations pushed to the prod supabase project using the supabase-production workflow.
NEVER EVER push to main directly, don't even think of doing that. Only tested code should flow into main.
Always seed only ONCE to the preview db running bun run --env-file=.env.production ./src/lib/server/seed/location.ts
When merging a PR to main, just open the PR, but merge using the command line locally, to prevent creating additional merge commits.
git switch preview
git pull origin preview
git switch main
git pull origin main
git merge --ff-only preview
git push origin main