@@ -399,137 +399,3 @@ file_id = f"{purpose}:file-{sha256(content + org_id).hex()[:12]}"
399399- Database tables provide complete audit trail
400400- Worker status: starting, active, shutdown, terminated
401401- Job status: pending, in_progress, completed, failed, canceled
402-
403-
404- # Using supabase
405-
406- <general >
407- Your general approach is as follows:
408- - Check if a supabase project already exists, and if yes, what tables are already present.
409- - If no project exists, create a new project.
410- - Implement the solution: write the code along with tests for the new functionality.
411- You are very smart - if you notice that these steps are not appropriate for the task at hand, feel free to adapt them as needed.
412- - Check that things worked as expected before moving on to the next step.
413- </general >
414-
415- <supabase >
416- # Supabase CLI Guide
417-
418- ## Prerequisites
419- - Supabase CLI installed
420- - Valid ` SUPABASE_ACCESS_TOKEN ` in your environment
421-
422- ## Common Operations
423-
424- ### Creating a New Project
425- ``` bash
426- supabase projects create < project-name>
427- ```
428- This will prompt you to:
429- 1 . Select an organization
430- 2 . Choose a region
431- 3 . Set a database password (optional - will generate if left blank)
432-
433- ### Listing Projects
434- ``` bash
435- supabase projects list
436- ```
437- This shows all your projects with details including:
438- - Organization ID
439- - Project Reference ID
440- - Project Name
441- - Region
442- - Creation Date
443-
444- ### Getting Project API Keys
445- ``` bash
446- supabase projects api-keys --project-ref < project-ref>
447- ```
448- This will return two keys:
449- - ` anon ` - public key for client-side operations
450- - ` service_role ` - secret key for server-side operations
451-
452- ### Project URL Format
453- The project URL follows this pattern:
454- ```
455- https://<project-ref>.supabase.co
456- ```
457-
458- ## Database Management
459-
460- ### Initial Setup
461- 1 . Initialize a Supabase project locally (if not already done):
462- ``` bash
463- supabase init
464- ```
465-
466- 2 . Link to your remote project:
467- ``` bash
468- supabase link --project-ref < project-ref>
469- ```
470-
471- ### Creating and Applying Database Changes
472-
473- 1 . Create a new migration:
474- ``` bash
475- supabase migration new < migration_name>
476- ```
477- This creates a new file in ` supabase/migrations/YYYYMMDDHHMMSS_<migration_name>.sql `
478-
479- 2 . Edit the migration file:
480- - Add your SQL commands
481- - Include table creation, alterations, policies, etc.
482- - Example structure:
483- ``` sql
484- -- Enable RLS
485- alter table if exists " public" ." my_table" enable row level security;
486-
487- -- Create tables
488- create table if not exists " public" ." my_table" (
489- " id" uuid not null default gen_random_uuid(),
490- " created_at" timestamp with time zone default timezone(' utc' ::text , now()) not null ,
491- -- ... other columns
492- primary key (id)
493- );
494-
495- -- Add RLS policies
496- create policy " Users can view own data"
497- on my_table for select
498- using (auth .uid () = user_id);
499-
500- -- Create views
501- create or replace view my_summary as
502- select ...;
503- ```
504-
505- 3 . Push changes to remote:
506- ``` bash
507- supabase db push
508- ```
509- This will apply your migrations to the remote database.
510-
511- ### Creating Users via API
512- To create a user directly using the Admin API:
513- ``` bash
514- curl -X POST ' https://[PROJECT_REF].supabase.co/auth/v1/admin/users' \
515- -H " apikey: [SERVICE_ROLE_KEY]" \
516- -H " Authorization: Bearer [SERVICE_ROLE_KEY]" \
517- -H " Content-Type: application/json" \
518- -d ' {
519- "email": "user@example.com",
520- "password": "secure_password",
521- "email_confirm": true
522- }'
523- ```
524- Note:
525- - Use the service_role key (not the anon key)
526- - Both ` apikey ` and ` Authorization ` headers are required
527- - Set ` email_confirm: true ` to create a pre-confirmed user
528-
529-
530- ## Using --help
531- You can always use the ` --help ` flag to get more information than covered here.
532-
533- </supabase >
534-
535- Make sure that you complete one step before moving on to the next - always make sure to check if the previous step was successful before proceeding.
0 commit comments