Open P5J3MS opened 9 months ago
Hey @P5J3MS, could you please provide some additional context regarding the specific commands you're attempting to execute?
It seems like the issue lies with AppFlowy Cloud attempting to connect to a database at port 5432, where the expected database tables does not exist. The solution might involve disabling the database service currently running on port 5432, which lacks the expected tables. You can achieve this using PgAdmin
.
@P5J3MS I think you should take a look at the gotrue service to see if it's migration is done successfully. appflowy-cloud
depends on it
I am experiencing the same issue. I am running Docker Compose from a container appflowyinc/appflowy_cloud:0.1.46
with image id 1b6e26e66ca0
. The Cloud container refuses to start, and seems to cause the error while executing database migrations.
appflowy | Error:
appflowy | Failed to initialize application state: Failed to run migrations: while executing migrations: error returned from database: relation "auth.users" does not exist
appflowy |
appflowy |
appflowy | Stack backtrace:
appflowy | 0: anyhow::error::<impl anyhow::Error>::msg
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.79/src/error.rs:83:36
appflowy | 1: appflowy_cloud::main::{{closure}}::{{closure}}
appflowy | at ./src/main.rs:55:18
appflowy | 2: core::result::Result<T,E>::map_err
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:829:27
appflowy | 3: appflowy_cloud::main::{{closure}}
appflowy | at ./src/main.rs:53:15
appflowy | 4: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:978:42
appflowy | 5: tokio::task::local::LocalSet::with::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:730:13
appflowy | 6: std::thread::local::LocalKey<T>::try_with
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
appflowy | 7: std::thread::local::LocalKey<T>::with
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
appflowy | 8: tokio::task::local::LocalSet::with
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:728:17
appflowy | 9: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:968:9
appflowy | 10: tokio::task::local::LocalSet::run_until::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:635:19
appflowy | 11: <core::pin::Pin<P> as core::future::future::Future>::poll
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
appflowy | 12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:57
appflowy | 13: tokio::runtime::coop::with_budget
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:107:5
appflowy | 14: tokio::runtime::coop::budget
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:73:5
appflowy | 15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:25
appflowy | 16: tokio::runtime::scheduler::current_thread::Context::enter
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:410:19
appflowy | 17: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:664:36
appflowy | 18: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:68
appflowy | 19: tokio::runtime::context::scoped::Scoped<T>::set
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/scoped.rs:40:9
appflowy | 20: tokio::runtime::context::set_scheduler::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:26
appflowy | 21: std::thread::local::LocalKey<T>::try_with
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
appflowy | 22: std::thread::local::LocalKey<T>::with
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
appflowy | 23: tokio::runtime::context::set_scheduler
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1
appflowy | .35.1/src/runtime/context.rs:176:17
appflowy | 24: tokio::runtime::scheduler::current_thread::CoreGuard::enter
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:27
appflowy | 25: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:652:19
appflowy | 26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:175:28
appflowy | 27: tokio::runtime::context::runtime::enter_runtime
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/runtime.rs:65:16
appflowy | 28: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:167:9
appflowy | 29: tokio::runtime::runtime::Runtime::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/runtime.rs:348:47
appflowy | 30: tokio::task::local::LocalSet::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:592:9
appflowy | 31: actix_rt::runtime::Runtime::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.9.0/src/runtime.rs:138:20
appflowy | 32: actix_rt::system::SystemRunner::block_on
appflowy | at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.9.0/src/system.rs:245:17
appflowy | 33: appflowy_cloud::main
appflowy | at ./src/main.rs:6:1
appflowy | 34: core::ops::function::FnOnce::call_once
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
appflowy | 35: std::sys_common::backtrace::__rust_begin_short_backtrace
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
appflowy | 36: std::rt::lang_start::{{closure}}
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
appflowy | 37: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
appflowy | 38: std::panicking::try::do_call
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
appflowy | 39: std::panicking::try
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
appflowy | 40: std::panic::catch_unwind
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
appflowy | 41: std::rt::lang_start_internal::{{closure}}
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
appflowy | 42: std::panicking::try::do_call
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
appflowy | 43: std::panicking::try
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
appflowy | 44: std::panic::catch_unwind
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
appflowy | 45: std::rt::lang_start_internal
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
appflowy | 46: std::rt::lang_start
appflowy | at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
appflowy | 47: <unknown>
appflowy | 48: __libc_start_main
appflowy | 49: _start
appflowy exited with code 1
appflowy-postgres | 2024-02-26 10:49:43.560 UTC [69] ERROR: relation "auth.users" does not exist
appflowy-postgres | 2024-02-26 10:49:43.560 UTC [69] STATEMENT: GRANT SELECT, INSERT, UPDATE, DELETE ON public.af_user TO supabase_auth_admin;
appflowy-postgres |
appflowy-postgres | -- Trigger Function to delete a user from the pulic.af_user table
appflowy-postgres | -- when a user is deleted from auth.users table (with matching uuid) field
appflowy-postgres | CREATE OR REPLACE FUNCTION public.delete_user()
appflowy-postgres | RETURNS TRIGGER AS $$
appflowy-postgres | BEGIN
appflowy-postgres | DELETE FROM public.af_user WHERE uuid = OLD.id;
appflowy-postgres | RETURN OLD;
appflowy-postgres | END;
appflowy-postgres | $$ LANGUAGE plpgsql;
appflowy-postgres |
appflowy-postgres | CREATE TRIGGER delete_user_trigger
appflowy-postgres | AFTER DELETE ON auth.users
appflowy-postgres | FOR EACH ROW EXECUTE FUNCTION public.delete_user();
appflowy-postgres |
appflowy-postgres | -- Trigger Function to update the 'deleted_at' field in the pulic.af_user table
appflowy-postgres | -- (Soft Delete)
appflowy-postgres | CREATE OR REPLACE FUNCTION public.update_af_user_deleted_at()
appflowy-postgres | RETURNS TRIGGER AS $$
appflowy-postgres | BEGIN
appflowy-postgres | -- Check if 'deleted_at' field is modified
appflowy-postgres | IF OLD.deleted_at IS DISTINCT FROM NEW.deleted_at THEN
appflowy-postgres | -- Update 'deleted_at' in public.af_user
appflowy-postgres | UPDATE public.af_user
appflowy-postgres | SET deleted_at = NEW.deleted_at
appflowy-postgres | WHERE uuid = NEW.id;
appflowy-postgres | END IF;
appflowy-postgres | RETURN NEW;
appflowy-postgres | END;
appflowy-postgres | $$ LANGUAGE plpgsql;
appflowy-postgres |
appflowy-postgres | CREATE TRIGGER update_af_user_deleted_at_trigger
appflowy-postgres | AFTER UPDATE OF deleted_at ON auth.users
appflowy-postgres | FOR EACH ROW EXECUTE FUNCTION public.update_af_user_deleted_at();
appflowy-postgres |
Hi @BramvdnHeuvel, please check speed2exe's comment, in my case gotrue didn't come up as expected and so the migration scripts failed. Did you use the docker-compose.yml from this repo? It should work as it is currently used as a blueprint for my kubernetes migration which will bring up a helm chart for deployment.
Anything new on this? I am experiencing the same issue after pulling the current main branch.
Describe the bug I currently write a script to deploy AppFlowy to my Kubernetes Cluster. When a postgres container starts, the migration/before script is executed. Then the AppFlowy container starts and fails with error "error returned from database: relation 'auth.users' does not exist"
To Reproduce Deploy appflowyinc/appflowy_cloud:0.1.25
Expected behavior Migration scripts should leave a working DB
Screenshots
Desktop (please complete the following information): Linux / Kubernetes
Additional context