supabase / supabase

The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
https://supabase.com
Apache License 2.0
71.91k stars 6.89k forks source link

Error: Migration failed. Reason: An error occurred running 'pathtoken-column'. #7736

Closed koetjeengdjalanan closed 1 year ago

koetjeengdjalanan commented 2 years ago

I am trying to deploy supabase on my private server but supabase-storage image is failed to build. This cause other three image to failed alongside in my side.

This is the result of docker image logs for:


- supabase-auth

time="2022-07-12T14:34:19Z" level=fatal msg="running db migrations: Migrator: problem creating schema migrations: couldn't start a new transaction: could not create new transaction: failed to connect to host=db user=postgres database=postgres: dial error (dial tcp 172.22.0.2:5432: connect: connection refused)" [POP] 2022/07/12 14:34:19 info - 0.0294 seconds [POP] 2022/07/12 14:34:20 info - 0.0442 seconds time="2022-07-12T14:34:20Z" level=fatal msg="running db migrations: Migrator: problem creating schema migrations: CREATE TABLE \"schema_migrations\" (\n\"version\" VARCHAR (14) NOT NULL\n);\nCREATE UNIQUE INDEX \"schema_migrations_version_idx\" ON \"schema_migrations\" (version);: ERROR: no schema has been selected to create in (SQLSTATE 3F000)"


- supabase-realtime

2022-07-12 14:34:21.858 [error] Could not create schema migrations table. This error usually happens due to the following:

To fix the first issue, run "mix ecto.create".

To address the second, you can run "mix ecto.drop" followed by "mix ecto.create". Alternatively you may configure Ecto to use another table and/or repository for managing migrations:

config :realtime, Realtime.RLS.Repo,
  migration_source: "some_other_table_for_schema_migrations",
  migration_repo: AnotherRepoForSchemaMigrations

The full error report is shown below.

** (Postgrex.Error) ERROR 3F000 (invalid_schema_name) schema "realtime" does not exist (ecto_sql 3.7.1) lib/ecto/adapters/sql.ex:760: Ecto.Adapters.SQL.raise_sql_call_error/1 (elixir 1.11.4) lib/enum.ex:1411: Enum."-map/2-lists^map/1-0-"/2 (ecto_sql 3.7.1) lib/ecto/adapters/sql.ex:852: Ecto.Adapters.SQL.execute_ddl/4 (ecto_sql 3.7.1) lib/ecto/migrator.ex:678: Ecto.Migrator.verbose_schema_migration/3 (ecto_sql 3.7.1) lib/ecto/migrator.ex:504: Ecto.Migrator.lock_for_migrations/4 (ecto_sql 3.7.1) lib/ecto/migrator.ex:419: Ecto.Migrator.run/4 (ecto_sql 3.7.1) lib/ecto/migrator.ex:146: Ecto.Migrator.with_repo/3


- supabase-kong

2022/07/12 14:34:18 [warn] 1#0: load balancing method redefined in /usr/local/kong/nginx-kong.conf:59 nginx: [warn] load balancing method redefined in /usr/local/kong/nginx-kong.conf:59 2022/07/12 14:34:18 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:490: error parsing declarative config file /var/lib/kong/kong.yml: /var/lib/kong/kong.yml: No such file or directory stack traceback: [C]: in function 'error' /usr/local/share/lua/5.1/kong/init.lua:490: in function 'init' init_by_lua:3: in main chunk



And here I think i already do all from wiki as it's written. Can someone help me? .env file is as closely as the example.
kiwicopple commented 2 years ago

Hey @koetjeengdjalanan - I'm not able to replicate this one. could you share a few steps on how we can reproduce this error?

Antony-Jia commented 2 years ago

Hey @koetjeengdjalanan - I'm not able to replicate this one. could you share a few steps on how we can reproduce this error?

