![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/dceprojects.corals.io/Corals/modules/Survey/database/migrations/ |
<?php namespace Corals\Modules\Survey\database\migrations; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class SurveysTables extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('surv_surveys', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('description')->nullable(); $table->string('status')->default('active'); $table->text('properties')->nullable(); $table->unsignedInteger('created_by')->nullable()->index(); $table->unsignedInteger('updated_by')->nullable()->index(); $table->softDeletes(); $table->timestamps(); }); Schema::create('surv_questions', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('title'); $table->string('description')->nullable(); $table->string('type'); $table->string('status')->default('active'); $table->text('properties')->nullable(); $table->unsignedBigInteger('next_question_id')->nullable(); $table->foreign('next_question_id') ->references('id') ->on('surv_questions') ->onDelete('cascade') ->onUpdate('cascade'); $table->unsignedInteger('created_by')->nullable()->index(); $table->unsignedInteger('updated_by')->nullable()->index(); $table->softDeletes(); $table->timestamps(); }); Schema::create('surv_answers', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('text'); $table->decimal('score'); $table->integer('order'); $table->unsignedBigInteger('next_question_id')->nullable(); $table->unsignedBigInteger('question_id'); $table->foreign('question_id') ->references('id') ->on('surv_questions') ->onDelete('cascade') ->onUpdate('cascade'); $table->foreign('next_question_id') ->references('id') ->on('surv_questions') ->onDelete('cascade') ->onUpdate('cascade'); $table->string('status')->default('active'); $table->text('properties')->nullable(); $table->unsignedInteger('created_by')->nullable()->index(); $table->unsignedInteger('updated_by')->nullable()->index(); $table->softDeletes(); $table->timestamps(); }); Schema::create('surv_question_survey', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('survey_id'); $table->unsignedBigInteger('question_id'); $table->integer('order'); $table->foreign('survey_id') ->references('id') ->on('surv_surveys') ->onDelete('cascade') ->onUpdate('cascade'); $table->foreign('question_id') ->references('id') ->on('surv_questions') ->onDelete('cascade') ->onUpdate('cascade'); }); Schema::create('surv_responses', function (Blueprint $table) { $table->bigIncrements('id'); $table->morphs('user'); $table->unsignedBigInteger('survey_id'); $table->unsignedBigInteger('question_id'); $table->unsignedBigInteger('answer_id')->nullable(); $table->string('question_title'); $table->string('answer_text'); $table->decimal('score')->nullable(); $table->foreign('survey_id') ->references('id') ->on('surv_surveys') ->onDelete('cascade') ->onUpdate('cascade'); $table->foreign('question_id') ->references('id') ->on('surv_questions') ->onDelete('cascade') ->onUpdate('cascade'); $table->foreign('answer_id') ->references('id') ->on('surv_answers') ->onDelete('cascade') ->onUpdate('cascade'); $table->text('properties')->nullable(); $table->unsignedInteger('created_by')->nullable()->index(); $table->unsignedInteger('updated_by')->nullable()->index(); $table->softDeletes(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('surv_surveys'); Schema::dropIfExists('surv_questions'); Schema::dropIfExists('surv_answers'); Schema::dropIfExists('surv_question_survey'); Schema::dropIfExists('surv_responses'); } }