Skip to content

Instantly share code, notes, and snippets.

@Cyberiaaxis
Created November 12, 2017 07:37
Show Gist options
  • Save Cyberiaaxis/69eed7f6684884ff39c00b6c5b4bc2d6 to your computer and use it in GitHub Desktop.
Save Cyberiaaxis/69eed7f6684884ff39c00b6c5b4bc2d6 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateQuestionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('questions', function (Blueprint $table) {
$table->increments('id');
$table->integer('topic_id')->unsigned()->nullable();
$table->foreign('topic_id', 'fk_256_topic_topic_id_question')->references('id')->on('topics');
$table->integer('category_id')->unsigned();
$table->foreign('category_id', 'questions_category_id_foreign')->references('id')->on('category');
$table->text('question_text')->nullable();
$table->text('code_snippet')->nullable();
$table->text('answer_explanation')->nullable();
$table->string('more_info_link')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['deleted_at']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('questions', function(Blueprint $table) {
$table->dropForeign('questions_category_id_foreign');
$table->dropForeign('questions_topic_id_foreign');
});
Schema::dropIfExists('questions');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment