mattes / migrate

Database migrations. CLI and Golang library.
Other
2.29k stars 326 forks source link

Chain commands in cassandra migration file #338

Open YannickB opened 6 years ago

YannickB commented 6 years ago

Hello,

Is it possible to chain several commands when executing a migration file for cassandra ? I have an error if I try to add something after a semi-colon.

migration failed in line 0: CREATE TABLE IF NOT EXISTS requirement ( id text, parent_id text, sequence int, computation text, weight int, state text, can_have_children boolean, PRIMARY KEY(id) ); CREATE INDEX IF NOT EXISTS requirement_parent_id ON requirement(parent_id); (details: line 11:0 mismatched input 'CREATE' expecting EOF (...PRIMARY KEY(id));[CREATE]...))

Of course I can still create one file per command but this is really not convenient. I wonder if this is a limitation of gocql, what do you think ?

Thanks!

YannickB commented 6 years ago

I asked the question on the gocql project (link above). It seems this is a cassandra limitation, the only way seems to find a way to split the statement and execute them separately. Maybe a strings.Split(file, ";") will do the trick ?