| @@ 6-29 (lines=24) @@ | ||
| 3 | use Illuminate\Database\Schema\Blueprint; |
|
| 4 | use Illuminate\Database\Migrations\Migration; |
|
| 5 | ||
| 6 | class CreateForumPostsTable extends Migration |
|
| 7 | { |
|
| 8 | public function up() |
|
| 9 | { |
|
| 10 | if (!Schema::hasTable('forum_posts')) { |
|
| 11 | Schema::create('forum_posts', function ($table) { |
|
| 12 | $table->increments('id'); |
|
| 13 | $table->string('title'); |
|
| 14 | $table->string('body', 4000); |
|
| 15 | $table->integer('forum_id')->unsigned(); |
|
| 16 | $table->foreign('forum_id') |
|
| 17 | ->references('id')->on('forums') |
|
| 18 | ->onDelete('cascade'); |
|
| 19 | $table->integer('author_id'); |
|
| 20 | $table->timestamps(); |
|
| 21 | }); |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| 25 | public function down() |
|
| 26 | { |
|
| 27 | Schema::dropIfExists('forum_posts'); |
|
| 28 | } |
|
| 29 | } |
|
| 30 | ||
| @@ 6-28 (lines=23) @@ | ||
| 3 | use Illuminate\Database\Schema\Blueprint; |
|
| 4 | use Illuminate\Database\Migrations\Migration; |
|
| 5 | ||
| 6 | class CreateForumPostRepliesTable extends Migration |
|
| 7 | { |
|
| 8 | public function up() |
|
| 9 | { |
|
| 10 | if (!Schema::hasTable('forum_post_replies')) { |
|
| 11 | Schema::create('forum_post_replies', function ($table) { |
|
| 12 | $table->increments('id'); |
|
| 13 | $table->string('body', 4000); |
|
| 14 | $table->integer('post_id')->unsigned(); |
|
| 15 | $table->foreign('post_id') |
|
| 16 | ->references('id')->on('forum_posts') |
|
| 17 | ->onDelete('cascade'); |
|
| 18 | $table->integer('author_id'); |
|
| 19 | $table->timestamps(); |
|
| 20 | }); |
|
| 21 | } |
|
| 22 | } |
|
| 23 | ||
| 24 | public function down() |
|
| 25 | { |
|
| 26 | Schema::dropIfExists('forum_post_replies'); |
|
| 27 | } |
|
| 28 | } |
|
| 29 | ||