]> git.localhorst.tv Git - alttp.git/blob - database/migrations/2022_04_09_120955_tournament_application.php
open tournament type
[alttp.git] / database / migrations / 2022_04_09_120955_tournament_application.php
1 <?php
2
3 use Illuminate\Database\Migrations\Migration;
4 use Illuminate\Database\Schema\Blueprint;
5 use Illuminate\Support\Facades\Schema;
6
7 return new class extends Migration
8 {
9         /**
10          * Run the migrations.
11          *
12          * @return void
13          */
14         public function up()
15         {
16                 Schema::create('applications', function (Blueprint $table) {
17                         $table->id();
18                         $table->foreignId('tournament_id')->constrained();
19                         $table->foreignId('user_id')->constrained();
20                         $table->boolean('denied')->default(false);
21                         $table->timestamps();
22
23                         $table->unique(['tournament_id', 'user_id']);
24                 });
25                 Schema::table('tournaments', function(Blueprint $table) {
26                         $table->boolean('accept_applications')->default(false);
27                 });
28                 Schema::table('participants', function(Blueprint $table) {
29                         $table->unique(['tournament_id', 'user_id']);
30                 });
31         }
32
33         /**
34          * Reverse the migrations.
35          *
36          * @return void
37          */
38         public function down()
39         {
40                 Schema::table('tournaments', function(Blueprint $table) {
41                         $table->dropColumn('accept_applications');
42                 });
43                 Schema::dropIfExists('applications');
44         }
45 };