Migrate.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use Schema\Wrapper as Wrapper;
  3. use App\Core\Sanity\MigratorController as Migrator;
  4. function common_files_upgrade($pluginversion) {
  5. if ($pluginversion < "0.0.1") {
  6. $table = Wrapper::get_table("common_filess");
  7. $table->addColumn("name", "string", Array("null" => false));
  8. $table->addColumn("time", "timestamp", Array("null" => true, "default"=>null));
  9. $table->addColumn("areaid", "integer", Array("null" => false));
  10. $table->addTimestamps();
  11. $table->addSoftDelete();
  12. $table->create();
  13. Migrator::getInstance()->update_plugin_version("common_files", "1.0.0");
  14. return;
  15. }
  16. //if ($pluginversion < "0.0.2") {
  17. //$table = Wrapper::get_table("common_filess");
  18. //Migrator::getInstance()->update_plugin_version("common_files", "1.0.1");
  19. //return;
  20. //}
  21. }
  22. function common_files_rollback($pluginversion) {
  23. if($pluginversion > "0.0.1"){
  24. $table = Wrapper::get_table("common_filess");
  25. $table->drop();
  26. return;
  27. }
  28. }