File size: 1.51Kb
<?php
namespace Andy\ShowMap;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;
class Setup extends AbstractSetup
{
use StepRunnerUpgradeTrait;
public function install(array $stepParams = [])
{
$this->schemaManager()->createTable('xf_andy_show_map', function(Create $table)
{
$table->addColumn('show_map_id', 'int')->autoIncrement();
$table->addColumn('category_id', 'text');
$table->addColumn('description', 'text');
$table->addColumn('coordinates', 'text');
$table->addColumn('zoom', 'int');
});
$this->schemaManager()->createTable('xf_andy_show_map_data', function(Create $table)
{
$table->addColumn('show_map_data_id', 'int')->autoIncrement();
$table->addColumn('thread_id', 'int');
$table->addColumn('category_id', 'text');
$table->addColumn('coordinates', 'text');
});
}
public function upgrade(array $stepParams = [])
{
if ($this->addOn->version_id < 11)
{
$this->schemaManager()->alterTable('xf_andy_show_map', function(Alter $alter)
{
$alter->renameColumn('description', 'category_id');
$alter->renameColumn('detail', 'description');
});
$this->schemaManager()->alterTable('xf_andy_show_map_data', function(Alter $alter)
{
$alter->renameColumn('description', 'category_id');
});
}
}
public function uninstall(array $stepParams = [])
{
$this->schemaManager()->dropTable('xf_andy_show_map');
$this->schemaManager()->dropTable('xf_andy_show_map_data');
}
}