AppFlowy-IO / AppFlowy-Cloud

AppFlowy is an open-source alternative to Notion. You are in charge of your data and customizations. Built with Flutter and Rust.
GNU Affero General Public License v3.0
1.06k stars 226 forks source link

[Bug] Migration scripts fail / Kubernetes deployment #315

Open P5J3MS opened 9 months ago

P5J3MS commented 9 months ago

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

AppFlowy Cloud with RUST_LOG=info
  2024-02-11T12:09:57.456626Z  INFO  Preparng to run database migrations...
    at src/application.rs:167

{"v":0,"name":"appflowy_cloud","msg":"Preparng to run database migrations...","level":30,"hostname":"appflowy-6cc587456b-bkzrw","pid":1,"time":"2024-02-11T12:09:57.456735529Z","target":"appflowy_cloud::application","line":167,"file":"src/application.rs"}
  2024-02-11T12:09:57.456768Z  INFO  Connecting to postgres database with setting: DatabaseSetting { pg_conn_opts: PgConnectOptions { host: "localhost", port: 5432, socket: None, username: "postgres", password: Some("password"), database: Some("postgres"), ssl_mode: Prefer, ssl_root_cert: None, ssl_client_cert: None, ssl_client_key: None, statement_cache_capacity: 100, application_name: None, log_settings: LogSettings { statements_level: Debug, slow_statements_level: Warn, slow_statements_duration: 1s }, extra_float_digits: Some("2"), options: None }, require_ssl: false, max_connections: 20, database_name: "postgres" }
    at src/application.rs:343

{"v":0,"name":"appflowy_cloud","msg":"Connecting to postgres database with setting: DatabaseSetting { pg_conn_opts: PgConnectOptions { host: \"localhost\", port: 5432, socket: None, username: \"postgres\", password: Some(\"password\"), database: Some(\"postgres\"), ssl_mode: Prefer, ssl_root_cert: None, ssl_client_cert: None, ssl_client_key: None, statement_cache_capacity: 100, application_name: None, log_settings: LogSettings { statements_level: Debug, slow_statements_level: Warn, slow_statements_duration: 1s }, extra_float_digits: Some(\"2\"), options: None }, require_ssl: false, max_connections: 20, database_name: \"postgres\" }","level":30,"hostname":"appflowy-6cc587456b-bkzrw","pid":1,"time":"2024-02-11T12:09:57.456879377Z","target":"appflowy_cloud::application","line":343,"file":"src/application.rs"}
Error: Failed to initialize application state: Failed to run migrations: while executing migrations: error returned from database: relation "auth.users" does not exist

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.79/src/error.rs:83:36
   1: appflowy_cloud::main::{{closure}}::{{closure}}
             at ./src/main.rs:55:18
   2: core::result::Result<T,E>::map_err
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:829:27
   3: appflowy_cloud::main::{{closure}}
             at ./src/main.rs:53:15
   4: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:978:42
   5: tokio::task::local::LocalSet::with::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:730:13
   6: std::thread::local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
   7: std::thread::local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
   8: tokio::task::local::LocalSet::with
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:728:17
   9: <tokio::task::local::RunUntil<T> as core::future::future::Future>::poll
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:968:9
  10: tokio::task::local::LocalSet::run_until::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:635:19
  11: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
  12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:57
  13: tokio::runtime::coop::with_budget
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:107:5
  14: tokio::runtime::coop::budget
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:73:5
  15: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:25
  16: tokio::runtime::scheduler::current_thread::Context::enter
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:410:19
  17: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:664:36
  18: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:68
19: tokio::runtime::context::scoped::Scoped<T>::set
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/scoped.rs:40:9
  20: tokio::runtime::context::set_scheduler::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:26
  21: std::thread::local::LocalKey<T>::try_with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
  22: std::thread::local::LocalKey<T>::with
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
  23: tokio::runtime::context::set_scheduler
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:17
  24: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:27
  25: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:652:19
  26: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:175:28
  27: tokio::runtime::context::runtime::enter_runtime
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/runtime.rs:65:16
  28: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:167:9
  29: tokio::runtime::runtime::Runtime::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/runtime.rs:348:47
  30: tokio::task::local::LocalSet::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/task/local.rs:592:9
  31: actix_rt::runtime::Runtime::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.9.0/src/runtime.rs:138:20
  32: actix_rt::system::SystemRunner::block_on
             at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-rt-2.9.0/src/system.rs:245:17
  33: appflowy_cloud::main
             at ./src/main.rs:6:1
  34: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  35: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  36: std::rt::lang_start::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  37: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
  38: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  39: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  40: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  41: std::rt::lang_start_internal::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
  42: std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  43: std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  44: std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  45: std::rt::lang_start_internal
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  46: std::rt::lang_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  47: <unknown>
  48: __libc_start_main
  49: _start

Desktop (please complete the following information): Linux / Kubernetes

Additional context

Jayaprakash-dev commented 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.

speed2exe commented 8 months ago

@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

BramvdnHeuvel commented 8 months ago

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 Cloud logs

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

Postgres logs

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  |
P5J3MS commented 8 months ago

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.

moritz157 commented 3 months ago

Anything new on this? I am experiencing the same issue after pulling the current main branch.