patka / cassandra-migration

Schema migration library for Cassandra
MIT License
153 stars 47 forks source link

script checksum mechanism #17

Closed shaynechmad closed 6 years ago

shaynechmad commented 7 years ago

Hi Patrick,

I want the ability to know if a script that already processed (and in the schema_version table) was changed, and if so return failure. (like the checksum mechanism in flyway).

The migration task go over all the scripts, calculate the script checksum. if the script is in schema_version table, it compare the calculated checksum to the checksum value in the schema_version table if the script is not in schema_version table, migrate the script.

what do you think? if you don't have time, i can help with the development

Thanks, Shay

patka commented 7 years ago

Hi Shay,

thanks for the congrats!

That feature sounds reasonable. I don't know how it is done in Flyway but it would be interesting to think for a moment how the checksum should be calculated or what it should consider. The easiest would be to take the whole script file into consideration but this would mean, that one single space or new line character at the end, maybe done by an auto format of an IDE, would screw up the checksum. I think it would also make sense to have the mechanism that in flyway is called repair, in case you want to recalculate all checksums. Might be interesting to use a maven plugin for this as well to make things more easy. For the algorithm itself, I guess it might make sense to use SHA512 to be on the safe side for the future.

Of course any code contribution is welcome as I cannot say currently how much time I will have within the next few weeks ;-)

Cheers Patrick

shaynechmad commented 7 years ago

Hi Patrick,

Have you looked for a solution? I wrote the checksum mechanism without the repair. I calculate it for all the script with SHA512 algorithm. if you want, I can attach the modified classes.

Thanks, Shay

patka commented 7 years ago

Hi Shay,

I am sorry, so far I had no time for it as my second daughter was born roughly two weeks ago. But I expect life to be more back to normal quite soon which then should give me time to tackle this problem.

Anyway, a pull request is of course highly welcome :)

Cheers Patrick

Am 05.11.17 um 14:31 schrieb shaynechmad:

Hi Patrick,

Have you looked for a solution? I wrote the checksum mechanism without the repair. I calculate it for all the script with SHA512 algorithm. if you want, I can attach the modified classes.

Thanks, Shay

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patka/cassandra-migration/issues/17#issuecomment-341973292, or mute the thread https://github.com/notifications/unsubscribe-auth/ADDQcs12oIYdKtxX13qzfEln7hAqwdVbks5szbiTgaJpZM4P5yuv.

shaynechmad commented 7 years ago

Hi Patrick,

Congratulations on the birth of your new baby girl :-)

I'm uploading a pull request for the checksum mechanism. let me know if you have any questions

Thanks, Shay

shaynechmad commented 6 years ago

Pull request #21

patka commented 6 years ago

Implemented in branch v3.

rbleuse commented 2 years ago

Hi @patka, may I ask why this feature was not implemented as well on the v4 branch ?