Closed djbutler closed 7 months ago
This is related to #480 .
Resetting the local database requires recreating the database container because some extensions like pg_cron
need to be restarted that way. If you are only interested in running migrations, perhaps you can try supabase migration up --db-url
?
This should be fixed in beta release, ie. npx supabase@beta db reset --db-url postgresql://postgres:proxy_password@localhost:65432/postgres
@sweatybridge Thanks for getting to this so quickly. Now the CLI correctly recognizes the --db-url as a remote Supabase instance, but the migrations themselves are failing. This is what I get:
➜ desktop-sync git:(main) npx supabase@beta db reset --db-url postgresql://postgres:proxy_password@localhost:65432/postgres
Need to install the following packages:
supabase@1.145.2
Ok to proceed? (y) y
Confirm resetting the remote database? [Y/n] Y
Resetting remote database...
Applying migration 20240210010157_create_phenotypers_table.sql...
unexpected EOF
At statement 0: CREATE TABLE IF NOT EXISTS phenotypers (
id UUID PRIMARY KEY NOT NULL,
name TEXT,
email TEXT
)
Try rerunning the command with --debug to troubleshoot the error.
➜ desktop-sync git:(main) npx supabase@beta db reset --db-url postgresql://postgres:proxy_password@localhost:65432/postgres
Confirm resetting the remote database? [Y/n] Y
Resetting remote database...
failed to list schemas: unexpected EOF
Try rerunning the command with --debug to troubleshoot the error.```
Should I open a new issue?
Should I open a new issue?
Yup, please also share the output with --debug
flag to help diagnose.
Describe the bug
The rest of the --db-url connection string is ignored if the host is localhost. In particular, the port and database name are ignored. This is a problem if you need to direct the CLI to a Postgres connection string that is local but not the default connection string. This is the case for services like Electric SQL (https://electric-sql.com/docs/quickstart), which runs a local Postgres proxy with a different connection string.
To Reproduce Steps to reproduce the behavior:
npx create-electric-app@latest my-app
cd my-app && npx electric-sql start --with-postgres
cd my-app && supabase init
supabase migration new my_new_migration
.supabase db reset --db-url postgresql://postgres:proxy_password@localhost:65432/postgres
supabase db reset --db-url postgresql://postgres:proxy_password@localhost:65432/foobar
Expected behavior Step 5 should connect to the --db-url string, but it connects to the default local database. Step 6 should fail entirely, but it doesn't fail. This shows that the connection string is being ignored.
Screenshots N/A
System information Rerun the failing command with
--create-ticket
flag (preferred).Versions of services:
─────────────────────────┼──────────────────────┼───────── supabase/postgres │ 15.1.0.147 │ - supabase/gotrue │ v2.132.3 │ - postgrest/postgrest │ v12.0.1 │ - supabase/realtime │ v2.25.50 │ - supabase/storage-api │ v0.43.11 │ - supabase/edge-runtime │ v1.32.0 │ - supabase/studio │ 20240101-8e4a094 │ - supabase/postgres-meta │ v0.75.0 │ - supabase/logflare │ 1.4.0 │ - bitnami/pgbouncer │ 1.20.1-debian-11-r39 │ - darthsim/imgproxy │ v3.8.0 │ -