Comments (7)
This caught me for a minute as well. I just added a build dependency on cargo-emit:
[build-dependencies]
cargo-emit = "0.1.1"
And a build.rs
use cargo_emit::rerun_if_changed;
cargo_emit::rerun_if_changed!(
"migrations",
);
from refinery.
Okay, seems like I have managed to reproduce issue on my end.
- Delete the database so that it's recreated from scratch.
- Have two migration files in
migrations
directory:V1__initial.sql
and--V2_secondary.sql
(--
so that the migration won't be run). - Run the program with
RUST_LOG=info cargo run
. The first migration is correctly applied. - Remove the prefix from the name of second migration (so now it reads
V2__secondary.sql
, so that it should be applied). - Upon running of the program, the secondary migration is not applied.
- Change the contents of the
.rs
file, so that the nextcargo run
recompiles the project. - Upon recompiling, the secondary migration is now correctly detected and applied.
What I also noticed is that if i change the name of migration so that it's no longer applicable (V2__secondary.sql -> --V2_secondary.sql
) the project gets recompiled. If i do that the other way around, the project no longer recompiles and its in an invalid state, when the second migration should be picked up, but isn't.
So, in conclusion, based on that, I see that the state of the migrations
directory is updated at compile time. When a valid migration file gets renamed so that it's no longer valid, the project is correctly recompiled and the invalid migration will not be ran.
However, if an invalid migration file is renamed so that it is valid, or a new migration with a valid filename is created, the change is not picked up. One has to then arbitrarily change something in source code, so that the project will be recompiled, and upon doing so, the migration is only then finally detected and ran.
Could you please try to reproduce the issue on your end?
Also, as to the possible fixes:
- make the project recompile if a new valid migration is created or
- check
migrations
directory at runtime instead of compile time
from refinery.
Similarly to #55 I reckon reflecting the filesystem change would be best achieved by instead of using WalkDir
, which works at runtime, using something which acts at compile time?
from refinery.
Hi, thanks! want to submit a patch adressing this issue?
from refinery.
Thanks for the response! I would like to but tbh I'm not sure where to start and how would this patch work. I see that something like include_str!
is a compiler builtin, so I would need some pointers where to look to implement a viable solution.
from refinery.
so, the reason the macro is used is to bundle the migrations at compile time to the binary using include_str
as you mentioned above. We should look for a way to trigger recompilation every time there is a change on the migrations dir
from refinery.
addressed with #170
from refinery.
Related Issues (20)
- Broken docker image 0.8.11 HOT 2
- Support mysql 24.0.0 HOT 3
- Support SurrealDB HOT 1
- Update broken Flyway documentation link HOT 1
- Support a function similar to flyway baseline HOT 1
- Wrap embedded migrations with enums HOT 8
- Get final database schema after all migrations are run HOT 3
- Current rusqlite version (0.30.0) not supported? HOT 1
- serde properties of Config should be under a feature gate along with Toml serde impl HOT 2
- New Files are not Detected by embed_migrations HOT 2
- Sqlx no longer supported because Migrate no longer implemented by Config HOT 3
- refinery_cli: ERROR: cannot insert multiple commands into a prepared statement HOT 7
- Add support for rusqlite 0.31.0 HOT 4
- refinery_cli: Error: `error applying update`, `db error: ERROR: relation "refinery_schema_history" does not exist` HOT 5
- Unreproducible release for refinery-core 0.8.13 HOT 2
- Changelog lists release 0.8.14 twice HOT 1
- Add run_iter_async HOT 2
- Build error with tiberius without serde HOT 2
- Allow specifying database schema on migrations (MSSQL database) HOT 1
- Missing math functions for SQLite HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refinery.