Skip to content

Commit

Permalink
Merge pull request #259 from mnixo/216
Browse files Browse the repository at this point in the history
#216/supabase cli usage
  • Loading branch information
camelPhonso committed Jun 21, 2024
2 parents c6755fa + 0b55731 commit d8d90d5
Show file tree
Hide file tree
Showing 3 changed files with 4,189 additions and 5,221 deletions.
96 changes: 7 additions & 89 deletions .github/BEFORE_YOUR_FIRST_ISSUE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ You can do this by finding the `fork` button on the top-right corner of our repo
Clone your new project into a local repository:

```bash
git clone [url-to-your-forked-repo-here]
git clone [url-to-your-forked-repo-here]
```

Go to the project directory:

```bash
cd kindly
cd kindly
```

With Node.js 20, install the project dependencies:

```bash
npm install
npm install
```

Add env variables:
Expand All @@ -57,81 +57,29 @@ Once it is installed, start your docker console and make sure there are no outst

You don't need to do anything else within docker for now. A container will be created in the next steps.

### Install the supabase cli
### Supabase CLI

The cli will allow you to set up the schema and seed your local copy of the kindly database. You can find more comprehensive guidance in the [official docs](https://supabase.com/docs/guides/cli/getting-started) but we've outlined below the commands you will need to run in order to get started.

Depending on the operating system you use, run the following command in your terminal to install the CLI:

<details>
<summary><strong>macOS / Linux</strong></summary>

```bash
brew install supabase/tap/supabase
```

</details>

<details>
<summary><strong>Windows</strong></summary>

```bash
npm install supabase --save-dev
```

</details>
<br/>
The CLI will allow you to set up the schema and seed your local copy of the kindly database. You can find more comprehensive guidance in the [official docs](https://supabase.com/docs/guides/cli/getting-started) but we've outlined below the commands you will need to run in order to get started.

We have added to the repo a migration file and a seed file for the database, so you will only need to log into supabase with the following command:

<details>
<summary><strong>macOS / Linux</strong></summary>

```bash
supabase login
```

</details>

<details>
<summary><strong>Windows</strong></summary>

```bash
npx supabase login
```

</details>
<br/>

This will take you to the browser to complete a login. Then you will need to start your container with the following command:

<details>
<summary><strong>macOS / Linux</strong></summary>

```bash
supabase start
```

</details>

<details>
<summary><strong>Windows</strong></summary>

```bash
npx supabase start
```

</details>
<br/>

This script will run the migration file to set up your schema and then will run the `supabase/seed.sql` file to populate the database with some test data.

You should see the new "kindly" container in your docker console now.

Your terminal will have logged a series of details that will look something like this:

```bash

Started supabase local development setup.

API URL: http://localhost:54321
Expand All @@ -140,30 +88,14 @@ Started supabase local development setup.
Inbucket URL: http://localhost:54324
anon key: eyJh......
service_role key: eyJh......

```

You can view these details again at any time by running the following command:

<details>
<summary><strong>macOS / Linux</strong></summary>

```bash
supabase status
```

</details>

<details>
<summary><strong>Windows</strong></summary>

```bash
npx supabase status
```

</details>
<br/>

Copy the `API URL` value into your `.env` file as the value of our `NEXT_PUBLIC_SUPABASE_URL` and the `anon key` value as our `NEXT_PUBLIC_SUPABASE_ANON_KEY` value.

Your local development is now ready ✨
Expand All @@ -172,24 +104,10 @@ You can use the `Studio URL` provided to view and edit your local supabase proje

You can also run all migration files and re-seed the database whenever necessary with the following command:

<details>
<summary><strong>macOS / Linux</strong></summary>

```bash
supabase db reset
```

</details>

<details>
<summary><strong>Windows</strong></summary>

```bash
npx supabase db reset
```

</details>
<br/>
This will set your local project back to the latest committed state and re-populate all data.

## Managing Database Migrations:
Expand All @@ -198,7 +116,7 @@ Now that you are working from a local instance of the database you will need to

You can find more detailed guidance on how to handle migrations in the Supabase [official documentation](https://supabase.com/docs/guides/cli/managing-environments?queryGroups=environment&environment=staging#auto-schema-diff)

We have helpfully included a script in the ```package.json``` to help create a new migration file:
We have helpfully included a script in the `package.json` to help create a new migration file:

```
npm run migrate insert-your-file-name
Expand All @@ -210,7 +128,7 @@ Make sure to replace **insert-your-file-name** with a name that describes your c
Make sure you are on the dev branch then use

```bash
npm run dev
npm run dev
```

## Next Steps
Expand Down
Loading

0 comments on commit d8d90d5

Please sign in to comment.