bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Shutdown the Plugin (to free database) #92

Open mikkoi opened 7 years ago

mikkoi commented 7 years ago

My use in testing: I have PostgreSQL database and I test my Dancer2 API routes by creating a new database instance every time. That way I always get 1) completely fresh database and 2) the newest schema. When the test has been run and assuming there were no errors, the database is deleted. When I start my Dancer2 with Plack::Test, I also run a setup() function to give the database name to Dancer (via runtime config).

When I finish running the test, I cannot delete the database because it is still open and reserved by Dancer2.

I think, what we need, is a way to signal to Database plugin that it must close down the connection and keep it closed. Something like

database->abandon([name]);