Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panics on unkown extension #12

Open
buraktabn opened this issue Aug 2, 2024 · 1 comment · May be fixed by #13
Open

Panics on unkown extension #12

buraktabn opened this issue Aug 2, 2024 · 1 comment · May be fixed by #13

Comments

@buraktabn
Copy link

one of the migration files looks like this:

CREATE
    EXTENSION IF NOT EXISTS postgis;

CREATE TABLE IF NOT EXISTS trails (
    id            BIGSERIAL PRIMARY KEY,
    location GEOMETRY(Point, 4326) NOT NULL
);

running the psql on docker as follows:

services:
  db:
    image: postgis/postgis:14-3.4
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=123123
    ports:
      - '5432:5432'
    volumes:
      - "db:/var/lib/postgresql/data"
%  RUST_BACKTRACE=full sql-gen generate                                                                                                                                                                                     101 ↵ ✹ ✭
Creating DB and applying migrations from migrations
thread 'main' panicked at /Users/burak/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sql-gen-0.1.5/src/main.rs:172:39:
could not run migration: Execute(Database(PgDatabaseError { severity: Error, code: "58P01", message: "could not open extension control file \"/usr/local/share/postgresql/extension/postgis.control\": No such file or directory", detail: None, hint: None, position: None, where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("extension.c"), line: Some(491), routine: Some("parse_extension_control_file") }))
stack backtrace:
   0:        0x100d40a9c - std::backtrace_rs::backtrace::libunwind::trace::h0b901628cfcf882b
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x100d40a9c - std::backtrace_rs::backtrace::trace_unsynchronized::hc6816418436e89a3
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x100d40a9c - std::sys_common::backtrace::_print_fmt::he96152a65a50ac61
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x100d40a9c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd743e1730fc889af
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x100d60c54 - core::fmt::rt::Argument::fmt::he5596ecdd2f3eedc
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/core/src/fmt/rt.rs:142:9
   5:        0x100d60c54 - core::fmt::write::h90423ed68cfda32b
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/core/src/fmt/mod.rs:1120:17
   6:        0x100d3d404 - std::io::Write::write_fmt::h43099f2911307ae7
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/io/mod.rs:1762:15
   7:        0x100d408d8 - std::sys_common::backtrace::_print::h421688e626cbeb38
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x100d408d8 - std::sys_common::backtrace::print::h5dea4d8334ffb101
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x100d41e68 - std::panicking::default_hook::{{closure}}::h74d4d2e3519ce8fb
  10:        0x100d41bb0 - std::panicking::default_hook::he779767b73a69f2a
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:292:9
  11:        0x100d42290 - std::panicking::rust_panic_with_hook::hf562b6af24c16505
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:779:13
  12:        0x100d42190 - std::panicking::begin_panic_handler::{{closure}}::he0b4ebe231153083
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:657:13
  13:        0x100d40f04 - std::sys_common::backtrace::__rust_end_short_backtrace::h506e293342848289
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x100d41f2c - rust_begin_unwind
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:645:5
  15:        0x100d7dbd8 - core::panicking::panic_fmt::hdbf482c928a0b9a2
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/core/src/panicking.rs:72:14
  16:        0x100d7df78 - core::result::unwrap_failed::h790226312b5dbdc2
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/core/src/result.rs:1649:5
  17:        0x100b35560 - sql_gen::main::{{closure}}::hfb6b09f36b32d2bd
  18:        0x100b2c5a8 - tokio::runtime::park::CachedParkThread::block_on::h448b2bd239db3116
  19:        0x100b7fc34 - sql_gen::main::h1b5249dec1ae4033
  20:        0x100b8c664 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1a25b4b38275ed3b
  21:        0x100b80cf0 - std::rt::lang_start::{{closure}}::he7719340f0b92f96
  22:        0x100d376bc - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h15b039485f9a382d
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/core/src/ops/function.rs:284:13
  23:        0x100d376bc - std::panicking::try::do_call::h495492b67a0caff3
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:552:40
  24:        0x100d376bc - std::panicking::try::h0cd1a6a97a8b1037
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:516:19
  25:        0x100d376bc - std::panic::catch_unwind::he0123c21323352ca
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panic.rs:142:14
  26:        0x100d376bc - std::rt::lang_start_internal::{{closure}}::h8ffb90db754f7023
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/rt.rs:148:48
  27:        0x100d376bc - std::panicking::try::do_call::h8f5aaa918fcc2486
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:552:40
  28:        0x100d376bc - std::panicking::try::hc6f686c35f31bade
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panicking.rs:516:19
  29:        0x100d376bc - std::panic::catch_unwind::hb250b2524587bbd1
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/panic.rs:142:14
  30:        0x100d376bc - std::rt::lang_start_internal::h16464641f6fcfbfc
                               at /rustc/6b771f6b5a6c8b03b6322a9c77ac77cb346148f0/library/std/src/rt.rs:148:20
  31:        0x100b80cd4 - std::rt::lang_start::hc4693c37be7b9405
  32:        0x100b80ae4 - _main


@jayy-lmao
Copy link
Owner

Seeing as you're running your own database, you need to use the --database flag to provide it as the database to generate from.

You will also need to apply that migration to the database yourself, as it intentionally does not auto-migrate when the --database flag is provided.

Finally, I think the Geometry type is still needed in the types mapper; but I think support in SQLX is still WIP: launchbadge/sqlx#166

@buraktabn buraktabn linked a pull request Aug 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants