The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Adds blog post
Paul Copplestone0ebbe6bf33a6
diff --git a/www/_blog/2021-03-31-supabase-cli.mdx b/www/_blog/2021-03-31-supabase-cli.mdxindex ba59e47b2d3..9c7e5462afd 100644--- a/www/_blog/2021-03-31-supabase-cli.mdx+++ b/www/_blog/2021-03-31-supabase-cli.mdx@@ -10,8 +10,6 @@ tags:date: '03-31-2021'----## Intro-Today is Day 3 of [Launch Week](https://supabase.io/blog/2021/03/25/launch-week), and as promised - we're releasing our CLI.This is the first step in a long journey of features we plan to deliver:@@ -29,9 +27,9 @@ Here are some of the items we have completed so far.You can now run Supabase on your local machine, using Docker Compose. This Docker setup is 100% compatible with every project on Supabase - the tools used for local development are exactly the same as production.-We have released a full set of documentation here. In this post we thought it would be useful to highlight how easy it is to get started.+We have released a full set of documentation [here](https://supabase.io/docs/guides/local-development). In this post we thought it would be useful to highlight how easy it is to get started.-A lot of Supabase developers are familiar with React, here are the steps you would use to create a new React project which uses Supabase as a backend.+A lot of Supabase developers are familiar with React, so here are the steps you would use to create a new React project which uses Supabase as a backend.Install the CLI:@@ -43,7 +41,7 @@ Set up your React app:```bash# create a fresh React app-npx create-react-app react-demo+npx create-react-app react-demo --use-npm# move into the new foldercd react-demo@@ -70,7 +68,7 @@ Now that your application is now prepared, you can use Supabase anywhere in your```jsximport { createClient } from '@supabase/supabase-js'const SUPABASE_URL = 'http://localhost:8000'-const SUPABASE_ANON_KEY = SUPABASE_ANON_K+const SUPABASE_ANON_KEY = SUPABASE_ANON_KEYconst supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)```@@ -89,9 +87,9 @@ Soon we will give you the ability to push your changes from your local machine t## Migrations-Database Migrations are simply the process of "changing" your database schema. In a NoSQL database you don't need migrations, because you can insert any JSON data without validation. However with Relational databases you define your schema upfront, and the database will reject data which doesn't "fit" the schema. This is one of the reasons Relational databases are so scalable - schemas ensure data integrity.+Database Migrations are a process to "change" your database schema. In a NoSQL database you don't need migrations, because you can insert any JSON data without validation. However with Relational databases you define your schema upfront, and the database will reject data which doesn't "fit" the schema. This is one of the reasons Relational databases are so scalable - schemas ensure data integrity.-Just like an application though, a database schema needs to be constantly updated. And that's where Migrations fit! Migrations are simply a set of SQL scripts which change your database schema.+Just like an application though, a database schema needs to be constantly updated. And that's where migrations fit! Migrations are simply a set of SQL scripts which change your database schema.There is one problem however: there is [no "right" way](https://news.ycombinator.com/item?id=21405501) to do migrations.@@ -138,9 +136,9 @@ This is critical for Row Level Security to work with views. For policies to kickThere was a problem in using the [pgAdmin Schema Diff](https://www.pgadmin.org/docs/pgadmin4/development/schema_diff.html) though, it's a GUI-only tool.-+-So we did one of the things we do best - improve existing open source software. We created a CLI mode for the Schema Diff on [our repo](https://github.com/supabase/pgadmin4/blob/cli/web/cli.py). We've also released a [docker image](https://hub.docker.com/r/supabase/pgadmin-schema-diff) for a quick start.+So we did what we always strive to do - improve existing open source software. We created a CLI mode for the Schema Diff on [our repo](https://github.com/supabase/pgadmin4/blob/cli/web/cli.py). We've also released a [docker image](https://hub.docker.com/r/supabase/pgadmin-schema-diff) for a quick start.The CLI offers the same functionality as the GUI version. You can diff two databases by specifying the connection strings like shown below.@@ -173,12 +171,12 @@ Done.A sample diff can be seen on this [gist](https://gist.github.com/steve-chavez/3f286a233806aeee0bcea4a47f97f0b5). This was generated by diffing these [two databases](https://github.com/supabase/pgadmin4/tree/cli/web/pgadmin/tools/schema_diff/tests/pg/10_plus).-On these [lines](https://gist.github.com/steve-chavez/3f286a233806aeee0bcea4a47f97f0b5#file-diff_demo-sql-L1022-L1023) you can see how it tracks the view's owner change(note: the `ALTER TABLE` statement is interchangeable with `ALTER VIEW` in this case).+On these [lines](https://gist.github.com/steve-chavez/3f286a233806aeee0bcea4a47f97f0b5#file-diff_demo-sql-L1022-L1023), you can see how it tracks the view's owner change (note: the `ALTER TABLE` statement is interchangeable with `ALTER VIEW` in this case). Additionally, you can see that it handles [domains](https://gist.github.com/steve-chavez/3f286a233806aeee0bcea4a47f97f0b5#file-diff_demo-sql-L278-L287) just fine(this is an edge-case that other diff tools don't handle).Also, similarly to the pgAdmin GUI:- You can include and exclude database objects from the diff with `--include-objects` or `--exclude-objects`-- You can choose a single schema to diff with the `--schema=public` argument. We actually recommend you do this for Supabase databases, diffing the whole database can take a while because of the `extensions` schema(specially if you enable PostGIS, which adds many functions).+- You can choose a single schema to diff with the `--schema` argument. We recommend you do this for Supabase databases. Diffing the whole database can take a while because of the `extensions` schema (especially if you enable PostGIS, which adds many functions).### Next steps@@ -194,23 +192,23 @@ Finally, we are adding one critical command to our CLI for everybody who wants tsupabase eject```-This will give you everything you need to run the Supabase stack wherever you please with docker. By default it even comes bundled with both an API gateway and a postgres database.+This gives you everything you need to run the Supabase stack.After running the command inside the terminal, you will see three items:-- docker-compose.yml-- kong (directory)-- postgres (directory)+- `docker-compose.yml` (file)+- `kong` (directory)+- `postgres` (directory)-If you have an existing postgres database running elsewhere you can easily drop the postgres directory but first make sure you do these three things:+If you have an existing Postgres database running elsewhere you can easily drop the Postgres directory but first make sure you do these three things:-- run the .sql files from the postgres directory on your existing database-- update all references to the DB URI in docker-compose.yml to your existing db-- run [these steps](https://github.com/supabase/realtime#server) to enable replication inside the database, so that the realtime engine can stream changes from you database+- run the .sql files from the Postgres directory on your existing database+- update all references to the DB URI in `docker-compose.yml` to your existing database+- run [these steps](https://github.com/supabase/realtime#server) to enable replication inside the database, so that the realtime engine can stream changes from your database-You may also want to play with the environment variables for each application inside docker-compose.yml, [postgrest](https://postgrest.org/en/v7.0.0/configuration.html) has many additional configuration options, as does [gotrue](https://github.com/supabase/gotrue#configuration). In the hosted version of Supabase we connect our own SMTP service to gotrue for sending auth mails, so you may also want to add these settings here in order to enable this.+You may also want to play with the environment variables for each application inside `docker-compose.yml`. [PostgREST](https://postgrest.org/en/v7.0.0/configuration.html) has many additional configuration options, as does [GoTrue](https://github.com/supabase/gotrue#configuration). In the hosted version of Supabase we connect our own SMTP service to GoTrue for sending auth emails, so you may also want to add these settings here in order to enable this.-Also check kong.yml inside the kong directory where you'll see how all the services are routed to, and with what rules, down the bottom you'll find the JWTs capable of accessing services that require api key access.+Also check `kong.yml` inside the `kong` directory where you'll see how all the services are routed to, and with what rules, down the bottom you'll find the JWTs capable of accessing services that require API Key access.Once you're all set, you can start the stack by running:@@ -220,8 +218,6 @@ docker-compose upHead over to the [Self Hosting Docs](https://docs-git-docs-self-hosting-supabase.vercel.app/docs/guides/self-hosting) for a more complete walk through, it also includes several [one-click deploys](https://docs-git-docs-self-hosting-supabase.vercel.app/docs/guides/self-hosting#one-click-deploys), so you can easily deploy into your own cloud hosting provider.-If you require any assistance feel free to reach out in our [github discussions](https://github.com/supabase/supabase/discussions) or at [email protected] .--## Next steps+If you require any assistance feel free to reach out in our [github discussions](https://github.com/supabase/supabase/discussions) or at [email protected].--\ No newline at end of file+Check out what else we've [launched this week](https://supabase.io/new/blog/2021/03/25/launch-week), contribute to the [CLI repo](https://github.com/supabase/cli), or go here for the [hosted version](https://app.supabase.io).\ No newline at end of filediff --git a/www/public/images/blog/cli/pgadmin-diff.png b/www/public/images/blog/cli/pgadmin-diff.pngnew file mode 100644index 00000000000..c0c57d22d07Binary files /dev/null and b/www/public/images/blog/cli/pgadmin-diff.png differ