| <?php |
| class CreateCategoriesTable extends Migration { |
| |
| public function up() |
| { |
| Schema::create('categories', function(Blueprint $table) { |
| $table->increments('id'); |
| $table->integer('forum_id')->unsigned()->nullable(); |
| $table->string('title', 255); |
| $table->text('content'); |
| $table->timestamps(); |
| |
| |
| |
| $table->foreign('forum_id')->references('id')->on('forum'); |
| |
| |
| }); |
| } |
| |
| public function down() |
| { |
| Schema::drop('categories'); |
| } |
| } |
| |
| |
| |
| |
| class CreateTopicsTable extends Migration { |
| |
| public function up() |
| { |
| Schema::create('topics', function(Blueprint $table) { |
| $table->increments('id'); |
| $table->integer('category_id')->unsigned()->nullable(); |
| $table->integer('user_id')->unsigned()->nullable(); |
| $table->string('title', 255); |
| $table->text('content'); |
| $table->timestamps(); |
| |
| |
| $table->foreign('user_id')->references('id')->on('user'); |
| |
| $table->foreign('category_id')->references('id')->on('category'); |
| }); |
| } |
| |
| public function down() |
| { |
| Schema::drop('topics'); |
| } |
| } |
| |
| |
| |
| |
| |
| |
| class CreatePostsTable extends Migration { |
| |
| public function up() |
| { |
| Schema::create('posts', function(Blueprint $table) { |
| $table->increments('id'); |
| $table->integer('topic_id')->unsigned()->nullable(); |
| $table->integer('user_id')->unsigned()->nullable(); |
| $table->text('content'); |
| $table->timestamps(); |
| |
| |
| $table->foreign('topic_id')->references('id')->on('topic'); |
| $table->foreign('user_id')->references('id')->on('user'); |
| }); |
| |
| |
| } |
| |
| public function down() |
| { |
| Schema::drop('posts'); |
| } |
| } |