fork download
  1. class Ideone {
  2. public static void onUpgrade(int oldVersion, int newVersion) {
  3. System.out.println(String.format("***from %d to %d***", oldVersion, newVersion));
  4. switch (oldVersion) {
  5. case 10: // from 10 to 11 and go to next case
  6. System.out.println(" TABLE_MAIN_UPGRADE_10_11");
  7. case 11: // from 11 to 12 and go to next case
  8. System.out.println(" TABLE_MAIN_UPGRADE_11_12");
  9. case 12: // from 12 to 13 and go to next case
  10. System.out.println(" TABLE_MAIN_UPGRADE_12_13");
  11. case 13: // from 13 to newVersion
  12. System.out.println(" TABLE_MAIN_UPGRADE_13_14");
  13. break;
  14. default:
  15. System.out.println(" DROP AND CREATE");
  16. break;
  17. }
  18. }
  19.  
  20. public static void main(String[] args) throws java.lang.Exception {
  21. int newVersion = 14;
  22. for (int i = 5; i < newVersion; i++)
  23. onUpgrade(i, newVersion);
  24. }
  25. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
***from 5 to 14***
	DROP AND CREATE
***from 6 to 14***
	DROP AND CREATE
***from 7 to 14***
	DROP AND CREATE
***from 8 to 14***
	DROP AND CREATE
***from 9 to 14***
	DROP AND CREATE
***from 10 to 14***
	TABLE_MAIN_UPGRADE_10_11
	TABLE_MAIN_UPGRADE_11_12
	TABLE_MAIN_UPGRADE_12_13
	TABLE_MAIN_UPGRADE_13_14
***from 11 to 14***
	TABLE_MAIN_UPGRADE_11_12
	TABLE_MAIN_UPGRADE_12_13
	TABLE_MAIN_UPGRADE_13_14
***from 12 to 14***
	TABLE_MAIN_UPGRADE_12_13
	TABLE_MAIN_UPGRADE_13_14
***from 13 to 14***
	TABLE_MAIN_UPGRADE_13_14