Skip to content

Commit

Permalink
[2.x] Refactor migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed May 6, 2024
1 parent d95a6de commit 96d938d
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateChannelsTable extends Migration
return new class extends Migration
{
public function up()
{
Schema::create('rainlab_forum_channels', function($table)
{
$table->engine = 'InnoDB';
Schema::create('rainlab_forum_channels', function($table) {
$table->increments('id');
$table->integer('parent_id')->unsigned()->index()->nullable();
$table->string('title')->nullable();
Expand All @@ -20,6 +18,10 @@ public function up()
$table->integer('nest_depth')->nullable();
$table->integer('count_topics')->default(0);
$table->integer('count_posts')->default(0);
$table->boolean('is_hidden')->default(0);
$table->boolean('is_moderated')->default(0);
$table->boolean('is_guarded')->default(0);
$table->string('embed_code')->nullable()->index();
$table->timestamps();
});
}
Expand All @@ -28,4 +30,4 @@ public function down()
{
Schema::dropIfExists('rainlab_forum_channels');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
use Schema;
use October\Rain\Database\Updates\Migration;

class CreatePostsTable extends Migration
return new class extends Migration
{
public function up()
{
Schema::create('rainlab_forum_posts', function($table)
{
$table->engine = 'InnoDB';
Schema::create('rainlab_forum_posts', function($table) {
$table->increments('id');
$table->string('subject')->nullable();
$table->text('content')->nullable();
$table->text('content_html')->nullable();
$table->integer('count_links')->default(0);
$table->integer('topic_id')->unsigned()->index()->nullable();
$table->integer('member_id')->unsigned()->index()->nullable();
$table->integer('edit_user_id')->nullable();
Expand All @@ -26,4 +25,4 @@ public function down()
{
Schema::dropIfExists('rainlab_forum_posts');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateTopicsTable extends Migration
return new class extends Migration
{
public function up()
{
Schema::create('rainlab_forum_topics', function($table)
{
$table->engine = 'InnoDB';
Schema::create('rainlab_forum_topics', function($table) {
$table->increments('id');
$table->string('subject')->nullable();
$table->string('slug')->index()->unique();
Expand All @@ -23,6 +21,7 @@ public function up()
$table->boolean('is_locked')->index()->default(0);
$table->integer('count_posts')->index()->default(0);
$table->integer('count_views')->index()->default(0);
$table->string('embed_code')->nullable()->index();
$table->index(['is_sticky', 'last_post_at'], 'sticky_post_time');
$table->timestamps();
});
Expand All @@ -32,4 +31,4 @@ public function down()
{
Schema::dropIfExists('rainlab_forum_topics');
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
use Schema;
use October\Rain\Database\Updates\Migration;

class CreateMembersTable extends Migration
return new class extends Migration
{
public function up()
{
Schema::create('rainlab_forum_members', function($table)
{
$table->engine = 'InnoDB';
Schema::create('rainlab_forum_members', function($table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index()->nullable();
$table->string('username')->nullable();
$table->string('slug')->nullable();
$table->integer('count_posts')->index()->default(0);
$table->integer('count_topics')->index()->default(0);
$table->dateTime('last_active_at')->index()->nullable();
$table->boolean('is_moderator')->default(0)->index();
$table->boolean('is_banned')->default(0);
$table->boolean('is_approved')->default(0)->index();
$table->timestamps();
});
}
Expand All @@ -25,4 +26,4 @@ public function down()
{
Schema::dropIfExists('rainlab_forum_members');
}
}
};
22 changes: 22 additions & 0 deletions updates/000005_create_topic_followers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php namespace RainLab\Forum\Updates;

use Schema;
use October\Rain\Database\Updates\Migration;

return new class extends Migration
{
public function up()
{
Schema::create('rainlab_forum_topic_followers', function($table) {
$table->integer('topic_id')->unsigned();
$table->integer('member_id')->unsigned();
$table->primary(['topic_id', 'member_id']);
$table->timestamps();
});
}

public function down()
{
Schema::dropIfExists('rainlab_forum_topic_followers');
}
};
33 changes: 0 additions & 33 deletions updates/add_embed_code.php

This file was deleted.

24 changes: 0 additions & 24 deletions updates/channels_add_hidden_and_moderated.php

This file was deleted.

25 changes: 0 additions & 25 deletions updates/create_channel_watches_table.php

This file was deleted.

50 changes: 0 additions & 50 deletions updates/create_topic_followers_table.php

This file was deleted.

25 changes: 0 additions & 25 deletions updates/create_topic_watches_table.php

This file was deleted.

18 changes: 0 additions & 18 deletions updates/drop_watches_tables.php

This file was deleted.

24 changes: 0 additions & 24 deletions updates/members_add_mod_and_ban.php

This file was deleted.

Loading

0 comments on commit 96d938d

Please sign in to comment.