Giter VIP home page Giter VIP logo

supabase / cli Goto Github PK

View Code? Open in Web Editor NEW
954.0 26.0 178.0 19.35 MB

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.

Home Page: https://supabase.com/docs/reference/cli/about

License: MIT License

Go 80.54% PLpgSQL 17.58% Shell 0.46% JavaScript 0.40% TypeScript 0.76% Ruby 0.18% Elixir 0.07%
cli database database-management dbms environment local postgres postgresql supabase

cli's Introduction

Supabase CLI (v1)

Coverage Status

Supabase is an open source Firebase alternative. We're building the features of Firebase using enterprise-grade open source tools.

This repository contains all the functionality for Supabase CLI.

  • Running Supabase locally
  • Managing database migrations
  • Creating and deploying Supabase Functions
  • Generating types directly from your database schema
  • Making authenticated HTTP requests to Management API

Getting started

Install the CLI

Available via NPM as dev dependency. To install:

npm i supabase --save-dev

To install the beta release channel:

npm i supabase@beta --save-dev

When installing with yarn 4, you need to disable experimental fetch with the following nodejs config.

NODE_OPTIONS=--no-experimental-fetch yarn add supabase

Note For Bun versions below v1.0.17, you must add supabase as a trusted dependency before running bun add -D supabase.

macOS

Available via Homebrew. To install:

brew install supabase/tap/supabase

To install the beta release channel:

brew install supabase/tap/supabase-beta
brew link --overwrite supabase-beta

To upgrade:

brew upgrade supabase
Windows

Available via Scoop. To install:

scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
scoop install supabase

To upgrade:

scoop update supabase
Linux

Available via Homebrew and Linux packages.

via Homebrew

To install:

brew install supabase/tap/supabase

To upgrade:

brew upgrade supabase

via Linux packages

Linux packages are provided in Releases. To install, download the .apk/.deb/.rpm/.pkg.tar.zst file depending on your package manager and run the respective commands.

sudo apk add --allow-untrusted <...>.apk
sudo dpkg -i <...>.deb
sudo rpm -i <...>.rpm
sudo pacman -U <...>.pkg.tar.zst
Other Platforms

You can also install the CLI via go modules without the help of package managers.

go install github.com/supabase/cli@latest

Add a symlink to the binary in $PATH for easier access:

ln -s "$(go env GOPATH)/cli" /usr/bin/supabase

This works on other non-standard Linux distros.

Community Maintained Packages

Available via pkgx. Package script here. To install in your working directory:

pkgx install supabase

Available via Nixpkgs. Package script here.

Run the CLI

supabase bootstrap

Or using npx:

npx supabase bootstrap

The bootstrap command will guide you through the process of setting up a Supabase project using one of the starter templates.

Docs

Command & config reference can be found here.

Breaking changes

We follow semantic versioning for changes that directly impact CLI commands, flags, and configurations.

However, due to dependencies on other service images, we cannot guarantee that schema migrations, seed.sql, and generated types will always work for the same CLI major version. If you need such guarantees, we encourage you to pin a specific version of CLI in package.json.

Developing

To run from source:

# Go >= 1.22
go run . help

cli's People

Contributors

ananya2001-an avatar awalias avatar darora avatar dependabot[bot] avatar egor-romanov avatar fenos avatar filipecabaco avatar gregnr avatar grschafer avatar hf avatar inian avatar ivasilov avatar j0 avatar joshenlim avatar kamilogorek avatar kandros avatar kangmingtay avatar kevinbrolly avatar laktek avatar loong avatar nyannyacha avatar osaxma avatar saltcod avatar soedirgo avatar sweatybridge avatar theo-m avatar thorwebdev avatar w3b6x9 avatar wakeful-cloud avatar ziinc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

Postgrest docker image doesn't work on Apple M1

Postgrest Keeps Restarting

Describe the bug

Container of Postgres keeps restarting....
I tried several times, if somethings wrong...
if im running out of ram or not...
So Thats What I did I try to Bump the Ram and Swap

Default Docker Set Up

4 CPU
Memory 2GB
Swap 1 GB

  • This Result on Postgrest Keeps Restarting

Working Docker Set UP

4 CPU
Memory 4GB
Swap 4 GB

  • then enables Experimental Features

  • Use new Virtualization Framework

  • This Resolves the ISSUE

System information

  • Laptop: Macbook Air M1 with 8GB Ram
  • OS: MacOs M1 Big Sur
  • Version of supabase-js: [0.3.9]
  • Version of Node.js: [14.16.0]

To Reproduce

Docker Default Set Up

  • 4 CPU

  • Memory 2GB

  • Swap 1 GB

  • Fresh Install Docker

  • supabase init

  • supabase start

Expected behavior

Default Docker Set Up Will Keep the Postgrest container restarting...

Screenshots

If applicable, add screenshots to help explain your problem.

Screen Shot 2021-05-16 at 3 53 04 PM

Expose pgadmin

Feature request

Is your feature request related to a problem? Please describe.

I'd love to view the running database cluster with pgadmin. As I was jumping between branches I found that I wanted to look at all the database in the cluster.

Describe the solution you'd like

We're already using pgadmin for diff'ing -

DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.3"

Does this fork include the UI? If so, can we please expose it on a new port?

Additional context

It would be awesome if it was pre-populated with the connection data so that they can login and see the cluster. Also I think pgadmin requires an admin username / password - could also be postgres/postgres

supabase remove

Feature request

A command to remove everything that supabase init installed (both local files and the docker containers). This would allow for a clean re-install.

supabase start: update text to show that it's starting containers

Chore

Describe the chore

The current setup is a bit slow when running supabase start.

I think we can imrpove it by either:

a. don't check for image updates (and add a command to pull them as/when needed)
b. add a command for skipping the check. eg supabase start --skip-images

a is preferable as it's less typing, but probably more complicated on the initial supabase start

No supabase link command documentation for Windows users

Improve documentation

Link

https://github.com/supabase/cli/tree/main/examples/tour#1-initialize-the-project

Describe the problem

The link documentation in the tour should be updated for Windows users too:

supabase link --url <<< 'postgresql://postgres:<your_password>@db.<your_project_ref>.supabase.co:5432/postgres'

I can work around it by just using a txt file with <. Or using linux etc.

Describe the improvement

I expect the CLI to take a string from Windows without the need to redirect it in from a file.

System information

  • OS: Windows 10 64 bit
  • Postgres version 13.3
  • Version of CLI: 0.10.4

