Comments (8)
Thanks for opening this bug report. I'm aware of this, but it's good to have an explicit issue for this. I do not consider that to be a huge problem for now, as migrations are mostly run on application start. That's a place where it's perfectly fine to just use a blocking method.
I might spend some time to look into ways for fixing this in the future, after the diesel 2.0 release and an initial diesel_async release. (Just to be explicit about that: This takes likely some time, I do not expect to find time for this in the next few months)
from diesel_async.
Hi,
I created this quickly by just copying the standard diesel migrations and making the strings public. It's not composable in any way.
There might be many pitfalls and shortcomings in this solution and we've only used it with postgres but it's been working fine for us this far.
As I understand it it's fine to copy the code as long as I keep the MIT-license.
@weiznich If my understanding regarding the licenses is wrong or there's any other issue with the naming or anything, let me know and I'll correct it. I'm just dropping a link here so that anyone who wants quick migrations can use it.
from diesel_async.
One thing to note about the blocking method is it required libpq
headers to be present, which is annoying if you bet on async and don't need it otherwise.
How would you approach the implementation of this? I presume this will require a rewrite of the diesel_migrations
harness to decouple the execution from the control logic somehow. Or would it be better to rewrite the whole harness to be async with the same design but async fns?
from diesel_async.
@nicrgren It's fine to fork and change that code on your own. I just do not want to do that for diesel-async as well, as I do not want to maintain that much duplicated code.
from diesel_async.
I honestly must say that I do currently not have an idea how to implement this in a composable way. What I can say: It will require quite a bit of design work, which is something I personally do not have the capacity for at the moment.
If your main goal is to remove the dependency on libpq
it seems like easier short term solution to just write a rust-postgres
based sync connection implementation as third party crate. That shouldn't be to hard based on the existing diesel-async
AsyncPgConnection
based on tokio-postgres
(as that already shows how to do all the type conversions).
from diesel_async.
I am staring at #100 but I don't understand how that fixes this issue. My problem is that I have a AsyncPgConnection
and I need to call run_pending_migrations
. It seems that with AsyncConnectionWrapper
I can take a database URL and turn that into a AsyncConnectionWrapper::<DbConnection>
, but that's not useful since I don't have the URL... the connection has long been established (by Rocket, which magically picks up the URL from the config file or environment variable or whatever), I just need to somehow call migrations on it. Help would be appreciated :)
Also, the docs mention a DbConnection
type that I cannot find anywhere.
from diesel_async.
It expects you to create a new connection either based on the connection url or based on an existing connection via a From
impl. The later is only available in an unreleased version yet. I cannot comment on how to do that based on rockets setup as I don't use rocket myself. It might be worth to ask that in their support channels. That written: There is currently no other built-in way that allows you to apply migrations via diesel_migrations
at application startup. It's also likely that this won't change anytime soon as diesel_migrations
API expects a sync diesel connection. Hopefully that helps at least to understand what's possible and what's not possible.
Also, the docs mention a DbConnection type that I cannot find anywhere.
DbConnection
can by any type that implements AsyncConnection
.
from diesel_async.
Yeah I think that From
instance would suffice. Good to hear this will be resolved in a future version. :)
For now I switched back to sync diesel.
from diesel_async.
Related Issues (20)
- Failed to find a type oid for ENUM_TYPE HOT 30
- Compiler requires `'static` when using transactions on generic AsyncConnection HOT 1
- The trait MultiConnection is not implemented
- conflicting implementations of trait `diesel_async::RunQueryDsl<_>` for type `paginate_async::PaginatedQuery<_, _>` HOT 4
- conflicting implementations of trait diesel_async::RunQueryDsl<_> for type paginate_async::PaginatedQuery<_, _> HOT 1
- use diesel_async::RunQueryDsl::execute conflicts with meilisearch_sdk execute HOT 5
- AsyncConnectionWrapper does not implement `build_transaction` HOT 2
- r2d2 not supported with AsyncPgConnection HOT 2
- Unable to connect to PostgreSQL in a separate Kubernetes pod using Diesel in Rust
- Failed to save array of enums HOT 1
- Is there some way to get the last insert id after an insert operation?
- Problem trait LoadQuery is not satisfied sub query when implement Pagination
- UpdateAndFetchResults is not implemented for deadpool Object HOT 1
- Outdated examples HOT 4
- Raw sql Query not working in 0.3.1 HOT 2
- Incorrect casting of MySQL `tinyint` HOT 3
- `table!` macro fails when a column with an underscore is included HOT 1
- Feature Request: sqlite
- Dangling transactions when pooled connections dropped HOT 4
- Fail to get the connection with the features ["postgres", "bb8"] HOT 4
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 diesel_async.