141 lines
3.7 KiB
PHP
141 lines
3.7 KiB
PHP
<?php
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Sakura\DB;
|
|
|
|
class StaticForumStats extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
$schema = DB::getSchemaBuilder();
|
|
|
|
$schema->table('forums', function (Blueprint $table) {
|
|
$table->integer('forum_count_topics')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('forum_count_posts')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('last_post_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->string('last_post_title')
|
|
->nullable()
|
|
->default(null);
|
|
|
|
$table->integer('last_post_time')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('last_post_user_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->string('last_post_username')
|
|
->nullable()
|
|
->default(null);
|
|
|
|
$table->string('last_post_user_colour')
|
|
->nullable()
|
|
->default(null);
|
|
});
|
|
|
|
$schema->table('topics', function (Blueprint $table) {
|
|
$table->integer('topic_replies')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('post_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('user_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->string('first_post_username')
|
|
->nullable()
|
|
->default(null);
|
|
|
|
$table->string('first_post_user_colour')
|
|
->nullable()
|
|
->default(null);
|
|
|
|
$table->integer('last_post_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('last_post_user_id')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->string('last_post_username')
|
|
->nullable()
|
|
->default(null);
|
|
|
|
$table->string('last_post_user_colour')
|
|
->nullable()
|
|
->default(null);
|
|
});
|
|
|
|
$schema->table('users', function (Blueprint $table) {
|
|
$table->integer('user_count_topics')
|
|
->unsigned()
|
|
->default(0);
|
|
|
|
$table->integer('user_count_posts')
|
|
->unsigned()
|
|
->default(0);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
$schema = DB::getSchemaBuilder();
|
|
|
|
$schema->table('users', function (Blueprint $table) {
|
|
$table->dropColumn([
|
|
'user_count_topics',
|
|
'user_count_posts',
|
|
]);
|
|
});
|
|
|
|
$schema->table('topics', function (Blueprint $table) {
|
|
$table->dropColumn([
|
|
'topic_replies',
|
|
'post_id',
|
|
'user_id',
|
|
'first_post_username',
|
|
'first_post_user_colour',
|
|
'last_post_id',
|
|
'last_post_user_id',
|
|
'last_post_username',
|
|
'last_post_user_colour',
|
|
]);
|
|
});
|
|
|
|
$schema->table('forums', function (Blueprint $table) {
|
|
$table->dropColumn([
|
|
'forum_count_topics',
|
|
'forum_count_posts',
|
|
'last_post_id',
|
|
'last_post_title',
|
|
'last_post_time',
|
|
'last_post_user_id',
|
|
'last_post_username',
|
|
'last_post_user_colour',
|
|
]);
|
|
});
|
|
}
|
|
}
|