Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

docs: Changes to readme after testing out supabase example #11

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions seed/supabase-twitter-clone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ First, let's set up a local development environment for the Supabase Twitter clo

```bash
npx supabase login
npx supabase init
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this when I ran this:

 failed to create config file: open supabase/config.toml: file exists
Try rerunning the command with --debug to troubleshoot the error.

I guess we don't need to init anymore since we already checked in the stuff that was generated during init.

```

![supabase-init-asciinema](https://github.com/snaplet/examples/assets/8771783/10f11bca-5dd5-42ac-b81a-b33d6016026e)
Expand All @@ -71,23 +70,11 @@ First, let's set up a local development environment for the Supabase Twitter clo
# Your projectID can be found using the `supabase projects list` command and noting the REFERENCE ID value.
# Input your remote database password when prompted.
npx supabase link --project-ref <your-twitter-clone-project-id>
# Create a valid migrations folder for Supabase to pull the first migration.
mkdir -p supabase/migrations
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, the dir already existed. I guess we could keep this around regardless (won't error or anything), but didn't seem needed anymore.


# Pull the database schema from the remote project.
npx supabase db pull
```

This process creates a new `remote_schema.sql` file within the `supabase/migrations` folder. However, this migration lacks the necessary triggers and publications for our real-time updates to function correctly. Thus, we need to manually add them to the `remote_schema.sql` file:

```sql
-- Append at the end
-- Trigger to create a profile for a user upon creation
CREATE TRIGGER on_auth_user_created AFTER INSERT ON auth.users FOR EACH ROW EXECUTE FUNCTION "public"."create_profile_for_user"();
-- Publication for the tweets table to enable real-time functionality
ALTER PUBLICATION "supabase_realtime" ADD TABLE "public"."tweets";
RESET ALL;
```
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were already in the migration file that was checked into the repo, so I guessed we don't need these lines in the readme anymore: https://github.com/snaplet/examples/blob/main/seed/supabase-twitter-clone/supabase/migrations/20240312180754_remote_schema.sql#L169-L171


Next, we must synchronize our local development project with the remote one:

```bash
Expand Down