You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
6.From there, go to the SQL Editor tab (<imgsrc="../images/supabase_sql_editor.png"width="100">) and paste the [schema.sql](/supabase/schema.sql) from this repo, and execute. This will enable all the relevant extensions (pgvector) and create the two tables:
49
+
6.By now, you should have 4 things: `email` & `password` for your supabase user, and the `Supabase URL`and `API Anon Key`.
7. If so, go to your terminal, and cd to the supabase folder: `cd ./supabase`
52
52
53
-
7. By now, you should have 4 things: `email` & `password` for your supabase user, and the `Supabase URL` and `API Anon Key`.
54
-
55
-
8. If so, go to your terminal, and cd to the supabase folder: `cd ./supabase`
56
-
57
-
9. Install Supabase and set up the CLI. You should follow thier [guide here](https://supabase.com/../guides/cli/getting-started?platform=macos#installing-the-supabase-cli), but in short:
53
+
8. Install Supabase and set up the CLI. You should follow thier [guide here](https://supabase.com/../guides/cli/getting-started?platform=macos#installing-the-supabase-cli), but in short:
58
54
- run `brew install supabase/tap/supabase` to install the CLI (or [check other options](https://supabase.com/../guides/cli/getting-started))
59
55
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) on your computer (we won't use it, we just need docker daemon to run in the background for deploying supabase functions)
60
-
10. Now when we have the CLI, we need to login with oour Supabase account, running `supabase login` - this should pop up a browser window, which should prompt you through the auth
61
-
11. And link our Supabase CLI to a specific project, our newly created one, by running `supabase link --project-ref <your-project-id>` (you can check what the project id is from the Supabase web UI, or by running `supabase projects list`, and it will be under "reference id") - you can skip (enter) the database password, it's not needed.
56
+
9. Now when we have the CLI, we need to login with our Supabase account, running `supabase login` - this should pop up a browser window, which should prompt you through the auth
57
+
10. And link our Supabase CLI to a specific project, our newly created one, by running `supabase link --project-ref <your-project-id>` (you can check what the project id is from the Supabase web UI, or by running `supabase projects list`, and it will be under "reference id") - you can skip (enter) the database password, it's not needed.
58
+
11. Now we need to apply the Adeus DB schema on our newly created, and empty database. We can do this by simply run: `supabase db push`. We can verify it worked by going to the Supabase project -> Tables -> and see that new tables were created.
62
59
12. Now let's deploy our functions! ([see guide for more details](https://supabase.com/../guides/functions/deploy)) `supabase functions deploy --no-verify-jwt` (see [issue re:security](https://github.com/adamcohenhillel/AdDeus/issues/3))
63
60
13. If you're planning to first use OpenAI as your Foundation model provider, then you'd need to also run the following command, to make sure the functions have everything they need to run properly: `supabase secrets set OPENAI_API_KEY=<your-openai-api-key>` (Ollama setup guide is coming out soon)
64
61
14. If you want access to tons of AI Models, both Open & Closed Source, set up your OpenRouter API Key. Go to [OpenRouter](https://openrouter.ai/) to get your API Key, then run `supabase secrets set OPENROUTER_API_KEY=<your-openrouter-api-key>`.
If you're working on a new feature that requires changes to the database, then you need to generate a migration file for those changes, so when your feature is merged to the main branch, and start being used by other people, they will be able to update their database accordingly.
21
+
22
+
This guide provides step-by-step instructions for how to make migration file from your Supabaase database changes.
23
+
24
+
25
+
## Create the migration
26
+
27
+
Let's say you edited the database in your Supabase project. You added the column "new_data" to the table.
28
+
29
+
Now you need to make sure others will have that column as well.
30
+
31
+
32
+
1. Go to the supabase folder in your local cloned repo
33
+
```bash
34
+
cd supabase
35
+
```
36
+
37
+
2. Make sure you're linked to the right Supabase project:
38
+
```bash
39
+
supabase link --project-ref <YOUR_REMOTE_SUPABASE_PROJECT_ID>
40
+
```
41
+
42
+
3. Create a new migration from the remote Supabase instance:
43
+
```bash
44
+
supabase db pull
45
+
```
46
+
47
+
This will generate a new file in the folder `supabase/migrations` named <timestamp>_remote_commit.sql
48
+
49
+
50
+
Add it to your branch, and push it with the rest of the feature code to your PR.
51
+
52
+
53
+
## Sync your database with all existing migrations
54
+
55
+
In case there are new migrations for Adeus, and you need to sync your own database with the latest migrations, follow these instructions:
56
+
57
+
58
+
1. Go to the supabase folder in your local cloned repo
59
+
```bash
60
+
cd supabase
61
+
```
62
+
63
+
2. Make sure you're linked to the right Supabase project:
64
+
```bash
65
+
supabase link --project-ref <YOUR_REMOTE_SUPABASE_PROJECT_ID>
66
+
```
67
+
68
+
3. Have a dry run:
69
+
70
+
```bash
71
+
supabase db push --dry-run
72
+
```
73
+
This will tell you what migrations will need to run, but without executing. This is useful way to see upfront what the migration changes are.
@@ -95,6 +95,10 @@ GRANT USAGE ON SCHEMA "public" TO "anon";
95
95
GRANT USAGE ON SCHEMA "public" TO "authenticated";
96
96
GRANT USAGE ON SCHEMA "public" TO "service_role";
97
97
98
+
GRANT ALL ON FUNCTION "public"."match_records_embeddings_similarity"(query_embedding extensions.vector, match_threshold double precision, match_count integer) TO "anon";
99
+
GRANT ALL ON FUNCTION "public"."match_records_embeddings_similarity"(query_embedding extensions.vector, match_threshold double precision, match_count integer) TO "authenticated";
100
+
GRANT ALL ON FUNCTION "public"."match_records_embeddings_similarity"(query_embedding extensions.vector, match_threshold double precision, match_count integer) TO "service_role";
101
+
98
102
GRANT ALL ON TABLE "public"."conversations" TO "anon";
99
103
GRANT ALL ON TABLE "public"."conversations" TO "authenticated";
100
104
GRANT ALL ON TABLE "public"."conversations" TO "service_role";
0 commit comments