Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: update sql template

Hieu Vu2e035241a8f4
diff --git a/apps/docs/components/MDX/kotlin_project_setup.mdx b/apps/docs/components/MDX/kotlin_project_setup.mdx
new file mode 100644
index 00000000000..11bfe2f9805
--- /dev/null
+++ b/apps/docs/components/MDX/kotlin_project_setup.mdx
@@ -0,0 +1,45 @@
+import ProductManagementSQLTemplate from './product_management_sql_template.mdx'
+import { Tabs } from 'ui'
+export const TabPanel = Tabs.Panel
+
+## Project setup
+
+Before we start building we're going to set up our Database and API. This is as simple as starting a new Project in Supabase and then creating a "schema" inside the database.
+
+### Create a project
+
+1. [Create a new project](https://app.supabase.com) in the Supabase Dashboard.
+1. Enter your project details.
+1. Wait for the new database to launch.
+
+### Set up the database schema
+
+Now we are going to set up the database schema. You can just copy/paste the SQL from below and run it yourself.
+
+<Tabs
+ scrollable
+ size="small"
+ type="underlined"
+ defaultActiveId="dashboard"
+>
+<TabPanel id="dashboard" label="Dashboard">
+
+1. Go to the [SQL Editor](https://app.supabase.com/project/_/sql) page in the Dashboard.
+2. Click **Product Management**.
+3. Click **Run**.
+
+</TabPanel>
+<TabPanel id="sql" label="SQL">
+
+<ProductManagementSQLTemplate />
+
+</TabPanel>
+</Tabs>
+
+### Get the API Keys
+
+Now that you've created some database tables, you are ready to insert data using the auto-generated API.
+We just need to get the Project URL and `anon` key from the API settings.
+
+1. Go to the [API Settings](https://app.supabase.com/project/_/settings/api) page in the Dashboard.
+1. Find your Project `URL`, `anon`, and `service_role` keys on this page.
diff --git a/apps/docs/components/MDX/product_management_sql_template.mdx b/apps/docs/components/MDX/product_management_sql_template.mdx
new file mode 100644
index 00000000000..e728bc67b91
--- /dev/null
+++ b/apps/docs/components/MDX/product_management_sql_template.mdx
@@ -0,0 +1,41 @@
+```sql
+-- Create a table for public profiles
+create table products (
+ id uuid references auth.users not null primary key,
+ updated_at timestamp with time zone,
+ username text unique,
+ full_name text,
+ avatar_url text,
+ website text,
+ constraint username_length check (char_length(username) >= 3)
+);
+
+-- Set up Row Level Security (RLS)
+-- See https://supabase.com/docs/guides/auth/row-level-security for more details.
+alter table products
+ enable row level security;
+
+create policy "Public profiles are viewable by everyone." on profiles
+ for select using (true);
+
+create policy "Users can insert their own profile." on profiles
+ for insert with check (auth.uid() = id);
+
+create policy "Users can update own profile." on profiles
+ for update using (auth.uid() = id);
+
+-- Set up Storage!
+insert into storage.buckets (id, name)
+ values ('products', 'products');
+
+-- Set up access controls for storage.
+-- See https://supabase.com/docs/guides/storage#policy-examples for more details.
+create policy "Avatar images are publicly accessible." on storage.objects
+ for select using (bucket_id = 'products');
+
+create policy "Anyone can upload an avatar." on storage.objects
+ for insert with check (bucket_id = 'products');
+
+create policy "Anyone can update their own avatar." on storage.objects
+ for update using (auth.uid() = owner) with check (bucket_id = 'products');
+```