Cannot deploy postgres extensions in migrations

Bug report

Describe the bug

I have a database that has the postgis and moddatetime extensions installed.

I linked to this database, then installed the extensions locally since the cli doesnt dump and restore from the linked project.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a new supabase project with moddatetime or another non default extension enabled
  2. Install the supabase CLI
  3. Create a new directory and initialize git via git init
  4. Run supabase init in the directory
  5. Run supabase link --url <<< 'postgresql://postgres:<PASSWORD>@db.<PROJECT_ID>.supabase.co:5432/postgres' or equivalent on Windows in the directory
  6. Run supabase start
  7. Add an extension to the local database CREATE EXTENSION if not exists moddatetime with SCHEMA extensions;
  8. Create a migration supabase db dump --name test
  9. Deploy supabase deploy
Error: ERROR: permission denied for language c (SQLSTATE 42501)

I believe it might be caused by this (found within the migration sql):

CREATE OR REPLACE FUNCTION extensions.moddatetime()
    RETURNS trigger
    LANGUAGE 'c'
    COST 1
    VOLATILE NOT LEAKPROOF
AS '$libdir/moddatetime', 'moddatetime'
;

Expected behavior

I expect it to deploy.

System information

  • OS: Windows 10 64 bit
  • Postgres version 13.3
  • Version of CLI: 0.10.4

Local UI does not work in Windows Subsystem For Linux (WSL2)

Bug report

Describe the bug

After running supabase init and supabase start and then going to the specified Supabase URL, instead of displaying the UI, I receive a JSON repsponse:

{
"message": "no Route matched with those values"
}

To Reproduce

With WSL2 properly setup and Docker Desktop with Use the WSL 2 based engine enabled in settings, run supabase init and supabase start in a WSL2 terminal. Finally navigate to the Supabase URL shown in the terminal after supabase init.

Expected behavior

I should see the Supabase UI

System information

  • OS: Windows 10 (with WSL2)
  • Browser chrome
  • Version of supabase-cli: 3.0.6
  • Version of Node.js: v14.15.3

supabase update

Feature request

There should be a way to update the docker images from supabase.

Maybe something like supabase stop && cd .supabase/docker && docker-compose pull && cd ../.. && supabase start? Though should likely not start if it wasn't already started.

Create type and database wrong order in migrations

Bug report

Describe the bug

When creating a migration file after creating a type and then using it in a newly created table, the type creation is placed after table creation in migration file.

To Reproduce

Create type:

create type custom_type as enum ('option1', 'option2');

Create table

create table custom_table(
  id uuid not null primary key,
  type custom_type
);

Create migration

supabase db dump --name create_custom_table

Deploy migration (optional step to observe error)

supabase deploy

Expected behavior

I suppose that in the generated migration file the type should be created before the table.

Observed behavior

In the generated migration file the table is created first, and the type after it. This causes an error during deployment:

Error: ERROR: type "custom_type" does not exist (SQLSTATE 42704)

System information

  • OS: Windows
  • Supabase CLI: 0.10.5
  • Version of Node.js: 16.13.0
  • Postgres Client where SQL was run: DataGrip

Additional context

I understand this feature is probably not complete, I hope it is okay to file a bug report anyway. The steps above are similar to what I tried locally, but the names of the type, columns and table have been changed for this report.

In addition I noticed the migration has DROP TYPE IF EXISTS public.custom_type; commented out, just above creating the type. Not sure if this is intentional.

Error: Error running SQL: ERROR: relation "public.profiles" does not exist

Bug report

Describe the bug

I am not able to run supabase start without an error

To Reproduce

Steps to reproduce the behavior:

  1. Install supabase-cli
  2. execute supabase init
  3. execute supabase start
  4. See error
titog@intel-nuc:~/supabase-local$ supabase start
โฃŸ Applying migration 20211108185629_link.sql...

BEGIN
ALTER EVENT TRIGGER
ALTER PUBLICATION
Error: Error running SQL: ERROR:  relation "public.profiles" does not exist
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block

Expected behavior

supabase should start a mirrored instance locally

System information

  • OS: Ubuntu 20.04 x86
  • Version of supabase-cli: 0.10.5

Auth actions throwing 502 Bad gateway error while developing locally

Bug report

Describe the bug

A 502 Bad gateway error gets thrown in the development console when trying to sign up or sign in a user after calling createClient in a frontend Vue application using Vitejs. Everything works fine when using the supabaseUrl and supabaseKey from the dashboard but not that of the CLI after initialising it.

To Reproduce

Follow the guide as is in the CLI docs

  1. Run npm install -g supabase
  2. Run supabase init
  3. Create the client using the createClient method from the @supabase/supabase-js package
  4. Run supabase start
  5. Run npm run dev
  6. Call the signin or signUp method

Expected behavior

That a user will be signed in or a new user record be created

Screenshots

image

System information

  • OS: Pop!_OS 20.10
  • Browser: Brave
  • Version of supabase-js: 1.7.7
  • Version of Node.js: 12.18.2

Additional context

Docker version: 20.10.5, build 55c4c88
Docker Compose version: 1.28.6, build 5db8d86f

Output when running docker ps
image

CLI Hangs sortly after starting

Bug report

Describe the bug

Whenever I try to start the CLI, it creates a bunch of processes (like thousands), and then uses up all of my available memory. There is no debug output, and it just seems to keep creating processes

To Reproduce

I'm running the command as sudo (due to docker permissions) so it looks something like this:

sudo supabase start

Expected behavior

I expected it to just start the instance locally

Screenshots

I don't have many applicable screenshots, but here is one from my terminal of what happened when I tried to killall the process (focus on the number of processes, not that they couldn't be closed - I forgot to use sudo at first). There were tons more of them too

Terminal

System information

  • OS: Linux
  • Version of supabase-cli: 0.3.8
  • Version of Node.js: 14.16.1

Additional Information

I am pretty confident that this isn't a docker issue. If I eject the project with supabase eject, then I'm able to run that normally with sudo docker-compose up. However, this isn't ideal, and I'd prefer to use the CLI for running it locally

Feature Request: Don't name containers in docker-compose.yml or assign them random names prefixed with supabase

Feature request

the problem

Naming containers in docker-compose makes it impossible to have two supabase projects side by side

While exploring supabase locally I had the problem that I needed to spin up another supabase setup to verify if I messed up my current setup. Due to the setting the container_name in docker-compose.yml it is not possible to spin up another instance without getting an error that this name is already in use.

