LPH
Well-known member
A basic addon was written and is being expanded to use the XF database.
Setup.php
At this point, the addon is in the development environment with a route, etc. This new Setup.php file has been written and saved. How do I get this file to run on the development environment and not have things blow up? I don't want to bugger it up since the addon was written without the database first.
Do I go into AdminCP >> Addons and "sync changes" or rebuild?
Setup.php
PHP:
<?php
namespace TRN\XenWriter;
use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;
use XF\Db\Schema\Alter;
use XF\Db\Schema\Create;
class Setup extends AbstractSetup
{
use StepRunnerInstallTrait;
use StepRunnerUpgradeTrait;
use StepRunnerUninstallTrait;
public function installStep1()
{
$schemaManager = $this->schemaManager();
$schemaManager->createTable('xf_xenwriter_document', function (Create $table) {
$table->addColumn('xenwriter_document_id', 'int')->autoIncrement();
$table->addColumn('xenwriter_category_id', 'int')->autoIncrement();
$table->addColumn('parent_category_id', 'int')->setDefault(0);
$table->addColumn('title', 'varchar', 100)->setDefault('');
$table->addColumn('description', 'varchar', 255)->setDefault('');
$table->addColumn('content', 'text');
$table->addColumn('tag_line', 'varchar', 100)->setDefault('');
$table->addColumn('date', 'int');
$table->addColumn('last_update', 'int');
$table->addColumn('user_id', 'int');
$table->addColumn('username', 'varchar', 100)->setDefault('');
$table->addColumn('xenwriter_document_state', 'enum')->values(['visible','moderated','deleted'])->setDefault('visible');
$table->addColumn('prefix_cache', 'mediumblob');
$table->addColumn('require_prefix', 'tinyint')->setDefault(0);
$table->addColumn('thread_prefix_id', 'int')->setDefault(0);
$table->addColumn('thread_node_id', 'int')->setDefault(0);
$table->addColumn('discussion_thread_id', 'int')->comment('Points to an automatically-created thread for this document');
$table->addColumn('rating_count', 'int')->setDefault(0);
$table->addColumn('rating_sum', 'int')->setDefault(0);
$table->addColumn('rating_avg', 'float', '')->setDefault(0);
$table->addColumn('rating_weighted', 'float', '')->setDefault(0);
$table->addPrimaryKey('xenwriter_document_id');
$table->addKey(['xenwriter_category_id', 'last_update'], 'xw_category_last_update');
$table->addKey(['xenwriter_category_id', 'rating_weighted'], 'xw_category_rating_weighted');
$table->addKey('last_update');
$table->addKey('rating_weighted');
$table->addKey(['user_id', 'last_update']);
$table->addKey('thread_prefix_id');
$table->addKey('discussion_thread_id');
});
$tables['xf_xenwriter_document_feature'] = function(Create $table)
{
$table->addColumn('xenwriter_document_id', 'int');
$table->addColumn('feature_date', 'int');
$table->addPrimaryKey('xenwriter_document_id');
$table->addKey('feature_date');
};
}
}
At this point, the addon is in the development environment with a route, etc. This new Setup.php file has been written and saved. How do I get this file to run on the development environment and not have things blow up? I don't want to bugger it up since the addon was written without the database first.
Do I go into AdminCP >> Addons and "sync changes" or rebuild?