Skip to content
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

Cross-migration transaction support #100

Closed
venantius opened this issue Apr 16, 2016 · 3 comments
Closed

Cross-migration transaction support #100

venantius opened this issue Apr 16, 2016 · 3 comments

Comments

@venantius
Copy link
Contributor

I'm curious as to whether there's a way to wrap ragtime's migrations in a transaction block.

To be clear, I'm not talking about per-migration transactions (i.e., begin - migration - transaction), but rather a cross-migration transaction block:
begin
migration1
migration2
migration3
...
commit

I'm asking because I'm looking at whether I can hastily run all migrations on my test database, execute a test, and then return the state of the world to 0 before doing it all again for each test.

I've been trying to do this in a way that plays nicely with Korma but my guess is that ragtime is handling its own DB connection and so they're not actually sharing the transaction block. Any thoughts on how to handle this?

@weavejester
Copy link
Owner

The ragtime.jdbc/sql-database function takes a db-spec, which can contain a raw connection instead of a database URL. So you could do something like:

(clojure.java.jdbc/with-db-connection [t db-spec]
  (let [datastore (ragtime.jdbc/sql-database {:connection t})]
    ...))

@venantius
Copy link
Contributor Author

I unfortunately realized this after filing the issue. Thanks for the quick response, though, and sorry for the noise :)

@weavejester
Copy link
Owner

No problem!

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

2 participants