<?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();
            
            // defining foreign
            
            $table->foreign('forum_id')->references('id')->on('forum'); // if there is forum table or something like that on the database
            
            
        });
    }
     
        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();

                // defining foreing
                $table->foreign('user_id')->references('id')->on('user'); // if there is user table or something like that on the database

                $table->foreign('category_id')->references('id')->on('category'); // if there is category table or something like that on the database
            });
        }
     
        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();
                
                 // defining
                $table->foreign('topic_id')->references('id')->on('topic'); // if there is topic table or something like that on the database
                $table->foreign('user_id')->references('id')->on('user'); // if there is user table or something like that on the database
            });

           
        }
     
        public function down()
        {
            Schema::drop('posts');
        }
    }