Migrate.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Schema\Wrapper as Wrapper;
  3. use App\Core\Sanity\MigratorController as Migrator;
  4. //https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-types
  5. function common_glossary_upgrade($pluginversion) {
  6. if ($pluginversion < "0.0.1") {
  7. $table = Wrapper::get_table("common_glossarys");
  8. $table->addColumn("area_id", "integer", Array("null" => false));
  9. $table->addColumn("name", "string", Array("null" => false));
  10. $table->addColumn("description", "text", Array("null" => true));
  11. //$table->addColumn("time", "timestamp", Array("null" => true, "default"=>null));
  12. $table->addTimestamps();
  13. $table->addSoftDelete();
  14. $table->create();
  15. Migrator::getInstance()->update_plugin_version("common_glossary", "1.0.0");
  16. return;
  17. }
  18. //if ($pluginversion < "0.0.2") {
  19. //$table = Wrapper::get_table("common_glossarys");
  20. //Migrator::getInstance()->update_plugin_version("common_glossary", "1.0.1");
  21. //return;
  22. //}
  23. }
  24. function common_glossary_rollback($pluginversion) {
  25. if($pluginversion > "0.0.1"){
  26. $table = Wrapper::get_table("common_glossarys");
  27. $table->drop();
  28. return;
  29. }
  30. }