I met same questions. By docker-compose.yml like this. ` version: "3.8"

services: ... db: image: timescale/timescaledb-ha:pg14-latest restart: always ports:

Antony-Jia commented 2 years ago

My postgresql contianer is lack of someting. I just do like this: 1.modify localhost VM address 2.modify POSTGRES_HOST TimescaleDB(my postgresql) address 3.add extension pgjwt 4.modify wal_level 5.sudo apt-get install postgresql-14-wal2json in my postgresql

Excute init sql again and sovle the problem.

but it show it very often. I don't know is right.

supabase-db | 2022-07-30 13:56:13.679 UTC [40] LOG: logical decoding found consistent point at 0/1B64470 supabase-db | 2022-07-30 13:56:13.679 UTC [40] DETAIL: There are no running transactions. supabase-db | 2022-07-30 13:56:13.679 UTC [40] STATEMENT: with pub as ( supabase-db | select supabase-db | concat_ws( supabase-db | ',', supabase-db | case when bool_or(pubinsert) then 'insert' else null end, supabase-db | case when bool_or(pubupdate) then 'update' else null end, supabase-db | case when bool_or(pubdelete) then 'delete' else null end supabase-db | ) as w2j_actions, supabase-db | coalesce( supabase-db | string_agg( supabase-db | realtime.quote_wal2json(format('%I.%I', schemaname, tablename)::regclass), supabase-db | ',' supabase-db | ) filter (where ppt.tablename is not null), supabase-db | '' supabase-db | ) w2j_add_tables supabase-db | from supabase-db | pg_publication pp supabase-db | left join pg_publication_tables ppt supabase-db | on pp.pubname = ppt.pubname supabase-db | where supabase-db | pp.pubname = $1 supabase-db | group by supabase-db | pp.pubname supabase-db | limit 1 supabase-db | ), supabase-db | w2j as ( supabase-db | select supabase-db | x.*, pub.w2j_add_tables supabase-db | from supabase-db | pub, supabase-db | pg_logical_slot_get_changes( supabase-db | $2, null, $3, supabase-db | 'include-pk', '1', supabase-db | 'include-transaction', 'false', supabase-db | 'include-timestamp', 'true', supabase-db | 'write-in-chunks', 'true', supabase-db | 'format-version', '2', supabase-db | 'actions', pub.w2j_actions, supabase-db | 'add-tables', pub.w2j_add_tables supabase-db | ) x supabase-db | ) supabase-db | select supabase-db | xyz.wal, supabase-db | xyz.is_rls_enabled, supabase-db | xyz.subscription_ids, supabase-db | xyz.errors supabase-db | from supabase-db | w2j, supabase-db | realtime.apply_rls( supabase-db | wal := w2j.data::jsonb, supabase-db | max_record_bytes := $4 supabase-db | ) xyz(wal, is_rls_enabled, subscription_ids, errors) supabase-db | where supabase-db | w2j.w2j_add_tables <> '' supabase-db | and xyz.subscription_ids[1] is not null

@kiwicopple

Antony-Jia commented 2 years ago

I find https://github.com/supabase/realtime/issues/231 and it's OK

yusuf-khamis commented 1 year ago

Am currently encountering this, pretty frustrating to know you've done everything right, followed the wiki to the latter and still having some errors poping up, did you manage to figure this one out?

kiwicopple commented 1 year ago

It looks like @Antony-Jia disabled logging like this:

https://stackoverflow.com/questions/66215102/disable-logging-of-logical-replication-statements-in-postgres-13-1

Let us know if that helps

itisnajim commented 1 year ago

@Antony-Jia what you did exactly, can u share the steps please ?

Antony-Jia commented 1 year ago

@Antony-Jia what you did exactly, can u share the steps please ?

Whe you use self-host postgresql ( like timescaledb ) with supabase, if you met some error like lack of pgjwt, you can install it in you self-host envirment and restart docker-compose. if you just hate the lots of logs, you can set log_min_messages = fatal in postgresql.conf. It's better to disable realtime function and log will not show. You can see more detail #231 (Bug: postgresql.conf is full of queries)

itisnajim commented 1 year ago

No realtime = No(t a) Firebase alternative, i'll try limits the logs as describing in your post.

sweatybridge commented 1 year ago

I will close this issue as fixed. If you are using custom postgres images like timescale/timescaledb-ha:pg14-latest, remember to run migrations to setup initial schemas. These are open sourced in our postgres repo.

The realtime logs are now suppressed by default https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml#L197.

BonsoirDiep commented 4 months ago

in my case: check log docker error (is restarting), find .sql error, and force fix

docker ps -a
docker compose logs auth -n 10 
sudo find /var/lib/docker -name *backfill_email_last_sign_in*.sql
sudo nano /var/lib/docker/overlay2/<___>/diff/usr/local/etc/auth/migrations/<__>_backfill_email_last_sign_in_at.up.sql

change

-- previous backfill migration left last_sign_in_at to be null, which broke some projects

update {{ index .Options "Namespace" }}.identities
  set last_sign_in_at = '2022-11-25'
  where
    last_sign_in_at is null and
    created_at = '2022-11-25' and
    updated_at = '2022-11-25' and
    provider = 'email' and
    id= user_id::text;

to:

-- previous backfill migration left last_sign_in_at to be null, which broke some projects

update {{ index .Options "Namespace" }}.identities
  set last_sign_in_at = '2022-11-25'
  where
    last_sign_in_at is null and
    created_at = '2022-11-25' and
    updated_at = '2022-11-25' and
    provider = 'email' and
    id::text = user_id::text;