/framework/core/zap/ZoneApply.php

http://zoop.googlecode.com/ · PHP · 37 lines · 25 code · 8 blank · 4 comment · 0 complexity · 0e56a92c95d31306c6ee32263df443b5 MD5 · raw file

  1. <?php
  2. class ZoneApply
  3. {
  4. function subMigrations($p, $s)
  5. {
  6. SqlBeginTransaction();
  7. // make sure the migrations table exists
  8. Migration::initDB();
  9. // have it scan the migrations directory for all available migrations
  10. $versions = Migration::getAllMigrationNames();
  11. // query the db for applied migrations
  12. $applied = Migration::getAllAppiedMigrationNames();
  13. // apply anything that hasn't been done yet, in the proper order
  14. $unapplied = array_diff($versions, $applied);
  15. foreach($unapplied as $key => $needsApplied)
  16. {
  17. Migration::apply($key, $needsApplied);
  18. }
  19. SqlCommitTransaction();
  20. }
  21. function subMigration($p, $s)
  22. {
  23. $version = $p[3];
  24. SqlBeginTransaction();
  25. $filename = Migration::filenameFromVersion($version);
  26. Migration::apply($filename, $version);
  27. SqlCommitTransaction();
  28. }
  29. }