Install pnpm if not installed globally on your local machine:
npm install -g pnpm
Install dependencies:
pnpm i
First, run the development server:
pnpm dev
To run the optimized production server:
pnpm build
pnpm start
Open http://localhost:3000 with your browser to see the result.
-
npx supabase login
-
npx supabase link --project-ref Project_ID
-
npx supabase db pull (only while setup, don't need to run)
-
npx supabase init (only while setup, don't need to run)
-
npx supabase start
-
npx supabase stop
-
npx supabase db reset
Note: need to change SUPABASE_URL and NEXT_PUBLIC_SUPABASE_URL to "http://localhost:54321" for local development
- Supabase GUI URL http://localhost:54323/
NEXT_PUBLIC_SUPABASE_URL="http://localhost:54323"
- Open GUI
- Create new table in Table Editor or run sql in SQL Editor
- Open Terminal
- Run "npx supabase db diff --local --file add_table/column_name". This will generate new migration file inside supabase/migrations folder.
create table audit_log (
id bigint generated by default as identity primary key,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null,
updated_at timestamp with time zone default timezone('utc'::text, now()) not null,
user_id uuid not null references auth.users(id) on delete cascade,
action_type text not null check (action_type in ('CREATE', 'UPDATE', 'DELETE', 'LOGIN', 'LOGOUT')),
table_name text not null,
record_id bigint not null,
previous_data jsonb,
new_data jsonb,
ip_address text,
user_agent text
);
- Run "npx supabase db push"
- Run "npx supabase db push --db-url db_url"