### Supabase Start Command Response Source: https://supabase.com/docs/reference/cli/supabase-branches-list Example output after successfully starting the Supabase local development setup. ```text Creating custom roles supabase/roles.sql... Applying migration 20220810154536_employee.sql... Seeding data supabase/seed.sql... Started supabase local development setup. ``` -------------------------------- ### Example pre-test setup file with extensions and helpers Source: https://supabase.com/docs/guides/local-development/testing/pgtap-extended This SQL script installs necessary extensions like pgtap, http, and supabase-dbdev, then installs the basejump-supabase_test_helpers. It concludes with a simple test to confirm the setup. ```sql -- install tests utilities -- install pgtap extension for testing create extension if not exists pgtap with schema extensions; /* --------------------- ---- install dbdev ---- ---------------------- Requires: - pg_tle: https://github.com/aws/pg_tle - pgsql-http: https://github.com/pramsey/pgsql-http */ create extension if not exists http with schema extensions; create extension if not exists pg_tle; drop extension if exists "supabase-dbdev"; select pgtle.uninstall_extension_if_exists('supabase-dbdev'); select pgtle.install_extension( 'supabase-dbdev', resp.contents ->> 'version', 'PostgreSQL package manager', resp.contents ->> 'sql' ) from extensions.http( ( 'GET', 'https://api.database.dev/rest/v1/' || 'package_versions?select=sql,version' || '&package_name=eq.supabase-dbdev' || '&order=version.desc' || '&limit=1', array[ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header ], null, null ) ) x, lateral ( select ((row_to_json(x) -> 'content') #>> '{}')::json -> 0 ) resp(contents); create extension "supabase-dbdev"; select dbdev.install('supabase-dbdev'); drop extension if exists "supabase-dbdev"; create extension "supabase-dbdev"; -- Install test helpers select dbdev.install('basejump-supabase_test_helpers'); create extension if not exists "basejump-supabase_test_helpers" version '0.0.6'; -- Verify setup with a no-op test begin; select plan(1); select ok(true, 'Pre-test hook completed successfully'); select * from finish(); rollback; ``` -------------------------------- ### Minimal index_advisor example with table creation Source: https://supabase.com/docs/guides/database/extensions/index_advisor Complete example showing extension installation, table creation, and index_advisor analysis on a simple query with an unindexed column. ```SQL create extension if not exists index_advisor cascade; create table book( id int primary key, title text not null ); select * from index_advisor('select book.id from book where title = $1'); ``` -------------------------------- ### Example Instruments Table Setup Source: https://supabase.com/docs/guides/api/rest/debugging-performance This SQL sets up a sample `instruments` table used for demonstrating query execution plans. ```sql create table instruments ( id int8 primary key, name text ); insert into instruments (id, name) values (1, 'violin'), (2, 'viola'), (3, 'cello'); ``` -------------------------------- ### Start a New Supabase Deployment Source: https://supabase.com/docs/guides/self-hosting/postgres-upgrade-17 Use this command to start a new self-hosted Supabase instance. Postgres 17 is the default, so no special configuration is needed for a fresh setup. ```bash docker compose up -d ``` -------------------------------- ### Start Supabase Stack with Logs Configuration Source: https://supabase.com/docs/reference/self-hosting-analytics/create-endpoint Run the Supabase CLI commands to add the logs configuration and start the stack. ```bash sh run.sh config add logs && \ sh run.sh start ``` -------------------------------- ### Start Local Supabase Stack Source: https://supabase.com/docs/reference/self-hosting-analytics/introduction Use the Supabase CLI to start a local development stack. Logs will use the Postgres backend by default. ```bash supabase start ``` -------------------------------- ### Install Supabase Swift Client with Swift Package Manager Source: https://supabase.com/docs/reference/swift/installing Install the Supabase Swift client using Swift Package Manager. Ensure you have Xcode 12 or later. ```bash swift package init --type executable swift package add supabase-swift ``` -------------------------------- ### Create a bucket with options Source: https://supabase.com/docs/reference/swift/storage-createbucket This example demonstrates creating a bucket with specific configurations, such as public access. ```swift try await supabase.storage.createBucket("my-private-bucket", options: BucketOptions(public: false)) ``` -------------------------------- ### Supabase Redirect Endpoint Example Source: https://supabase.com/docs/guides/integrations/partner-integration-guide This is the GET endpoint that Supabase redirects users to when they click 'Install Integration'. It receives project and organization details as query parameters. ```http GET https:///?project_id=&organization_slug= ``` -------------------------------- ### Install and Start Roboflow Inference Source: https://supabase.com/docs/guides/ai/integrations/roboflow Installs the necessary Roboflow inference packages and starts the local inference server. Ensure Docker is installed on your machine before running this command. ```bash pip install inference inference-cli inference-sdk && inference server start ``` -------------------------------- ### Example Response for Get Projects Source: https://supabase.com/docs/reference/api/v1-activate-custom-hostname This is an example JSON response for the 'Get Projects by Organization' endpoint, illustrating the structure of project data and pagination information. ```json { "projects": [ { "ref": "lorem", "name": "lorem", "cloud_provider": "lorem", "region": "lorem", "is_branch": true, "status": "INACTIVE", "inserted_at": "lorem", "databases": [ { "infra_compute_size": "pico", "region": "lorem", "status": "ACTIVE_HEALTHY", "cloud_provider": "lorem", "identifier": "lorem", "type": "PRIMARY", "disk_volume_size_gb": 42, "disk_type": "gp3", "disk_throughput_mbps": 42, "disk_last_modified_at": "lorem" } ] } ], "pagination": { "count": 42, "limit": 42, "offset": 42 } } ``` -------------------------------- ### Basic GET Request Source: https://supabase.com/docs/guides/database/extensions/http Example of how to perform a basic GET request to a RESTful API endpoint using the `http_get` function and casting the content to JSONB. ```APIDOC ## Basic `GET` ```sql select "status", "content"::jsonb from extensions.http_get('https://jsonplaceholder.typicode.com/todos/1'); ``` ``` -------------------------------- ### Initialize Prisma Project Source: https://supabase.com/docs/guides/database/prisma Sets up a new Prisma project by creating a directory, installing necessary dependencies, and initializing Prisma. ```bash mkdir hello-prisma cd hello-prisma npm init -y npm install prisma tsx @types/pg --save-dev npm install @prisma/client @prisma/adapter-pg dotenv pg npx tsc --init npx prisma init ``` -------------------------------- ### Initialize and start local database from backup Source: https://supabase.com/docs/guides/local-development/restoring-downloaded-backup Initializes the project and starts the database from a backup file. Ensure the Postgres version matches the backup image version. ```bash 1 supabase init 2 echo '15.6.1.115' > supabase/.temp/postgres-version 3 supabase db start --from-backup db_cluster.backup ``` -------------------------------- ### Get User Information Response Schema Source: https://supabase.com/docs/reference/self-hosting-auth/returns-the-configuration-settings-for-the-gotrue-server Example JSON response for the GET /user endpoint containing detailed profile information for the logged-in user. ```json 1 { 2 "app_metadata": { 3 "property1": null, 4 "property2": null 5 }, 6 "aud": "lorem", 7 "banned_until": "2021-12-31T23:34:00Z", 8 "confirmation_sent_at": "2021-12-31T23:34:00Z", 9 "confirmed_at": "2021-12-31T23:34:00Z", 10 "created_at": "2021-12-31T23:34:00Z", 11 "email": "lorem", 12 "email_change_sent_at": "2021-12-31T23:34:00Z", 13 "email_confirmed_at": "2021-12-31T23:34:00Z", 14 "id": "fbdf5a53-161e-4460-98ad-0e39408d8689", 15 "identities": [ 16 { 17 "created_at": "2021-12-31T23:34:00Z", 18 "id": "lorem", 19 "identity_data": { 20 "property1": null, 21 "property2": null 22 }, 23 "last_sign_in_at": "2021-12-31T23:34:00Z", 24 "provider": "lorem", 25 "updated_at": "2021-12-31T23:34:00Z", 26 "user_id": "fbdf5a53-161e-4460-98ad-0e39408d8689" 27 } 28 ], 29 "invited_at": "2021-12-31T23:34:00Z", 30 "last_sign_in_at": "2021-12-31T23:34:00Z", 31 "new_email": "lorem", 32 "new_phone": "lorem", 33 "phone": "lorem", 34 "phone_change_sent_at": "2021-12-31T23:34:00Z", 35 "phone_confirmed_at": "2021-12-31T23:34:00Z", 36 "reauthentication_sent_at": "2021-12-31T23:34:00Z", 37 "recovery_sent_at": "2021-12-31T23:34:00Z", 38 "role": "lorem", 39 "updated_at": "2021-12-31T23:34:00Z", 40 "user_metadata": { 41 "property1": null, 42 "property2": null 43 } 44 } ``` -------------------------------- ### Initialize Node.js Project and Install Supabase Client Source: https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore Set up a new Node.js project and install the necessary Supabase JavaScript client package. ```bash npm init -y npm install @supabase/supabase-js ``` -------------------------------- ### Initialize and start local Supabase project Source: https://supabase.com/docs/guides/troubleshooting/new-branch-doesnt-copy-database Run these commands to set up the local environment required for migration synchronization. ```bash 1 supabase init 2 supabase start ``` -------------------------------- ### Get All Buckets Response (200) Source: https://supabase.com/docs/reference/self-hosting-storage/copies-an-object Example response for successfully retrieving a list of buckets. ```json [ { "id": "bucket2", "name": "bucket2", "public": false, "file_size_limit": 1000000, "allowed_mime_types": [ "image/png", "image/jpeg" ], "owner": "4d56e902-f0a0-4662-8448-a4d9e643c142", "created_at": "2021-02-17T04:43:32.770206+00:00", "updated_at": "2021-02-17T04:43:32.770206+00:00" } ] ``` -------------------------------- ### Create Sample Table and Data Source: https://supabase.com/docs/guides/database/extensions/hypopg Creates a sample 'account' table and populates it with 10,000 rows of data for testing query performance. ```sql create table account ( id int, address text ); insert into account(id, address) select id, id || ' main street' from generate_series(1, 10000) id; ``` -------------------------------- ### Basic Example: Create Customer Foreign Table and Select All Source: https://supabase.com/docs/guides/database/extensions/wrappers/paddle Illustrates the full process of defining a foreign table for Paddle customers and immediately querying all its data. ```sql create foreign table paddle.customers ( id text, name text, email text, status text, custom_data jsonb, created_at timestamp, updated_at timestamp, attrs jsonb ) server paddle_server options ( object 'customers', rowid_column 'id' ); select * from paddle.customers; ``` -------------------------------- ### Install supabase-dbdev using database.dev Source: https://supabase.com/docs/guides/local-development/testing/pgtap-extended Installs the supabase-dbdev package, a Postgres package manager, by first enabling http and pg_tle extensions, then fetching and installing the extension via database.dev API. It also includes steps to drop and recreate the extension for a clean setup. ```sql create extension if not exists http with schema extensions; create extension if not exists pg_tle; drop extension if exists "supabase-dbdev"; select pgtle.uninstall_extension_if_exists('supabase-dbdev'); select pgtle.install_extension( 'supabase-dbdev', resp.contents ->> 'version', 'PostgreSQL package manager', resp.contents ->> 'sql' ) from extensions.http( ( 'GET', 'https://api.database.dev/rest/v1/' || 'package_versions?select=sql,version' || '&package_name=eq.supabase-dbdev' || '&order=version.desc' || '&limit=1', array[ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header ], null, null ) ) x, lateral ( select ((row_to_json(x) -> 'content') #>> '{}')::json -> 0 ) resp(contents); create extension "supabase-dbdev"; select dbdev.install('supabase-dbdev'); -- Drop and recreate the extension to ensure a clean installation drop extension if exists "supabase-dbdev"; create extension "supabase-dbdev"; ``` -------------------------------- ### Initialize Supabase and Start Local Stack Source: https://supabase.com/docs/guides/ai/quickstarts/generate-text-embeddings Initialize Supabase in your project directory and start the local development environment. ```bash supabase init supabase start ``` -------------------------------- ### Multi-Platform Application RLS Policies Source: https://supabase.com/docs/guides/auth/oauth-server/token-security Real-world example with three OAuth clients (web, mobile, integration) each with different access levels. Web and direct sessions get full access, mobile gets read-only, integration gets limited public data access. ```sql -- Web app: Full access CREATE POLICY "Web app full access" ON profiles FOR ALL USING ( auth.uid() = user_id AND ( (auth.jwt() ->> 'client_id') = 'web-app-client-id' OR (auth.jwt() ->> 'client_id') IS NULL -- Direct user sessions ) ); -- Mobile app: Read-only access to profiles CREATE POLICY "Mobile app reads profiles" ON profiles FOR SELECT USING ( auth.uid() = user_id AND (auth.jwt() ->> 'client_id') = 'mobile-app-client-id' ); -- Third-party integration: Limited data access CREATE POLICY "Integration reads public data" ON profiles FOR SELECT USING ( auth.uid() = user_id AND (auth.jwt() ->> 'client_id') = 'integration-client-id' AND is_public = true ); ``` -------------------------------- ### Quickstart GraphQL API Request with cURL Source: https://supabase.com/docs/guides/graphql Initial cURL command to send a POST request to the Supabase GraphQL API endpoint, including the API key and a basic query, as shown in the Quickstart guide. ```bash curl -X POST https://.supabase.co/graphql/v1 \ -H 'apiKey: ' \ -H 'Content-Type: application/json' \ --data-raw '{"query": "{ accountCollection(first: 1) { edges { node { id } } } }", "variables": {}}' ``` -------------------------------- ### Initialize Supabase in an Existing Project Source: https://supabase.com/docs/guides/functions/quickstart Navigate to your existing project directory and run this command to initialize Supabase if it hasn't been configured yet. This ensures the project has a `supabase` folder with a `config.toml` file. ```bash cd your-existing-project supabase init # Initialize Supabase, if you haven't already ``` -------------------------------- ### Set up Python Virtual Environment Source: https://supabase.com/docs/guides/getting-started/quickstarts/flask Commands to create a new project directory, initialize a Python virtual environment, and activate it. ```bash mkdir my-app && cd my-app python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Supabase Stop Command Response Source: https://supabase.com/docs/reference/cli/supabase-branches-list Example output after successfully stopping the Supabase local development setup. ```text Stopped supabase local development setup. Local data are backed up to docker volume. ``` -------------------------------- ### Get Bucket Details Response (200) Source: https://supabase.com/docs/reference/self-hosting-storage/copies-an-object Example response for successfully retrieving details of a specific bucket. ```json { "id": "lorem", "name": "lorem", "owner": "lorem", "owner_id": "lorem", "public": true, "type": "STANDARD", "created_at": "lorem", "updated_at": "lorem" } ``` -------------------------------- ### Create a pre-test setup file Source: https://supabase.com/docs/guides/local-development/testing/pgtap-extended Generate a new SQL file for shared test setup using the `supabase test new` command. This file should be named with a prefix like `000-` to ensure it runs first alphabetically. ```bash supabase test new 000-setup-tests-hooks ``` -------------------------------- ### Install Ionic CLI and Start Vue App Source: https://supabase.com/docs/guides/getting-started/tutorials/with-ionic-vue Install the Ionic CLI globally and then create a new Ionic Vue app named 'supabase-ionic-vue' using the blank template. Finally, navigate into the project directory. ```bash npm install -g @ionic/cli ionic start supabase-ionic-vue blank --type vue cd supabase-ionic-vue ``` -------------------------------- ### Initializing the Supabase Client Source: https://supabase.com/docs/reference/python/storage-from-list Demonstrates how to create a Supabase client instance using the `create_client` method with URL and Key. ```APIDOC ## Initializing the Supabase Client You can initialize a new Supabase client using the `create_client()` method. ### Parameters * **supabase_url** (string) - Required - The unique Supabase URL which is supplied when you create a new project in your project dashboard. * **supabase_key** (string) - Required - The unique Supabase Key which is supplied when you create a new project in your project dashboard. * **options** (ClientOptions) - Optional - Options to change the Auth behaviors. ### Request Example ```python import os from supabase import create_client, Client url: str = os.environ.get("SUPABASE_URL") key: str = os.environ.get("SUPABASE_KEY") supabase: Client = create_client(url, key) ``` ```