Populating the Supabase Postgres database with actual structure.
Within Supabase, you can create custom roles. These roles can be used to make sure only users with the correct role can select, update, delete data - Authorization.
Together with tables, we can populate the first part of our database. In this population, we have also integrated relations. The reason we use relations is simple: we want to make sure that data can only be created with correct information. If you can insert a random value for user, then your database structure is incomplete. This can cause issues with rendering the data in your application later.
Within your Supaboost-V1.0 license, you have access to the .ZIP file
Supaboost-V1.0-SQL-Scripts. In this zip file, there are three text documents.
- Create tables and roles
- Create functions and triggers
- Create Row Level Security for Tables
This section will cover the file
1. Create tables and roles.
1. Create tables and roles there will be multiple rows. Which tables are we creating?
- This is basic functionality, to display the possibilities of what a Supaboost app can do
- This table is used to create profiles of users
- User_info is used to create non-changeable user information, such as company, is_active and if the user is the first within a company
- Changeable Company information, such as name, country, VAT identifier and Chamber of Commerce number
- Used to register subscription for a company, including status, customer_id (within Lemon Squeezy) and the variant of the subscription they are linked to
- Used as a link table to connect users and companies
Now comes the good part, let's get our database structure in!
- Open Supabase
- Log in to your project
- Open the SQL Editor
- Then select
+ New query
New blank query
- Open the Untitled query dropdown
- Enter the name of the text document:
1. Create tables and roles
- Paste the SQL statement of the text document in the Text Editor
- Then select
- If everything went well you should see the result
Success. No rows returned
When we now go to the table Editor, you will see that we have created 7 tables in Supabase!