Skip to content

Build fails when migration is not applied #1101

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

Closed
kotx opened this issue Mar 13, 2021 · 2 comments
Closed

Build fails when migration is not applied #1101

kotx opened this issue Mar 13, 2021 · 2 comments

Comments

@kotx
Copy link

kotx commented Mar 13, 2021

I am using the migrate! and query! macros in my application. However, since query! checks the database before building, it will error with error returned from database: permission denied for table users if migrations aren't applied.

However, if I apply migrations with sqlx migrate run, then when running the application the migrate! macro will fail with this:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: VersionMismatch(20210313084850)', src\main.rs:41:31

So, are query! and migrate! mutually exclusive?

@abonander
Copy link
Collaborator

This is a known issue, the migrate!() macro may not pick up changes to the migrations/ folder and thus will try to run migrations with outdated SQL. If the error is fixed with cargo clean, that's why.

Closing as duplicate of #681

@dayo777
Copy link

dayo777 commented Sep 20, 2023

thread 'main' panicked at 'Unable to run the migrations.: VersionMismatch(20230902000042)', src/main.rs:24:53
stack backtrace:
0: 0x557bd0d5b2b1 - std::backtrace_rs::backtrace::libunwind::trace::h6aeaf83abc038fe6
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x557bd0d5b2b1 - std::backtrace_rs::backtrace::trace_unsynchronized::h4f9875212db0ad97
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x557bd0d5b2b1 - std::sys_common::backtrace::_print_fmt::h3f820027e9c39d3b
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:65:5
3: 0x557bd0d5b2b1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hded4932df41373b3
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:44:22
4: 0x557bd0d824ef - core::fmt::rt::Argument::fmt::hc8ead7746b2406d6
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/fmt/rt.rs:138:9
5: 0x557bd0d824ef - core::fmt::write::hb1cb56105a082ad9
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/fmt/mod.rs:1094:21
6: 0x557bd0d584f1 - std::io::Write::write_fmt::h797fda7085c97e57
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/io/mod.rs:1713:15
7: 0x557bd0d5b0c5 - std::sys_common::backtrace::_print::h492d3c92d7400346
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:47:5
8: 0x557bd0d5b0c5 - std::sys_common::backtrace::print::hf74aa2eef05af215
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:34:9
9: 0x557bd0d5c567 - std::panicking::default_hook::{{closure}}::h8cad394227ea3de8
10: 0x557bd0d5c354 - std::panicking::default_hook::h249cc184fec99a8a
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:288:9
11: 0x557bd0d5ca1c - std::panicking::rust_panic_with_hook::h82ebcd5d5ed2fad4
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:705:13
12: 0x557bd0d5c917 - std::panicking::begin_panic_handler::{{closure}}::h810bed8ecbe66f1a
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:597:13
13: 0x557bd0d5b6e6 - std::sys_common::backtrace::__rust_end_short_backtrace::h1410008071796261
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:151:18
14: 0x557bd0d5c662 - rust_begin_unwind
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
15: 0x557bcff4ada3 - core::panicking::panic_fmt::ha0a42a25e0cf258d
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
16: 0x557bcff4b333 - core::result::unwrap_failed::h100c4d67576990cf
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/result.rs:1651:5
17: 0x557bcfff6afd - core::result::Result<T,E>::expect::h1b7e1141a15a06d7
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/result.rs:1033:23
18: 0x557bcff9db52 - webapp_api::main::{{closure}}::h1d06c71794e08738
at /home/dru/Rust_projects/webapp_api/src/main.rs:24:5
19: 0x557bd004e254 - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::h86706e0c1375f801
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/park.rs:283:63
20: 0x557bd004e0dc - tokio::runtime::coop::with_budget::hb3c2c1bb9c1a1a8f
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/coop.rs:107:5
21: 0x557bd004e0dc - tokio::runtime::coop::budget::h486d976611603046
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/coop.rs:73:5
22: 0x557bd004e0dc - tokio::runtime::park::CachedParkThread::block_on::hf8605df6fc8989e0
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/park.rs:283:31
23: 0x557bcffe9ad3 - tokio::runtime::context::blocking::BlockingRegionGuard::block_on::h73bb95adfed66daf
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context/blocking.rs:66:9
24: 0x557bd001c648 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}::hcebd1db57ad46189
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/mod.rs:87:13
25: 0x557bd007614c - tokio::runtime::context::runtime::enter_runtime::h0f2885796f955b11
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context/runtime.rs:65:16
26: 0x557bd001c603 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h98129081dc427729
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/mod.rs:86:9
27: 0x557bcff4d22a - tokio::runtime::runtime::Runtime::block_on::h84bfa8ce7fb02b92
at /home/dru/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/runtime.rs:313:45
28: 0x557bcff844af - webapp_api::main::he1470a2ec6666e19
at /home/dru/Rust_projects/webapp_api/src/main.rs:94:5
29: 0x557bd00774bb - core::ops::function::FnOnce::call_once::h297db8b9963e8ac7
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/ops/function.rs:250:5
30: 0x557bd00a9e1e - std::sys_common::backtrace::__rust_begin_short_backtrace::hdb8fc3290b2792b5
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/sys_common/backtrace.rs:135:18
31: 0x557bcff7fbd1 - std::rt::lang_start::{{closure}}::h6aba5a9b56aa646f
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/rt.rs:166:18
32: 0x557bd0d54325 - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::h5ce27e764c284c0a
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/ops/function.rs:284:13
33: 0x557bd0d54325 - std::panicking::try::do_call::h4c1fc390ae241991
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:500:40
34: 0x557bd0d54325 - std::panicking::try::h4d36e7eaed86af72
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:464:19
35: 0x557bd0d54325 - std::panic::catch_unwind::h41cfb4dd65282b1e
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panic.rs:142:14
36: 0x557bd0d54325 - std::rt::lang_start_internal::{{closure}}::hfed411c1c5fdb925
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/rt.rs:148:48
37: 0x557bd0d54325 - std::panicking::try::do_call::h6893f6f32a464342
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:500:40
38: 0x557bd0d54325 - std::panicking::try::h52b7102f469a0567
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:464:19
39: 0x557bd0d54325 - std::panic::catch_unwind::h62120054677916b5
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panic.rs:142:14
40: 0x557bd0d54325 - std::rt::lang_start_internal::hd66bf6b7da144005
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/rt.rs:148:20
41: 0x557bcff7fbaa - std::rt::lang_start::h06c7b3f2ad533aef
at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/rt.rs:165:17
42: 0x557bcff8455e - main
43: 0x7f3fdf629d90 -
44: 0x7f3fdf629e40 - __libc_start_main
45: 0x557bcff4b635 - _start
46: 0x0 -

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

No branches or pull requests

3 participants