Create folders:
mkdir -p app/components/scenes
mkdir -p app/components/page
mkdir -p app/components/navigation
mkdir -p app/components/common
mkdir -p app/components/input
mkdir -p app/routes/api
mkdir -p app/hooks
mkdir -p app/theme
touch app/theme/global.css
mkdir -p app/services
mkdir -p app/utils
mkdir -p server/loaders
mkdir -p server/actions
mkdir -p server/utils
mkdir -p config
mkdir -p public
mkdir -p db/migrations
npm run dev
cd ./supabase
npx supabase start
Take note of API URL
and anon key
. You can also use this to get API keys and URLs:
npx supabase status
Supabase web admin: http://127.0.0.1:54323/
Postgres connection string for TablePlus/Postico: postgresql://postgres:postgres@localhost:54322/postgres
npx supabase db pull # Pull down local db schema from cloud db
npx supabase db push # Push up your local db schema to cloud db
Get data:
npx supabase db dump --data-only -f db_data.sql
psql --single-transaction --file db_data.sql --dbname 'postgresql://postgres:postgres@localhost:54322/postgres'
Edit your local database, then run:
npx supabase db diff -f [migration-name]
# Then normally run: npx supabase db push
Running a migration locally:
npx supabase migration up
Reset database and apply current migrations:
npx supabase db reset
Note: use &api-key=demo
, or set it as a Bearer token in the header.
Live API on https://api.opensustainabilityindex.org/
SELECT * FROM companies(
0, -- offset_value
20, -- limit_value
'name', -- sort_by
'asc', -- sort_order
-- 'Technology', -- industry_filter
-- true, -- near_term_filter
-- 'Type A', -- commitment_type_filter
-- 'Active', -- commitment_status_filter
-- 'Target 1' -- target_target_filter
-- 'omx120' -- tags_filter
);
-- v2:
SELECT * FROM companies_v2(
0, -- offset_value
20, -- limit_value
'name', -- sort_by
'asc' -- sort_order
-- 'Technology', -- industry_filter
-- true, -- near_term_filter
-- 'Type A', -- commitment_type_filter
-- 'Active', -- commitment_status_filter
-- 'Target 1' -- target_target_filter
-- ?? -- emissions_required
-- 'omx120' -- tags_filter
);
Get SQL code:
SELECT pg_get_functiondef('companies_v2'::regproc);