0

I'm writing a groovy script to archive data from a table of live database to an archive database (schemas). at present the table structure is same in both database schemas. that might get changed by adding new columns to the live table later based on the project requirements. doing those changes to the archive table is possible manually.

But my question here is, after writing the SQL inserts like :

insert into live.tableName (col1, col2,...coln) values (val1,val2,..,valn);

in the groovy script would crash if such indecent happens to be in the future. so is there any good way of doing these sort of requirement in groovy/ groovy sql ? please help or suggest a proper mechanism please.

Nomesh DeSilva
  • 1,649
  • 4
  • 25
  • 43
  • This is possible, but the answer depends on the database system in use. – Erich Kitzmueller Apr 13 '15 at 17:24
  • @ammoQ I'm using mysql. – Nomesh DeSilva Apr 13 '15 at 17:26
  • In this case, you can use `EXPLAIN` to find out the table structure of the live table and the archive table, and generate the input statement on the fly. You might even decide to automatically alter the archive table structure to match the live table stucture, but I do not expect this proposal to stay uncontested here on stackoverflow. – Erich Kitzmueller Apr 13 '15 at 17:42
  • @ammoQ thanks, I really understand the concept you explain. but could you please help out with a guidance or an example script. – Nomesh DeSilva Apr 13 '15 at 17:46
  • 1
    Maybe you should just use something like http://www.liquibase.org/ to keep your databases aligned rather than writing your own implementation – tim_yates Apr 13 '15 at 20:29

0 Answers0