calling pragma before anything else ?

Hi,


First I would like to say many thanks to the developers of liquibase, it is extremely useful to me, and saves me a lot of time!


My context of use is with a sqlite database encrypted with sqlcipher. For this i have to call "<span containing PRAGMA key = ‘xxxx’;. It does not work because liquibase queries the database before the first changeset is executed

-creating a changelog level preConditions tag, containing sqlCheck. It does not seem to work, maybe because sqlCheck expects a single row with a single value in return. What’s more I am not sure it is run before any other database access


Would you have any direction for me to test?


Thanks in advance !

Eric Lemanissier

I can’t think of a hook within liquibase that will run SQL before anything else. Depending on how you are calling Liquibase, you could call PRAGMA on the jdbc Connection that is passed to liquibase. How are you running liquibase?

Nathan

Unfortunately not directly. You could create a new java class that wraps the liquibase.integration.commandline.Main class that is called by your java -jar call with one that sets up the connection differently, but that would require a bit of java dev. If you’re up for that I can help walk you through it if you have troubles.


Nathan 

Yes, you could probably do with with a jdbc driver. I’m not sure exactly how off hand, though.


Nathan

Thanks for your answer. I am calling liquibase from a c++ program by calling an external java process : java -jar liquibase --classpath=sqlitejdbc.jar --driver=org.sqlite.JDBC --url=jdbc:sqlite:dbFileName --changeLogFile= changelogFile
I guess there is no way to interact with the jdbc driver directly this way ?

Ok, thanks for your answer.

We would like to limit as much as possible the java development part. Do you think it would be possible to use JNI to create a standard sqlite-jdbc driver, then call the sqlite pragma using JNI, and finally run liquibase whith the jdbc driver via JNI ?


Eric

I managed to call the pragma on the driver via JNI interface. If anyone needs this, I will post the code in few days.

During the coding, I found it simpler to add the jdbc jar to the classpath before starting the virtualmachine, instead of using classloader etc. Is there any drawback to this ?

Good to hear you have it working.  It should be just fine to add the jdbc jar either way.


Nathan