A set of plugins to help on managing geographic information
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Schema\Wrapper as Wrapper;
|
||||
use App\Core\Sanity\MigratorController as Migrator;
|
||||
|
||||
function geo_state_upgrade($pluginversion) {
|
||||
if ($pluginversion < "0.0.1") {
|
||||
$table = Wrapper::get_table("geo_states");
|
||||
$table->addColumn("country_id", "integer", Array("null" => false));
|
||||
$table->addColumn("name", "string", Array("null" => false));
|
||||
$table->addColumn("code", "integer", Array("null" => true));
|
||||
$table->addColumn("shortname", "string", Array("null" => false, 'limit' => 5));
|
||||
$table->addColumn("description", "string", Array("null" => true));
|
||||
$table->addForeignKey('country_id', Wrapper::get_table('geo_countries'));
|
||||
$table->create();
|
||||
|
||||
Wrapper::exec(file_get_contents(__DIR__.'/001_brazil_states_seeding.sql') );
|
||||
|
||||
Migrator::getInstance()->update_plugin_version("geo_state", "1.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
//if ($pluginversion < "0.0.2") {
|
||||
//$table = Wrapper::get_table("geo_state");
|
||||
//Migrator::getInstance()->update_plugin_version("geo_states", "1.0.1");
|
||||
//return;
|
||||
//}
|
||||
}
|
||||
|
||||
function geo_state_rollback($pluginversion) {
|
||||
if($pluginversion > "0.0.1"){
|
||||
$table = Wrapper::get_table("geo_states");
|
||||
$table->drop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user