Introduction to the Database in the React Native Supabase Kit
How to use the Supabase Database in the React Native Supabase Kit
The Database provided in the React Native Supabase Kit is a simple schema with one single table: accounts
. It is the same provided by the Next.js Supabase Lite Kit.
NB: If you are using a Pro version of the Turbo kits, please replace the schema with the one provided by the Pro kit. The code in this kit is compatible with the schema of the Pro kit, as it's designed to be used in conjunction with it. However, it can also be used as a standalone schema.
Accounts
The accounts
table is the main table of the schema. It contains the following fields:
create table if not exists public.accounts( id uuid unique not null default extensions.uuid_generate_v4(), name varchar(255) not null, email varchar(320) unique, updated_at timestamp with time zone, created_at timestamp with time zone, created_by uuid references auth.users, updated_by uuid references auth.users, picture_url varchar(1000), public_data jsonb default '{}'::jsonb not null, primary key (id));
When a new user signs up, the accounts
table is automatically populated with the user data. The id
of the account is the uuid
generated by the Supabase database for the user's account in the auth.users
table.
From here on, you can add more tables to the schema, and link them to the accounts
table using the account_id
field to reference the user's account.