|
1 | 1 | # Documentation for development |
2 | 2 |
|
3 | 3 | > [!WARNING] |
4 | | -> TODO: This document is a work in progress. Please help us improve it by contributing! |
| 4 | +> TODO: This document is a work in progress. Please help us improve it! |
5 | 5 |
|
6 | 6 | See those other useful documents as well: |
7 | 7 | - [knowledge.md](knowledge.md) for high-level architecture and design decisions. |
8 | 8 | - [README.md](../backend/api/README.md) for the backend API |
9 | 9 | - [README.md](../backend/email/README.md) for the email routines and how to set up a local server for quick email rendering |
10 | 10 | - [README.md](../web/README.md) for the frontend / web server |
11 | 11 |
|
12 | | -### Adding a new profile variable |
| 12 | +### Adding a new profile field |
13 | 13 |
|
14 | | -To add a profile variable (personality type, etc.), make modifications here: |
15 | | -* ... |
| 14 | +A profile field is any variable associated with a user profile, such as age, politics, diet, etc. You may want to add a new profile field if it helps people find better matches. |
16 | 15 |
|
17 | | -You will likely need to update the `profiles` table of the database. Set up an SQL migration file that updates the table, as in [migrations](../backend/supabase/migrations), and run it in the same vein as [migrate.sh](../scripts/migrate.sh). |
| 16 | +To do so, you can add code in a similar way as in [this commit](https://github.com/CompassConnections/Compass/commit/b94cdba5af377b06c31cebb97c0a772ad6324690) for the `diet` field. |
18 | 17 |
|
19 | | -Sync the database types from supabase to the local files (which assist Typescript in typing): |
| 18 | +[//]: # (If you also want people to filter by that profile field, you'll also need to add it to the search filters, as done in [this commit](https://github.com/CompassConnections/Compass/commit/591798e98c51144fe257e28cf463707be748c2aa) for the education level. ) |
| 19 | + |
| 20 | +Note that you will also need to add a column to the `profiles` table in the dev database before running the code; you can do so via this SQL command (change the type if not `TEXT`): |
| 21 | +```sql |
| 22 | +ALTER TABLE profiles ADD COLUMN some_new_profile_field TEXT; |
| 23 | +``` |
| 24 | + |
| 25 | +Store it in `add_some_some_profile_field.sql` in the [migrations](../backend/supabase/migrations) folder and run [migrate.sh](../scripts/migrate.sh) from the root folder: |
20 | 26 | ```bash |
| 27 | +./scripts/migrate.sh backend/supabase/migrations/add_some_new_profile_field.sql |
| 28 | +``` |
21 | 29 |
|
22 | | -yarn regen-types |
| 30 | +Then sync the database types from supabase to the local files (which assist Typescript in typing): |
| 31 | +```bash |
| 32 | +yarn regen-types dev |
23 | 33 | ``` |
24 | 34 |
|
| 35 | +That's it! |
| 36 | + |
25 | 37 | ### Cover with tests |
26 | 38 |
|
27 | 39 | Best Practices |
|
0 commit comments