This repository contains the Supabase configuration and migrations for the NanoPay.me project.
- We use Supabase as our database provider, utilizing its PostgreSQL database with RESTful API capabilities.
- Our project implements Row Level Security (RLS) to manage data access efficiently at the database level.
Before you begin, ensure you have the following installed:
Install the project dependencies, including the Supabase CLI:
npm install
Initialize your local Supabase instance with the current migrations:
npm run setup
Configure External Authentication Methods: If you need to use external authentication providers (such as GitHub, Google, etc.), update the config.toml file located at the root of the project. Add or modify the relevant sections for each auth provider you want to enable. For example:
[auth.external.github]
enabled = true
client_id = "your_client_id"
secret = "your_client_secret"
redirect_uri = "http://localhost:54321/auth/v1/callback"
# Add other providers as needed
# [auth.external.google]
# [auth.external.facebook]
# etc.
Make sure to replace the placeholder values with your actual OAuth credentials for each provider. For more information on configuring external authentication providers, refer to the Supabase documentation.
Follow this workflow when making changes to the database:
- Make changes to the local database (via UI or SQL)
- Create local migrations
- Test changes in the local instance
- Push changes to the remote instance
-
Check status of local Supabase instance:
npm run status
-
Start local Supabase instance:
npm run start
-
Stop local Supabase instance:
npm run stop
-
Reset local Supabase instance:
npm run reset
-
Show diff between migration files and local instance:
npm run diff
-
Create a migration sql file with current local diff:
npm run migrate "update_table_products"
-
Create an empty migration sql file:
npm run new "update_table_products"
-
Generate database types for TypeScript:
npm run types
-
Link remote Supabase instance:
npm run link
-
Show diff between migration files and remote instance:
npm run diff-remote
-
Create a migration sql file with current remote diff:
npm run migrate-remote "update_table_products"
-
Push changes to remote instance:
npm run push
-
Pull changes from remote instance:
npm run pull
Note: This should not be necessary if following the correct migration flow (local -> remote).
To deploy your project:
- Create a new project in the Supabase dashboard
- Link your local instance to the remote instance using
npm run link
- Push your changes to the remote instance with
npm run push
- When using external authentication providers, make sure to update the env variables in the Supabase dashboard.
-
For more commands, run:
npx supabase --help
For any questions or issues, please open an issue in this repository or consult the Supabase documentation.