39 lines
1.4 KiB
PHP
39 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Schema\Wrapper as Wrapper;
|
|
use App\Core\Sanity\MigratorController as Migrator;
|
|
|
|
function geo_city_upgrade($pluginversion) {
|
|
if ($pluginversion < "0.0.1") {
|
|
$table = Wrapper::get_table("geo_cities");
|
|
$table->addColumn("state_id", "integer", Array("null" => false));
|
|
$table->addColumn("country_id", "integer", Array("null" => false));
|
|
$table->addColumn("code", "integer", Array("null" => true));
|
|
$table->addColumn("name", "string", Array("null" => false));
|
|
$table->addColumn("description", "text", Array("null" => true));
|
|
$table->addTimestamps();
|
|
$table->addSoftDelete();
|
|
$table->addForeignKey('state_id', Wrapper::get_table('geo_states'));
|
|
$table->addForeignKey('country_id', Wrapper::get_table('geo_countries'));
|
|
$table->create();
|
|
|
|
Wrapper::exec(file_get_contents(__DIR__.'/001_seed_rs_cities.sql') );
|
|
|
|
Migrator::getInstance()->update_plugin_version("geo_city", "1.0.0");
|
|
return;
|
|
}
|
|
|
|
//if ($pluginversion < "0.0.2") {
|
|
//$table = Wrapper::get_table("geo_city");
|
|
//Migrator::getInstance()->update_plugin_version("geo_city", "1.0.1");
|
|
//return;
|
|
//}
|
|
}
|
|
|
|
function geo_city_rollback($pluginversion) {
|
|
if($pluginversion > "0.0.1"){
|
|
$table = Wrapper::get_table("geo_cities");
|
|
$table->drop();
|
|
return;
|
|
}
|
|
} |