Hi,
This week a colleague and I have forked RoundhousE and added the ability to migrate or 'kick' a RavenDB instance.
Why an external migration tool?
After experimenting with RavenDB and doing migrations in the Application_Start of the web application. Users started complaining that the application took a lot of time before it showed the first screen. The complaint always came from the user how was the first to open the application in the morning. The cause was our migration code, it shouldn't run at every start of the application but only on every new update of the application.
Why RoundhousE?
We have been using RoundhousE in our company for a few years now, both for SQL Server and Oracle. It is part of our software distribution and executed with every update.
In the past I've been contributing to RoundhousE, so I know the codebase a little.
How do sql scripts translate to RavenDB?
To do migrations with RoundhousE you need pass it multiple folders that have scripts in them. The content of those script files is read and passed to the database for execution. Those sql scripts contain actions we all know, like INSERT, DELETE, SELECT. If you translate those to RavenDB's http api, you get PUT/POST, DELETE, GET. Another part of sql script is the table you would like to use for your insert, select or delete, in RavenDB this is the document url.
How does the execution of scripts work?
curl -X PUT http://localhost
:
8080/docs/bobs_address -d
"{ FirstName: 'Bob', LastName: 'Smith', Address: '5 Elm St' }"
We only remove curl -X, because it isn't curl that will execute the scripts, but RoundhousE.
RoundhousE will interpret the script and does a http PUT, GET, POST, PATCH or DELETE to the document url with the content of the -d parameter as data. Even headers are supported with the -H parameter, just like curl.
An advantage is that the scripts can be run with curl, the same way the sql scripts we use with RoundhousE can be run with sqlcmd.
What about the RoundhousE tables?
These have been transformed to RoundhousE documents. There is a single Version document, and for each run of a script there is ScriptsRun and/or ScriptsRunError document.
What are the parameters I should pass to RoundhousE to use this?
There aren't any additional parameters. The databasetype should be set to ravendb or raven. The connectionstring is the one you use in your RavenDB application and must be in the form of Url=http://localhost:8080;Database=MyTenant.
RoundhousE supports 2 connectionstrings, normal and admin. I suggest you pass a database to the normal connectionstring and omit the database part for the admin connectionstring. Scripts that are run as admin are then executed against the system database. This is useful for the creation of a new tenant/database.
How is the document url in the script used?
A script like this:
PUT http://localhost
:
8080/docs/bobs_address -d
"{ FirstName: 'Bob', LastName: 'Smith', Address: '5 Elm St' }"
Contains a document url with a server part,
http://localhost:8080. This part is replaced by an url build from the connectionstring. If the connectionstring is the following Url=http://dropkick:81;Database=Chuck, the data will be put to
http://dropkick:81/databases/Chuck/docs/bobs_address
Whats next?
Well the RoundhousE adjustments are still a branch of a fork of RoundhousE. It's there so that everybody can use it, but it would be nice if it got merged with the RoundhousE master. Not everything has been implemented, only the stuff we need for now are. Feel free to fork and fix bugs and add features.
Where is the code?
Regards,
Jochen
PS: This message has been cross-posted on the RavenDB group
--
You received this message because you are subscribed to the Google Groups "chucknorris" group.
To view this discussion on the web visit https://groups.google.com/d/msg/chucknorrisframework/-/xrQsPq-L1tAJ.
To post to this group, send email to chucknorri...@googlegroups.com.
To unsubscribe from this group, send email to chucknorrisframe...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/chucknorrisframework?hl=en.