Add migrations that were missed for some reason

This commit is contained in:
DariusIII
2024-04-28 15:32:46 +02:00
parent e0f5174519
commit ffadd3e78a
18 changed files with 623 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateForumTableCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('forum_categories')) {
Schema::create('forum_categories', function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_category')->unsigned();
$table->string('title');
$table->string('subtitle');
$table->integer('weight');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('forum_categories');
}
}
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateForumTableThreads extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('forum_threads')) {
Schema::create('forum_threads', function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_category')->unsigned();
$table->foreignIdFor(config('forum.integration.user_model'), 'author_id');
$table->string('title');
$table->boolean('pinned');
$table->boolean('locked');
$table->timestamps();
$table->softDeletes();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('forum_threads');
}
}
@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateForumTablePosts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('forum_posts')) {
Schema::create('forum_posts', function (Blueprint $table) {
$table->increments('id');
$table->integer('parent_thread')->unsigned();
$table->foreignIdFor(config('forum.integration.user_model'), 'author_id');
$table->text('content');
$table->timestamps();
$table->softDeletes();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('forum_posts');
}
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateForumTableThreadsRead extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('forum_threads_read')) {
Schema::create('forum_threads_read', function (Blueprint $table) {
$table->integer('thread_id')->unsigned();
$table->foreignIdFor(config('forum.integration.user_model'), 'user_id');
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('forum_threads_read');
}
}
@@ -0,0 +1,49 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateForumTableCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
if (!Schema::hasColumn('forum_categories', 'category_id')) {
$table->renameColumn('parent_category', 'category_id');
}
if (!Schema::hasColumn('forum_categories', 'description')) {
$table->renameColumn('subtitle', 'description');
}
});
Schema::table('forum_categories', function (Blueprint $table) {
$table->integer('category_id')->default(0)->change();
$table->string('description')->nullable()->change();
$table->integer('weight')->default(0)->change();
$table->boolean('enable_threads')->default(0);
$table->boolean('private')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->renameColumn('category_id', 'parent_category');
$table->dropColumn(['created_at', 'updated_at', 'enable_threads', 'private']);
$table->renameColumn('description', 'subtitle');
});
}
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateForumTableThreads extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->renameColumn('parent_category', 'category_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->renameColumn('category_id', 'parent_category');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UpdateForumTablePosts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_posts', function (Blueprint $table) {
$table->renameColumn('parent_thread', 'thread_id');
$table->integer('post_id')->after('content')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_posts', function (Blueprint $table) {
$table->renameColumn('thread_id', 'parent_thread');
});
}
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddDefaultsToForumTableThreadsColumns extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->boolean('pinned')->nullable()->default(0)->change();
$table->boolean('locked')->nullable()->default(0)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->boolean('pinned')->nullable(false)->default(null)->change();
$table->boolean('locked')->nullable(false)->default(null)->change();
});
}
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddCountsToCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
// Add increments to the thread and post counts on the categories table
$table->integer('post_count')->after('enable_threads')->default(0);
$table->integer('thread_count')->after('enable_threads')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->dropColumn(['thread_count', 'post_count']);
});
}
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddCountsToThreadsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->integer('reply_count')->after('locked')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->dropColumn('reply_count');
});
}
}
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddSequenceToPostsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_posts', function (Blueprint $table) {
$table->integer('sequence')->after('post_id')->unsigned()->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_posts', function (Blueprint $table) {
$table->dropColumn('sequence');
});
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->nestedSet();
$table->dropColumn(['category_id', 'weight']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->dropNestedSet();
$table->integer('category_id')->unsigned();
$table->integer('weight');
});
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateForumCategoryBooleans extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->renameColumn('enable_threads', 'accepts_threads');
$table->renameColumn('private', 'is_private');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->renameColumn('accepts_threads', 'enable_threads');
$table->renameColumn('is_private', 'private');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColorToCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->string('color')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->dropColumn('color');
});
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddThreadIdsToCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->integer('newest_thread_id')->after('accepts_threads')->unsigned()->nullable();
$table->integer('latest_active_thread_id')->after('newest_thread_id')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_categories', function (Blueprint $table) {
$table->dropColumn('newest_thread_id');
$table->dropColumn('latest_active_thread_id');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPostIdToThreads extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->integer('last_post_id')->after('locked')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->dropColumn('last_post_id');
});
}
}
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFirstPostIdToThreads extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->integer('first_post_id')->after('locked')->unsigned()->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->dropColumn('first_post_id');
});
}
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFkIndices extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->index('category_id');
});
Schema::table('forum_posts', function (Blueprint $table) {
$table->index('thread_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('forum_threads', function (Blueprint $table) {
$table->dropIndex('forum_threads_category_id_index');
});
Schema::table('forum_posts', function (Blueprint $table) {
$table->dropIndex('forum_posts_thread_id_index');
});
}
}