Fork me on GitHub
#sql
<
2019-04-18
>
dumrat17:04:51

Should I just skip using these clojure libraries and just resort to using a mixture of sql + bash scripts?

hiredman17:04:15

I suspect you need a --;; between each statement

hiredman17:04:04

I haven't used ragtime, but I've used similar things and if I recall this has to do with jdbc

hiredman17:04:49

jdbc isn't the same as pasting sql statements in to a command line client (mysql, or psql), have to execute each statement as an individual thing, and in order to know how to split a .sql file into statements, a common convention is --;;

hiredman17:04:19

I forget exactly what the issue is with splitting on ';', I vaguely recall there is one (although our home grown migration library where I work now does split on ';' and it hasn't been a problem)

hiredman17:04:31

I think the issue with splitting on ';' is it breaks stored procedure definitions

dumrat17:04:34

@hiredman Does putting --;; between each line work when there are local vars? (i.e. SET @ins_id1 = LAST_INSERT_ID();) I tried this and it seems that the local var is null

hiredman17:04:10

my guess for that is you are running into a transaction issue

hiredman17:04:07

ragtime maybe executing each statement one by one effectively each in their own transaction, but I never use set like that, so I am not sure what the scope for those values is

hiredman17:04:47

https://github.com/weavejester/ragtime/issues/107 and I guess there are issues running migrations in a transaction in the general case

dumrat17:04:35

Yeah I have this issue also. Rollback doesn't work properly 😞

dumrat17:04:48

Ok, I think I will try another migration lib then

hiredman17:04:17

actually, I bet that isn't a transaction thing, I bet ragtime isn't creating a single jdbc connection and running each statement, I bet it is creating a new sql connection for every statement