AscendingCreations / AxumSession

Axum Session Management Libraries that use Sqlx
MIT License
142 stars 29 forks source link

Expose AxumSessionStore::migrate() from AxumSessionLayer #2

Closed apps4uco closed 2 years ago

apps4uco commented 2 years ago

I may be jumping the gun as you havent released the crate yet and its a minor point ... but....

The only way I saw to migrate the session table is by using

{
  let store=AxumSessionStore::new(pool.clone().into(),session_config.clone());
   store.migrate().await.expect("Error creating session table in database");
} //inside a scope so that store gets dropped after use

However the session store is again created by AxumSessionLayer::new

I think it would be a good idea to do one of the following:

Thanks

genusistimelord commented 2 years ago

I did think about this however this function is only ever needed to be ran once. So generally most web applications would setup a Configuration and Setup phase where this function would be ran once. As you do not want to run this every time your server starts up and only when you tell it too.

However to make this Easier to use, I would like to Migrate this out of AxumSessionStore and make it take a config and a pool directly. As there is no need for it to use an entire Session store.

Thank you for your interest in my library.

genusistimelord commented 2 years ago

This has been fixed in the last update for Async changes