supabase
use supabase and drizzle-kit to manage database schema and migrations
workflow
use local-first approach to develop and test supabase:
- create migrations locally: update
schema.ts
and rundrizzle-kit migrate
- push migrations to supabase: run
supabase db push
google auth
row level security
commands
supabase initsupabase startsupabase loginsupabase stopsupabase exportsupabase import
login
login to supabase from local machine and allow to use supabase CLI
npx supabase login
create migration
supabase migrate create -n <migration_name>
supabase and drizzle-kit
https://orm.drizzle.team/learn/tutorials/drizzle-with-supabase
import { config } from 'dotenv';import { drizzle } from 'drizzle-orm/postgres-js';import postgres from 'postgres';
config({ path: '.env' });
const client = postgres(process.env.DATABASE_URL!);export const db = drizzle(client);
drizzle-kit
schema.ts
is the source of truth for the database schema. It is used to generate the migrations and the typescript types.