It is nice to have a defined container name, but I don't see any benefit except for easier identification when running docker ps or docker container ls.

the solution

Maybe the cli can create a random name and prefix it with supabase-.

the alternative

The only alternative here is ejecting the project or editing the files in .supabase/ manually

start command won't recover from interrupted initialization

Bug report

Describe the bug

When supabase init is interrupted or otherwise unavailable, the supabase start command isn't able to recover and provides a misleading error message.

To Reproduce

I'm on a 2019 MBP running Big Sur...

  1. Turn off Docker globally (you may also need to clear any local Docker images used in Supabase's compose file)
  2. Run supabase init taking the defaults and you'll end up with "Error running docker-compose."
โฏ supabase init
โœ” Port for Supabase URL: ยท 8000
โœ” Port for PostgreSQL database: ยท 5432
โœ– Error running docker-compose.
  1. Start the Docker daemon again...
  2. Try running supabase init (again). No-op.
โฏ supabase init
Project already initialized. Remove .supabase to reinitialize.
  1. Run supabase start and see the same error from the init command.
โฏ supabase start
โœ– Error running docker-compose.

This was solved by rm -rf .supabase and re-running supabase init but it isn't clear the underlying cause.

Expected behavior

Ideally supabase start would detect initialization had failed and prompt me to re-initialize or supabase init should detect a badly configured .supabase/ directory.

System information

  • OS: macOS
  • Version of supabase-cli: 0.3.6
  • Version of Node.js: v15.11.0

supabase init crashes

Bug report

Describe the bug

supabase init command crashes before initialisation completes.

To Reproduce

Steps to reproduce the behaviour, please provide code snippets or a repository:

  1. type supabase init command in console
  2. Choose defaults for Supabase URL, PostgreSQL database and email testing interface
  3. Error messages appear and process crashes

Expected behaviour

Command executes and terminates exit code 0 and initialisation complete.

Screenshots

Here's the errors output to console(click to expand) โœ” Port for Supabase URL: ยท 8000 โœ” Port for PostgreSQL database: ยท 5432 โœ” Port for email testing interface: ยท 9000 โœ– Error running docker-compose: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1253, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1299, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1248, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1008, in _send_output self.send(msg) File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 948, in send self.connect() File "/usr/local/lib/python3.9/site-packages/docker/transport/unixconn.py", line 43, in connect sock.connect(self.unix_socket) FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py", line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py", line 394, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1253, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1299, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1248, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1008, in _send_output
self.send(msg)
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 948, in send
self.connect()
File "/usr/local/lib/python3.9/site-packages/docker/transport/unixconn.py", line 43, in connect
sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 214, in _retrieve_server_version
return self.version(api_version=False)["ApiVersion"]
File "/usr/local/lib/python3.9/site-packages/docker/api/daemon.py", line 181, in version
return self._result(self._get(url), json=True)
File "/usr/local/lib/python3.9/site-packages/docker/utils/decorators.py", line 46, in inner
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/compose/cli/main.py", line 81, in main
command_func()
File "/usr/local/lib/python3.9/site-packages/compose/cli/main.py", line 200, in perform_command
project = project_from_options('.', options)
File "/usr/local/lib/python3.9/site-packages/compose/cli/command.py", line 60, in project_from_options
return get_project(
File "/usr/local/lib/python3.9/site-packages/compose/cli/command.py", line 152, in get_project
client = get_client(
File "/usr/local/lib/python3.9/site-packages/compose/cli/docker_client.py", line 41, in get_client
client = docker_client(
File "/usr/local/lib/python3.9/site-packages/compose/cli/docker_client.py", line 170, in docker_client
client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 197, in init
self._version = self._retrieve_server_version()
File "/usr/local/lib/python3.9/site-packages/docker/api/client.py", line 221, in _retrieve_server_version
raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

System information

  • OS: macOS
  • Version of supabase-js: 0.4.2
  • Version of Node.js: v14.17.1
  • docker-compose version 1.29.2, build unknown
  • docker-py version: 5.0.0
  • CPython version: 3.9.5
  • OpenSSL version: OpenSSL 1.1.1k 25 Mar 2021

Additional context

Happy to help with fix (with some pointers)

supabase tail command for logs

Feature request

Is your feature request related to a problem? Please describe.

I should be able to tail my Supabase logs from the Supabase CLI.

Logs should include Kong, Postgres, Storage, Functions, Webhooks and logs re any emails sent.

Describe the solution you'd like

supabase tail should stream my logs to my console. Maybe provide an option to limit which kinds of logs e.g. supabase tail -postgres

Logs could be delivered via a websocket connection between the CLI and my Supabase instance.

supabase tail should work with self-hosted and hosted supabase instances.

Describe alternatives you've considered

None really, this is essentially feature parity for other CLI dev tools.

Additional context

How to use Supabase CLI with GitHub Actions?

Bug report

Describe the bug

As far as I know, there's no way to use the Supabase CLI in a continuous integration environment like GitHub Actions without checking the automatically generated .supabase/ directory into version control.

Running supabase init in a CI environment just results in nothing (because your CI can't answer its prompts):

Run yarn supabase init
25l25l? Port for Supabase URL: โ€ฃ 800025h25h

And then, because supabase init did nothing and thus didn't create the .supabase/ directory, running supabase start fails:

Run yarn start:sb
.FileNotFoundError: [Errno 2] No such file or directory: './.supabase/docker/docker-compose.yml'
Error: Process completed with exit code 1.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a new GitHub action.
  2. Run supabase init
  3. Run supabase start
  4. See error.

Expected behavior

There should be documentation and CLI options for running in continuous integration environments like GitHub Actions.

Screenshots

If applicable, add screenshots to help explain your problem.

image

System information

  • OS: Ubuntu 20.04 LTS on GitHub Actions
  • Version of supabase-js: 1.21.0
  • Version of Node.js: 12.22.3

Additional context

I'm trying to get the checks working for this PR: tutorbookapp/tutorbook#228

And then this is one of the failed runs: https://github.com/tutorbookapp/tutorbook/runs/3216189922?check_suite_focus=true

Supabase CLI - Provide option to restore a Postgres backup

Feature request

To encourage parity, between prod, staging and development when standing up a local Supabase dev environment, I often want

  • a copy of prod/staging db
  • w/ or without data (schema only)

To have a pre-setup database and environment w/out having to create the db and seed (in the event I do not use migrations or have something like https://github.com/amacneil/dbmate setup and in use).

Is your feature request related to a problem? Please describe.

Would like to standup a copy of prod/staging in local dev, either with or without data (ie, schema only).

Describe the solution you'd like

  • Given a manual backup downloaded from supabase
  • After supabase init and start
  • exec a cli command to restore a local .backup file given the path
  • With option to do schema only or also restore data
  • This could run something like:
psql postgres://postgres:postgres@localhost:7432/postgres < [email protected]

But know the connection string from the docker config.

Describe alternatives you've considered

  • Just run psql < manually

A clear and concise description of any alternative solutions or features you've considered.

Additional context

The ruby gem parity offers some of these tools: https://github.com/thoughtbot/parity

See:

development restore production
development restore staging

and the other db options.

It might be nice to have some settings that could define your remote Supabase db and thus offer a unified backup/download and backup/download and restore option from a single command.

Of course, with appropriate warnings about overwriting local dev db.

PostgreSQL version is different than hosted Supabase

Bug report

Describe the bug

The PostgreSQL version run locally via docker-compose in this CLI is different than the version hosted by Supabase for new projects (which I'm pretty sure is v13). This prevents me from using something like the pgAdmin Schema Diff tool to generate migration scripts for my production Supabase project based on changes I've made to my local development PostgreSQL database.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a new Supabase project.
  2. Start the local Supabase: supabase start
  3. Connect pgAdmin to both.
  4. Try to schema diff.
  5. See error saying that both servers have to be running the same version of PostgreSQL.

Expected behavior

The CLI and the hosted version of Supabase should both be running the same version of PostgreSQL.

System information

  • OS: Ubuntu 20.04 LTS (Pop_OS! 20.04 LTS)
  • Version of supabase: 0.5.0
  • Version of Node.js: 12.18.3

Additional context

I'm trying to migrate my database schema using diffs instead of migration scripts as recommended.

Supbase Stop Doesn't Stop Running Docker Containers

Bug report

Describe the bug

supabase stop does not stop running docker containers.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. supabase init
  2. supabase start
  3. supabase stop
  4. Notification of "Stopped local Supabase"
  5. supabase docker group is still running.

Expected behavior

'supabase stop' would stop all supabase related docker containers.

Screenshots

image

System information

  • OS: Windows running ubuntu and docker desktop through WSL2
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-cli: 0.3.3
  • Version of Node.js: 15.6.0

ERROR: permission denied for table users

Bug report

Currently unable to use pg_dump as getting permission denied for table users.
pg_dump: error: query failed: ERROR: permission denied for table users
The last time pg_dump successfully ran was the morning of 7/21.

Expected behavior

I believe pg_dump should be able to dump the database including the users table as it was previously.

I came across this, supabase/supabase#2495 Is this the recommended fix?

If so, is there anywhere this change would have been communicated? Thank you

Local Supabase Doesn't Auth Local Tokens

Bug report

Describe the bug

Using Supabase locally in my project works great to log in from the React Native app. However, I'm using a NestJS backend to authenticate tokens like the official NestJS authentication reference here https://github.com/doug-martin/nestjs-query. The tokens are not authenticated and my RN app always gets a 401 and never lets the request through.

My same setup works like a charm using my Supabase project credentials from https://app.supabase.io. It's just Supabase local tokens that always return a 401.

To Reproduce

In this repo (using this branch)

1a. run supabase start at the root of the repo
1b Yarn install in root of repo
1c Yarn install in server folder
2a. Update supabase keys in the supabase strategy
2b Add a new .env file with updated supabase keys like in sample.env
3a. Yarn start in the root of the project to run the expo project. Open iOS app - I haven't tested Android yet.
3b. Yarn start in server folder to start the backend
4 SignUp - go to i icon in the upper right
5 See modal

Expected behavior

Successful GQL response with local Supabase issued token.

Screenshots

Successful request - using remote Supabase creds

Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2021-10-30.at.23.28.01.mp4

Failed Request - using local Supabase creds

With this error.

{
  "graphQLErrors": [
    {
      "message": "Unauthorized",
      "extensions": {
        "code": "UNAUTHENTICATED",
        "response": {
          "statusCode": 401,
          "message": "Unauthorized"
        }
      }
    }
  ],
  "clientErrors": [],
  "networkError": null,
  "message": "Unauthorized"
}
Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2021-10-30.at.23.32.33.mp4

System information

  • OS: macOS Big Sur
  • iOS with Expo React Native
  • Version of supabase-js: "@supabase/supabase-js": "^1.24.0",
  • Version of Node.js: v14.15.0

Additional context

add aarch64 support

Feature request

Is your feature request related to a problem? Please describe.

I'd like to run supabase on a Raspberry Pi 4 with a 64bit OS. Currently some of the used images don't seem to support that architecture (see log at the bottom) resulting in exec user process caused: exec format error for:

  • supabase-mail
  • supabase-db
  • supabase-rest
  • supabase-auth

Describe the solution you'd like

Add support for aarch64.

Additional context

docker-compose up output on a RPi4 a 64bit Rasbian:
https://gist.github.com/bmedicke/4ee23a9914717c3fd92f7800cd457cff

Service 'kong' failed to build : Build failed

Bug report

Describe the bug

Failed to get credentials for Kong when supabase init is executed

carlomigueldy@DESKTOP-Q42TFOP:~/projects/saas-starter$ supabase init
โœ” Port for Supabase URL: ยท 8000
โœ” Port for PostgreSQL database: ยท 5432
โœ” Port for email testing interface: ยท 9000
โœ– Error running docker-compose: realtime uses an image, skipping
rest uses an image, skipping
storage uses an image, skipping
mail uses an image, skipping
auth uses an image, skipping
Building kong
#1 [internal] load build definition from Dockerfile
#1 sha256:a2bf235f4fa01db7fb26200e6ef362fd57ada372b4bc7e1de5c56b470cd90bd0
#1 transferring dockerfile: 253B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 sha256:aaa0ae78db691dfb8ecc2380ae3694a081ce542f81261cf88448f8c3034be22a
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/kong:2.1
#3 sha256:1bdd87e2d2dd9065233e3ef11ba879dfcb300117837b2620acfd719f1953d56c
<3>init: (2483) ERROR: UtilConnectToInteropServer:300: connect failed 2
#3 ERROR: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``
------
 > [internal] load metadata for docker.io/library/kong:2.1:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``
Service 'kong' failed to build : Build failed

To Reproduce

A fresh project then just run supabase init

Expected behavior

Should install a local emulator with all of Supabase dependencies.

Screenshots

If applicable, add screenshots to help explain your problem.

image

System information

  • OS: Windows
  • Version of supabase-js: 0.5.0
  • Version of Node.js: v14.17.1

Auth.signUp Error in Local Env with Supabase CLI

Bug report

Describe the bug

supabase.auth.signup on local setup gives 'Database error finding user'.

A clear and concise description of what the bug is.

Installed supabase cli, set up a local project, and then tried to do a simple user signup. On signup I get a status: 500 with message: Database error finding user.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. supabase init
  2. localhost:8000
  3. postgres port 5477 (only thing different from default)
  4. create index.js with the following:
import { createClient } from '@supabase/supabase-js'
const SUPABASE_URL = 'http://localhost:8000'
const SUPABASE_ANON_KEY = 'key-here'
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)

const main = async () => {
  const { user, session, error } = await supabase.auth.signUp({
    email: '[email protected]',
    password: 'superpasswordtighty',
  })
  console.log(user)       //null
  console.log(session)  //null
  console.log(error)     //{ message: 'Database error finding user', status: 500 }
}
main()

Expected behavior

A user would be created in the database. I can connect to postgres just fine, and it looks like everything is there (as far as I know). I also tried the auth.signIn method, and I get the same error (which makes sense since there's no user yet). Not sure if the signUp method is getting it's wires crossed with singIn?

Screenshots

postgres database:
image

System information

  • OS: Windows running Ubuntu and Docker Desktop through WSL2

  • Version of supabase-js: 1.7.6, cli: 0.3.3

  • Version of Node.js: 15.6.0

supabase-rest container fails to start when using docker-compose

Bug report

Describe the bug

When bringing up docker-compose for the first time, supabase-rest fails to start with error:

supabase-rest exited with code 137
Full logs
Attaching to supabase-auth, supabase-db, supabase-kong, supabase-mail, supabase-realtime, supabase-rest
supabase-db        | The files belonging to this database system will be owned by user "postgres".
supabase-db        | This user must also own the server process.
supabase-db        | 
supabase-db        | The database cluster will be initialized with locale "en_US.utf8".
supabase-db        | The default database encoding has accordingly been set to "UTF8".
supabase-db        | The default text search configuration will be set to "english".
supabase-db        | 
supabase-db        | Data page checksums are disabled.
supabase-db        | 
supabase-db        | fixing permissions on existing directory /var/lib/postgresql/data ... ok
supabase-db        | creating subdirectories ... ok
supabase-db        | selecting dynamic shared memory implementation ... posix
supabase-db        | selecting default max_connections ... 100
supabase-db        | selecting default shared_buffers ... 128MB
supabase-db        | selecting default time zone ... Etc/UTC
supabase-db        | creating configuration files ... ok
supabase-db        | running bootstrap script ... ok
supabase-db        | performing post-bootstrap initialization ... ok
supabase-db        | syncing data to disk ... ok
supabase-db        | 
supabase-db        | initdb: warning: enabling "trust" authentication for local connections
supabase-db        | You can change this by editing pg_hba.conf or using the option -A, or
supabase-db        | --auth-local and --auth-host, the next time you run initdb.
supabase-db        | 
supabase-db        | Success. You can now start the database server using:
supabase-db        | 
supabase-db        |     /usr/lib/postgresql/12/bin/pg_ctl -D /var/lib/postgresql/data -l logfile start
supabase-db        | 
supabase-mail      | Installing default greeting.html to /config
supabase-db        | waiting for server to start....2021-07-15 09:05:25.018 UTC [120] LOG:  starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
supabase-db        | 2021-07-15 09:05:25.020 UTC [120] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
supabase-mail      | {"level":"info","phase":"startup","version":"v3.0.0-rc1-2-gc64e7a6","buildDate":"2021-05-04T04:00:22+0000","time":"2021-07-15T09:05:25Z","message":"Inbucket starting"}
supabase-mail      | {"level":"info","phase":"startup","module":"storage","time":"2021-07-15T09:05:25Z","message":"Retention configured for 72h0m0s"}
supabase-mail      | {"level":"info","module":"web","phase":"startup","path":"ui","time":"2021-07-15T09:05:25Z","message":"Web UI content mapped"}
supabase-mail      | {"level":"info","module":"web","phase":"startup","addr":"0.0.0.0:9000","time":"2021-07-15T09:05:25Z","message":"HTTP listening on tcp4"}
supabase-mail      | {"level":"info","module":"smtp","phase":"startup","addr":"0.0.0.0:2500","time":"2021-07-15T09:05:25Z","message":"SMTP listening on tcp4"}
supabase-mail      | {"level":"info","module":"pop3","phase":"startup","addr":"0.0.0.0:1100","time":"2021-07-15T09:05:25Z","message":"POP3 listening on tcp4"}
supabase-db        | 2021-07-15 09:05:25.090 UTC [124] LOG:  database system was shut down at 2021-07-15 09:05:24 UTC
supabase-db        | 2021-07-15 09:05:25.106 UTC [120] LOG:  database system is ready to accept connections
supabase-db        |  done
supabase-db        | server started
supabase-db        | 
supabase-db        | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/00-initial-schema.sql
supabase-db        | CREATE PUBLICATION
supabase-db        | CREATE SCHEMA
supabase-db        | CREATE EXTENSION
supabase-db        | CREATE EXTENSION
supabase-db        | CREATE EXTENSION
supabase-db        | CREATE ROLE
supabase-db        | CREATE ROLE
supabase-db        | CREATE ROLE
supabase-db        | CREATE ROLE
supabase-db        | GRANT ROLE
supabase-db        | GRANT ROLE
supabase-db        | GRANT ROLE
supabase-db        | GRANT
supabase-db        | ALTER DEFAULT PRIVILEGES
supabase-db        | ALTER DEFAULT PRIVILEGES
supabase-db        | ALTER DEFAULT PRIVILEGES
supabase-db        | 
supabase-db        | 
supabase-db        | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/auth-schema.sql
supabase-db        | CREATE SCHEMA
supabase-db        | CREATE TABLE
supabase-db        | CREATE INDEX
supabase-db        | CREATE INDEX
supabase-db        | CREATE TABLE
supabase-db        | CREATE INDEX
supabase-db        | CREATE INDEX
supabase-db        | CREATE INDEX
supabase-db        | CREATE TABLE
supabase-db        | CREATE TABLE
supabase-db        | CREATE INDEX
supabase-db        | CREATE TABLE
supabase-db        | INSERT 0 7
supabase-db        | CREATE FUNCTION
supabase-db        | CREATE FUNCTION
supabase-db        | CREATE FUNCTION
supabase-db        | GRANT
supabase-db        | GRANT
supabase-db        | GRANT
supabase-db        | ALTER ROLE
supabase-db        | 
supabase-db        | 
supabase-db        | /usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/init-permissions.sh
supabase-db        | 
supabase-db        | 2021-07-15 09:05:26.150 UTC [120] LOG:  received fast shutdown request
supabase-db        | 2021-07-15 09:05:26.152 UTC [120] LOG:  aborting any active transactions
supabase-db        | waiting for server to shut down....2021-07-15 09:05:26.165 UTC [120] LOG:  background worker "logical replication launcher" (PID 134) exited with exit code 1
supabase-db        | 2021-07-15 09:05:26.166 UTC [126] LOG:  shutting down
supabase-db        | 2021-07-15 09:05:26.207 UTC [120] LOG:  database system is shut down
supabase-db        |  done
supabase-db        | server stopped
supabase-db        | 
supabase-db        | PostgreSQL init process complete; ready for start up.
supabase-db        | 
supabase-db        | 2021-07-15 09:05:26.331 UTC [1] LOG:  pgaudit extension initialized
supabase-db        | 2021-07-15 09:05:26.332 UTC [1] LOG:  starting PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
supabase-db        | 2021-07-15 09:05:26.334 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
supabase-db        | 2021-07-15 09:05:26.334 UTC [1] LOG:  listening on IPv6 address "::", port 5432
supabase-db        | 2021-07-15 09:05:26.336 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
supabase-db        | 2021-07-15 09:05:26.390 UTC [1] LOG:  redirecting log output to logging collector process
supabase-db        | 2021-07-15 09:05:26.390 UTC [1] HINT:  Future log output will appear in directory "log".
supabase-kong      | 2021/07/15 09:05:28 [warn] 1#0: load balancing method redefined in /usr/local/kong/nginx-kong.conf:59
supabase-kong      | nginx: [warn] load balancing method redefined in /usr/local/kong/nginx-kong.conf:59
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: using the "epoll" event method
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: openresty/1.15.8.3
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: built by gcc 9.3.0 (Alpine 9.3.0) 
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: OS: Linux 5.10.25-linuxkit
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: getrlimit(RLIMIT_NOFILE): 1048576:1048576
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: start worker processes
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: start worker process 22
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: start worker process 23
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: start worker process 24
supabase-kong      | 2021/07/15 09:05:28 [notice] 1#0: start worker process 25
supabase-kong      | 2021/07/15 09:05:28 [notice] 25#0: *2 [lua] cache.lua:374: purge(): [DB cache] purging (local) cache, context: init_worker_by_lua*
supabase-kong      | 2021/07/15 09:05:28 [notice] 25#0: *2 [lua] cache.lua:374: purge(): [DB cache] purging (local) cache, context: init_worker_by_lua*
supabase-kong      | 2021/07/15 09:05:28 [notice] 25#0: *2 [kong] init.lua:329 declarative config loaded from /var/lib/kong/kong.yml, context: init_worker_by_lua*
supabase-auth      | time="2021-07-15T09:05:34.723207511Z" level=debug msg="Set log level to: debug"
supabase-auth      | time="2021-07-15T09:05:34Z" level=info msg="GoTrue API started on: auth:9999"
supabase-realtime  | 2021-07-15 09:05:38.174 [info] Running RealtimeWeb.Endpoint with cowboy 2.8.0 at :::4000 (http)
supabase-realtime  | 2021-07-15 09:05:38.175 [info] Access RealtimeWeb.Endpoint at http://localhost:4000
supabase-rest exited with code 137
supabase-rest exited with code 137
supabase-rest exited with code 137
supabase-realtime  | 2021-07-15 09:05:41.861 [info] tzdata release in place is from a file last modified Wed, 21 Oct 2020 18:40:20 GMT. Release file on server was last modified Sun, 24 Jan 2021 19:35:23 GMT.
supabase-realtime  | 2021-07-15 09:05:42.670 [info] Tzdata has updated the release from 2020d to 2021a
supabase-rest exited with code 137
supabase-rest exited with code 137
supabase-rest exited with code 137
supabase-rest exited with code 137
supabase-rest exited with code 137

To Reproduce

Steps to reproduce the behaviour:

$ npm install -g [email protected]
$ supabase eject
$ cd docker
$ docker compose up

Expected behavior

For all the containers to run successfully.

Screenshots

N/A

System information

  • OS: macOS 11.2.3 (Apple Silicon)
  • Browser (if applies): N/A
  • Version of supabase-js: N/A
  • Version of Node.js: v15.13.0

Additional context

N/A

Add more detailed error output

Feature request

Is your feature request related to a problem? Please describe.

When starting Supabase with the default config the error output is very generic when docker-compose fails for example because of a service already using a specified port.

$ supabase start
โœ– Error running docker-compose.

Describe the solution you'd like

The error output of supabase start should output more info about why docker-compose failed.

Describe alternatives you've considered

Alternatively or additionally the full error could be logged to a file.

service role key provided by cli is not working as expected

Bug report

The service role key provided by the cli seems not to be the right one. When I try to run this command in the shell:

curl -X POST 'http://localhost:8888/auth/v1/signup' \
-H "apikey: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoic2VydmljZV9yb2xlIn0.necIJaiP7X2T2QjGeV-FhpkizcNTX8HjDDBAxpgQTEI" \
-H "Content-Type: application/json" \
-d '{
  "email": "[email protected]",
  "password": "123456"
}'

I get this response

{
  "message":"Invalid authentication credentials"
}

The JWT_SECRET (super-secret-jwt-token-with-at-least-32-characters-long) is indeed the one that was used to sign this key, but something seems to be missing?

To Reproduce

clone the repo https://github.com/ff6347/supabase-cli-gives-non-functional-service-role-key
run npx supabase start
run node index.mjs or the command above

Expected behavior

A clear and concise description of what you expected to happen.

I expect the key to work.

System information

  • OS: macOS 11.2.3
  • Version of supabase-js:
  "dependencies": {
    "@supabase/supabase-js": "1.11.7",
    "supabase": "0.3.8"
  }
  • Version of Node.js: 14.16.0

[RFC 0001] MVP

Abstract

We would like to create a basic CLI for Supabase. At this stage we can assume that the user won't need to create orgs/projects from the CLI, but they will need to:

  • develop locally
  • push database migrations to their Postgres database

Rendered

Auth Actions Taking 10+ seconds on windows

Bug report

Describe the bug

Sorry, one more issue :)
Not sure if this is local/dev/cli related, or tangentially related to this issue: supabase/supabase#937
but now that I can log in, the initial login takes 10 to 20 seconds. If I run the login immediately after, it usually goes down to around 15 milliseconds, but then will intermittently go back to 10 to 20 seconds to log in.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. create user
  2. log in with user

Expected behavior

Logins should be consistently under 1 second.

Screenshots

You can see the times bounce around, between 20 seconds and 15 milliseconds for the initial login, but then calling the session is always fast (I'm assuming because supabase is already initialized?)
image

System information

  • OS: Windows 10 running ubuntu and docker desktop with WSL2
  • Version of supabase-js: 1.7.7, CLI: 0.3.4
  • Version of Node.js: 15.4.0

Additional context

Here's the node script I'm testing with:

import { createClient } from '@supabase/supabase-js'
const SUPABASE_URL = 'http://localhost:8000'
const SUPABASE_ANON_KEY = '---the-key---'
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
import { performance } from "perf_hooks"

const main = async () => {
  var t0 = performance.now()
  const { user, session, error } = await supabase.auth.signIn({
    email: '[email protected]',
    password: 'superpasswordtighty',
  })
  var t1 = performance.now()
  console.log("Login took " + (t1 - t0) + " milliseconds. (" + ((t1 - t0) / 1000) + "secconds)")

  var t0 = performance.now()
  const session2 = supabase.auth.session()
  var t1 = performance.now()
  console.log("Session took " + (t1 - t0) + " milliseconds. (" + ((t1 - t0) / 1000) + "secconds)")
}
main()

Auth is using postgres user, which looks at public.users before auth.users

need to re-order the schema-path for postgres user, or make a new auth user instead

Discussed in supabase/supabase#3440

Originally posted by sebtoombs October 7, 2021
Hey!

Description

I'm trying to use supabase locally for dev, and finding that having a public.users table causes issues. Namely, the queries for auth related actions (sign in etc) run e.g. "select xyz from users", and the schema path seems to be "$user", public, auth. This means auth actions find the public.users table instead and throw the following error: "Database error finding user".

This doesn't seem to be an issue in supabase hosted (worth noting the public.users table I'm using is identical to the "Stripe subscriptions" starter sample).

I suspect there's something going on with roles/users etc here that differs between the two environments.

I really hope I'm just making a silly mistake!

Steps to reproduce

Start local supabase env

Init a local supabase enviroment (assumes docker & supabase CLI are installed)

supabase init
supabase start

Create public.users table

I'm using the "supabase" user to run this. Is that appropriate?

psql -h localhost -p 5432 -U postgres -W
create table public.users (
  id uuid references auth.users not null primary key,
  full_name text,
  billing_address jsonb,
  payment_method jsonb
);

Attempt sign in

Via app, attempt sign in (supabase.auth.signIn)

Response:

{"code":500,"msg":"Database error finding user","error_id":"xxxxxxxxx"}

Seed with a Script

Feature request

Is your feature request related to a problem? Please describe.

We currently have seeding scripts written in TypeScript.

They served two purposes:

  1. Reproducibility of the project: if we had to deploy somewhere else, we would still have the essential data needed for the app to work.
  2. Easily provision a local development environment.

There is currently no way to run such seeding scripts after running supabase start since the CLI is blocking, which means we can't simply add a dev:start script to run supabase start && yarn db:seed.

Describe the solution you'd like

  • We would like supabase start to accept a flag to run a custom seeding command.
  • We would like to have the possibility to edit the Supabase config to run a seeding script

Describe alternatives you've considered

We considered converting our seeding scripts to SQL, but I believe this is a feature that could benefit Supabase too.

Additional context

The data we want to seed is pretty static.
We wrote our seeding scripts in TypeScript.
We could also solve our problem with #30.

Create a new migration file

it would be useful to have a command to generate a migration file which the user can then edit manually

At the moment the flow is:

  • start database
  • edit database
  • dump to migration

But another valid flow is

  • create migration
  • edit migration
  • start database

Realtime websocket fails to connect when running locally

Bug report

Describe the bug

I use a realtime WS connection to subscribe to various updates, which works great in production. However, this seems to fail to connect when using supabase locally, with the following errors:

Server:

supabase-kong      | 2021/04/17 21:28:06 [error] 22#0: *10872 connect() failed (111: Connection refused) while connecting to upstream, client: 172.23.0.1, server: kong, request: "GET /realtime/v1/websocket?apikey=REDACTED&vsn=1.0.0 HTTP/1.1", upstream: "http://172.23.0.4:4000/socket/websocket?vsn=1.0.0", host: "localhost:8000"

Client:

browser.js?7e3c:21 
WebSocket connection to 'ws://localhost:8000/realtime/v1/websocket?apikey=REDACTED&vsn=1.0.0' failed: 

To Reproduce

Just subscribing to events according to the docs, as mentioned it works perfectly in prod. The relevant file is here, and a screenshot below; I'll try to make a recreation in the meantime you might be able to confirm this as an easy case of user error ๐Ÿ˜…

supabase-kong      | 2021/04/17 21:28:06 [error] 22#0: *10872 connect() failed (111: Connection refused) while connecting to upstream, client: 172.23.0.1, server: kong, request: "GET /realtime/v1/websocket?apikey=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTYwMzk2ODgzNCwiZXhwIjoyNTUwNjUzNjM0LCJyb2xlIjoiYW5vbiJ9.36fUebxgx1mcBo4s19v0SzqmzunP--hm_hep0uLX0ew&vsn=1.0.0 HTTP/1.1", upstream: "http://172.23.0.4:4000/socket/websocket?vsn=1.0.0", host: "localhost:8000"

Expected behavior

The websocket connection should proceed and receive incoming messages from the server.

Screenshots

image

System information

  • OS: Mac OS (M1, Big Sur 11.0.1)

  • Browser (if applies) Chrome

  • Version of supabase-js:

    "@supabase/supabase-js": "^1.7.1"
    "supabase": "^0.3.8"
    
  • Version of Node.js: 15.8.0

Should be able to start from anywhere

since we do a global install of the CLI you should be able to supabase start from any directory

I noticed that if you're in a dir where you didn't init you will get :

supabase@MacBook-Pro-4 supabase % supabase start
โ ง Starting local emulator.../usr/local/lib/node_modules/supabase/node_modules/gluegun/build/index.js:13
    throw up;
    ^

Error: Command failed: docker-compose -f .supabase/emulator/docker-compose.yml up -d
.FileNotFoundError: [Errno 2] No such file or directory: './.supabase/emulator/docker-compose.yml'

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Socket.<anonymous> (internal/child_process.js:444:11)
    at Socket.emit (events.js:314:20)
    at Pipe.<anonymous> (net.js:675:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'docker-compose -f .supabase/emulator/docker-compose.yml up -d',
  stdout: '',
  stderr: ".FileNotFoundError: [Errno 2] No such file or directory: './.supabase/emulator/docker-compose.yml'\n"
}

instead of .supabase we should probably install the folder in the users root ~/.supabase

Feature Request: Make eject actually eject the docker-compose.yml located in .supabase instead of regenerating it

Feature request

From the work with other cli's that use the term eject as a command I expect that I get the current configuration written to my working directory and it only should work after I ran an init command.

The Problem

Currently the eject behaves more like a generate command that has no relation to the setup created with init.

This blocks to issue #28, since generating prefixed container names would only make sense if the names persist when ejecting the project.

The Solution

For me the expected flow would be:

  1. setup new project with init
  2. move the content of .supabase/** to the working directory with eject without running function generate again

I guess it is okay from the UX that there is no direct way to to generate the files directly in the working directory since I guess the cli will be used to do other things like migration etc in the future.

'supabase init' stalls macOS Big Sur 11.6

Bug report

Describe the bug

'supabase init' stalls. Stalls as in once executed, nothing happens. Have left for an hour or so with no change.

To Reproduce

  1. 'brew install supabase/tap/supabase'
  2. mkdir dirname
  3. cd dirname
  4. Start docker
  5. 'supabase init'
  6. See nothing

Expected behavior

'supabase init' to run.

Screenshots

Screen Shot 2021-10-17 at 2 10 56 PM

System information

  • OS: macOS Big Sur 11.6
  • Version of supabase-js: 'supabase -v' = 0.10.2
  • Version of Node.js: 'node -v'= v16.11.1

Additional context

'supabase -h' works as intended making me think that supabase is correctly installed... it's possible that I have missed some critical step in: https://supabase.io/docs/guides/local-development however, have repeated after restart etc. with no luck. The command is being executed as the terminal header changes to show it and a little loading wheel appears in thee terminal tab header for about 5 seconds then disappears.

Would appreciate any help or insight you could provide.

Hide the database folder (for now)

Chore

Describe the chore

The database folder/diff will be useful once it's fully documented, but for now it's a bit confusing if it does anything. Let's hide it until we have the migrations flow working

Add volumes

Chore

Since some people will be trying to deploy this to production, we should probably add a volume to the postgres image (even if it's just commented out

volumes:
      - <location>/postgres:/var/lib/postgresql/data

Additional context

We could ask if they want to store the data?

supabase-auth can't connect to db, seems to ignore port setting

Thanks for your work! I've had some trouble getting supabase set up locally for development. When specifying different port options in supabase init, the supabase-auth docker container exits on start with the following message:

04T06:02:46Z" level=fatal msg="failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 172.18.0.3:5432: connect: connection refused)\ncould not create new transaction\ngithub.com/gobuffalo/pop/v5.newTX\n\t/go/pkg/mod/github.com/gobuffalo/pop/[email protected]/tx.go:29\ngithub.com/gobuffalo/pop/v5.

I specified 5434 for the db rather than 5432 (as I already have a different postgres running on localhost), so it looks like it's ignoring that and trying to use the default. If I stop my other postgres and use the default ports instead, it all works fine.

Supabase CLI - Docker Auth Config: Add OAuth Settings

Feature request

Easily configure Supabase with OAuth config environment settings to enable GitHub and other third-party auth in local development.

Is your feature request related to a problem? Please describe.

While the docker-compose.yml included

        GOTRUE_JWT_SECRET: super-secret-jwt-token-with-at-least-32-characters-long
        GOTRUE_JWT_EXP: 3600
        GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated

Did not immediately know what the envars would be needed to configure GitHub or other OAuth providers.

Describe the solution you'd like

For each: azure, bitbucket, github, gitlab, facebook, and google

GOTRUE_EXTERNAL_GITHUB_ENABLED=true
GOTRUE_EXTERNAL_GITHUB_CLIENT_ID=myappclientid
GOTRUE_EXTERNAL_GITHUB_SECRET=clientsecretvaluessssh

also may need redirect and urls:

EXTERNAL_X_ENABLED - bool

Whether this external provider is enabled or not

EXTERNAL_X_CLIENT_ID - string required

The OAuth2 Client ID registered with the external provider.

EXTERNAL_X_SECRET - string required

The OAuth2 Client Secret provided by the external provider when you registered.

EXTERNAL_X_REDIRECT_URI - string required

The URI a OAuth2 provider will redirect to with the code and state values.

EXTERNAL_X_URL - string

But for all providers, but perhaps commented out or all disables and envars empty.

  • Include a cli option on init to declare a provider/list of providers to setup (but then how to you set up additional after one was setup?)

Additional context

https://github.com/supabase/supabase/blob/766d3c0c9107fb553210dcc02880e2d6a9291fc3/docker/docker-compose.yml#L27

Seems like best option might be to include all by default, just not enabled in the docker-compose so can configure easily when/if needed in future.

Error: unexpected end of JSON input

Bug report

Describe the bug

I am trying to create a new supabase instance using CLI on a ubuntu 20.04 (arm) and I am receiving:

Error: unexpected end of JSON input

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. install supabase cli 0.10.5
  2. Create an empty directory supabase-local
ubuntu@ubuntu:~/supabase-local$ git init
Initialized empty Git repository in /home/ubuntu/supabase-local/.git/
ubuntu@ubuntu:~/supabase-local$ supabase init
Error: unexpected end of JSON input

Expected behavior

I guess it should create a supabase directory.

System information

  • OS: Linux Ubuntu 20.04 - arm
  • Version of supabase-cli 0.10.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.