Skip to content

Commit 96d938d

Browse files
committed
[2.x] Refactor migrations
1 parent d95a6de commit 96d938d

15 files changed

+59
-326
lines changed

updates/create_channels_table.php updates/000001_create_channels.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
use Schema;
44
use October\Rain\Database\Updates\Migration;
55

6-
class CreateChannelsTable extends Migration
6+
return new class extends Migration
77
{
88
public function up()
99
{
10-
Schema::create('rainlab_forum_channels', function($table)
11-
{
12-
$table->engine = 'InnoDB';
10+
Schema::create('rainlab_forum_channels', function($table) {
1311
$table->increments('id');
1412
$table->integer('parent_id')->unsigned()->index()->nullable();
1513
$table->string('title')->nullable();
@@ -20,6 +18,10 @@ public function up()
2018
$table->integer('nest_depth')->nullable();
2119
$table->integer('count_topics')->default(0);
2220
$table->integer('count_posts')->default(0);
21+
$table->boolean('is_hidden')->default(0);
22+
$table->boolean('is_moderated')->default(0);
23+
$table->boolean('is_guarded')->default(0);
24+
$table->string('embed_code')->nullable()->index();
2325
$table->timestamps();
2426
});
2527
}
@@ -28,4 +30,4 @@ public function down()
2830
{
2931
Schema::dropIfExists('rainlab_forum_channels');
3032
}
31-
}
33+
};

updates/create_posts_table.php updates/000002_create_posts.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
use Schema;
44
use October\Rain\Database\Updates\Migration;
55

6-
class CreatePostsTable extends Migration
6+
return new class extends Migration
77
{
88
public function up()
99
{
10-
Schema::create('rainlab_forum_posts', function($table)
11-
{
12-
$table->engine = 'InnoDB';
10+
Schema::create('rainlab_forum_posts', function($table) {
1311
$table->increments('id');
1412
$table->string('subject')->nullable();
1513
$table->text('content')->nullable();
1614
$table->text('content_html')->nullable();
15+
$table->integer('count_links')->default(0);
1716
$table->integer('topic_id')->unsigned()->index()->nullable();
1817
$table->integer('member_id')->unsigned()->index()->nullable();
1918
$table->integer('edit_user_id')->nullable();
@@ -26,4 +25,4 @@ public function down()
2625
{
2726
Schema::dropIfExists('rainlab_forum_posts');
2827
}
29-
}
28+
};

updates/create_topics_table.php updates/000003_create_topics.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
use Schema;
44
use October\Rain\Database\Updates\Migration;
55

6-
class CreateTopicsTable extends Migration
6+
return new class extends Migration
77
{
88
public function up()
99
{
10-
Schema::create('rainlab_forum_topics', function($table)
11-
{
12-
$table->engine = 'InnoDB';
10+
Schema::create('rainlab_forum_topics', function($table) {
1311
$table->increments('id');
1412
$table->string('subject')->nullable();
1513
$table->string('slug')->index()->unique();
@@ -23,6 +21,7 @@ public function up()
2321
$table->boolean('is_locked')->index()->default(0);
2422
$table->integer('count_posts')->index()->default(0);
2523
$table->integer('count_views')->index()->default(0);
24+
$table->string('embed_code')->nullable()->index();
2625
$table->index(['is_sticky', 'last_post_at'], 'sticky_post_time');
2726
$table->timestamps();
2827
});
@@ -32,4 +31,4 @@ public function down()
3231
{
3332
Schema::dropIfExists('rainlab_forum_topics');
3433
}
35-
}
34+
};

updates/create_members_table.php updates/000004_create_members.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
use Schema;
44
use October\Rain\Database\Updates\Migration;
55

6-
class CreateMembersTable extends Migration
6+
return new class extends Migration
77
{
88
public function up()
99
{
10-
Schema::create('rainlab_forum_members', function($table)
11-
{
12-
$table->engine = 'InnoDB';
10+
Schema::create('rainlab_forum_members', function($table) {
1311
$table->increments('id');
1412
$table->integer('user_id')->unsigned()->index()->nullable();
1513
$table->string('username')->nullable();
1614
$table->string('slug')->nullable();
1715
$table->integer('count_posts')->index()->default(0);
1816
$table->integer('count_topics')->index()->default(0);
1917
$table->dateTime('last_active_at')->index()->nullable();
18+
$table->boolean('is_moderator')->default(0)->index();
19+
$table->boolean('is_banned')->default(0);
20+
$table->boolean('is_approved')->default(0)->index();
2021
$table->timestamps();
2122
});
2223
}
@@ -25,4 +26,4 @@ public function down()
2526
{
2627
Schema::dropIfExists('rainlab_forum_members');
2728
}
28-
}
29+
};
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php namespace RainLab\Forum\Updates;
2+
3+
use Schema;
4+
use October\Rain\Database\Updates\Migration;
5+
6+
return new class extends Migration
7+
{
8+
public function up()
9+
{
10+
Schema::create('rainlab_forum_topic_followers', function($table) {
11+
$table->integer('topic_id')->unsigned();
12+
$table->integer('member_id')->unsigned();
13+
$table->primary(['topic_id', 'member_id']);
14+
$table->timestamps();
15+
});
16+
}
17+
18+
public function down()
19+
{
20+
Schema::dropIfExists('rainlab_forum_topic_followers');
21+
}
22+
};

updates/add_embed_code.php

-33
This file was deleted.

updates/channels_add_hidden_and_moderated.php

-24
This file was deleted.

updates/create_channel_watches_table.php

-25
This file was deleted.

updates/create_topic_followers_table.php

-50
This file was deleted.

updates/create_topic_watches_table.php

-25
This file was deleted.

updates/drop_watches_tables.php

-18
This file was deleted.

updates/members_add_mod_and_ban.php

-24
This file was deleted.

0 commit comments

Comments
 (0)