warp-tech / warpgate

Smart SSH, HTTPS and MySQL bastion that requires no additional client-side software
Apache License 2.0
3.87k stars 120 forks source link

Bug: postgres driver for sea-orm won't work with auto-increment u32 type #456

Closed notnooblord closed 2 years ago

notnooblord commented 2 years ago

Tried to deploy with postgres today, most of the tables created fine, but right in the end of "unattended setup" command got into panic.

Probably we can't just slap auto_increment = true on u32 type using postgres. https://github.com/SeaQL/sea-query/blob/0.26.3/src/backend/postgres/table.rs#L239

I'm not yet really familiar with sea-query, probably can be instrumented to work.

Here's panic unwind:

thread 'main' panicked at 'not implemented', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/sea-query-0.26.3/src/backend/postgres/table.rs:239:26
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: sea_query::backend::postgres::table::<impl sea_query::backend::postgres::PostgresQueryBuilder>::prepare_column_type_check_auto_increment
   4: sea_query::backend::postgres::table::<impl sea_query::backend::table_builder::TableBuilder for sea_query::backend::postgres::PostgresQueryBuilder>::prepare_column_def
   5: <sea_query::table::create::TableCreateStatement as sea_orm::database::statement::StatementBuilder>::build
   6: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   7: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: warpgate_core::services::Services::new::{{closure}}
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  11: warpgate::_main::{{closure}}
  12: <tracing::instrument::Instrumented<T> as core::future::future::Future>::poll
  13: tokio::runtime::Runtime::block_on
  14: warpgate::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Aborted
notnooblord commented 2 years ago

Seems like any unsigned is not supported in postgres derive macro. https://www.sea-ql.org/SeaORM/docs/generate-entity/entity-structure/#column-type Maybe we can just use i32 and i16 types.

notnooblord commented 2 years ago

@Eugeny There is also u16 in known host port, that also panics 😅 https://github.com/notnooblord/warpgate/blob/488bd7f62b8d4b068dc73b10650da66ad97363e8/warpgate-db-migrations/src/m00004_create_known_host.rs#L14

Eugeny commented 2 years ago

Sorry - fixed now! (you'll need to drop and recreate the database)