Migrate.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Schema\Wrapper as Wrapper;
  3. use App\Core\Sanity\MigratorController as Migrator;
  4. function geo_country_upgrade($pluginversion) {
  5. if ($pluginversion < "0.0.1") {
  6. $table = Wrapper::get_table("geo_countries");
  7. $table->addSoftDelete();
  8. $table->addColumn("name", "string", Array("null" => false));
  9. $table->addColumn("description", "string", Array("null" => true));
  10. $table->addColumn("code", "integer", Array("null" => false));
  11. $table->addColumn("iso2", "string", Array("null" => false, 'limit' => 2));
  12. $table->addColumn("iso3", "string", Array("null" => false, 'limit' => 3));
  13. $table->save();
  14. Wrapper::exec(file_get_contents(__DIR__.'/001_countries_seeding.sql') );
  15. Migrator::getInstance()->update_plugin_version("geo_country", "1.0.0");
  16. return;
  17. }
  18. //if ($pluginversion < "0.0.2") {
  19. //$table = Wrapper::get_table("geo_country");
  20. //Migrator::getInstance()->update_plugin_version("geo_country", "1.0.1");
  21. //return;
  22. //}
  23. }
  24. function geo_country_rollback($pluginversion) {
  25. if($pluginversion > "0.0.1"){
  26. $table = Wrapper::get_table("geo_countries");
  27. $table->drop();
  28. return;
  29. }
  30. }