From f514c4f84837f00a343d456a81e9f20f860e948a Mon Sep 17 00:00:00 2001 From: Miguel N Date: Wed, 29 Apr 2020 21:16:05 +0100 Subject: [PATCH] Optimize tables --- ...04_29_022402_create_applications_table.php | 2 +- .../2020_04_29_022421_create_votes_table.php | 7 ++++ ...04_29_022442_create_appointments_table.php | 2 +- .../2020_04_29_023554_create_logs_table.php | 32 ---------------- ...020_04_29_195848_votes_has_application.php | 38 +++++++++++++++++++ 5 files changed, 47 insertions(+), 34 deletions(-) delete mode 100644 database/migrations/2020_04_29_023554_create_logs_table.php create mode 100644 database/migrations/2020_04_29_195848_votes_has_application.php diff --git a/database/migrations/2020_04_29_022402_create_applications_table.php b/database/migrations/2020_04_29_022402_create_applications_table.php index 25adbb6..0a69e3a 100644 --- a/database/migrations/2020_04_29_022402_create_applications_table.php +++ b/database/migrations/2020_04_29_022402_create_applications_table.php @@ -28,7 +28,7 @@ class CreateApplicationsTable extends Migration 'STAGE_INTERVIEW', 'APPROVED', 'DENIED' - ]); + ])->default('STAGE_SUBMITTED'); $table->timestamps(); }); } diff --git a/database/migrations/2020_04_29_022421_create_votes_table.php b/database/migrations/2020_04_29_022421_create_votes_table.php index ebe6980..6c72fc6 100644 --- a/database/migrations/2020_04_29_022421_create_votes_table.php +++ b/database/migrations/2020_04_29_022421_create_votes_table.php @@ -15,7 +15,14 @@ class CreateVotesTable extends Migration { Schema::create('votes', function (Blueprint $table) { $table->id(); + $table->bigInteger('userID')->unsigned(); + $table->enum('allowedVoteType', [ + 'VOTE_DENY', + 'VOTE_APPROVE' + ]); $table->timestamps(); + + $table->foreign('userID')->references('id')->on('users'); }); } diff --git a/database/migrations/2020_04_29_022442_create_appointments_table.php b/database/migrations/2020_04_29_022442_create_appointments_table.php index 9dbeb89..e95df27 100644 --- a/database/migrations/2020_04_29_022442_create_appointments_table.php +++ b/database/migrations/2020_04_29_022442_create_appointments_table.php @@ -29,7 +29,7 @@ class CreateAppointmentsTable extends Migration 'SCHEDULED', 'CONCLUDED' ])->default('SCHEDULED'); - $table->text('meetingNotes'); + $table->text('meetingNotes')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2020_04_29_023554_create_logs_table.php b/database/migrations/2020_04_29_023554_create_logs_table.php deleted file mode 100644 index c797cf1..0000000 --- a/database/migrations/2020_04_29_023554_create_logs_table.php +++ /dev/null @@ -1,32 +0,0 @@ -id(); - $table->bigIncrements('userID'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('logs'); - } -} diff --git a/database/migrations/2020_04_29_195848_votes_has_application.php b/database/migrations/2020_04_29_195848_votes_has_application.php new file mode 100644 index 0000000..dfa00aa --- /dev/null +++ b/database/migrations/2020_04_29_195848_votes_has_application.php @@ -0,0 +1,38 @@ +id('id'); + $table->bigInteger('vote_id')->unsigned(); + $table->bigInteger('application_id')->unsigned(); + $table->timestamps(); + + $table->foreign('vote_id')->references('id')->on('votes'); + $table->foreign('application_id')->references('id')->on('applications'); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}