1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Support\Carbon; |
6
|
|
|
use Xoco70\LaravelTournaments\DBHelpers; |
7
|
|
|
|
8
|
|
|
class CreateLtTournamentTable extends Migration |
9
|
|
|
{ |
10
|
|
|
public function up() |
11
|
|
|
{ |
12
|
|
|
Schema::create('tournament', function (Blueprint $table) { |
13
|
|
|
$table->increments('id'); |
14
|
|
|
//TODO Added ->nullable() to solve FK issue with Sqlite :( |
15
|
|
|
$table->Integer('user_id')->unsigned()->nullable()->index(); |
16
|
|
|
$table->foreign('user_id') |
17
|
|
|
->references('id') |
18
|
|
|
->on('users') |
19
|
|
|
->onUpdate('cascade') |
20
|
|
|
->onDelete('cascade'); |
21
|
|
|
|
22
|
|
|
$table->string('name'); |
23
|
|
|
$table->string('slug')->unique(); |
24
|
|
|
$table->date('dateIni'); |
25
|
|
|
$table->date('dateFin'); |
26
|
|
|
$table->date('registerDateLimit')->nullable()->default(Carbon::now()->addMonth(1)); |
27
|
|
|
$table->integer('sport')->unsigned()->default(1); |
28
|
|
|
$table->string('promoter')->nullable(); |
29
|
|
|
$table->string('host_organization')->nullable(); |
30
|
|
|
$table->string('technical_assistance')->nullable(); |
31
|
|
|
$table->integer('rule_id')->default(1); |
32
|
|
|
$table->tinyInteger('type')->default(1); // 1= local, 2= state, 3= national, 4=continent, 5=world |
33
|
|
|
$table->integer('venue_id')->nullable()->unsigned(); |
34
|
|
|
$table->integer('level_id')->unsigned()->nullable()->default(1); // TODO nullable ??? |
35
|
|
|
|
36
|
|
|
$table->foreign('venue_id') |
37
|
|
|
->references('id') |
38
|
|
|
->on('venue'); |
39
|
|
|
|
40
|
|
|
$table->timestamps(); |
41
|
|
|
$table->softDeletes(); |
42
|
|
|
$table->engine = 'InnoDB'; |
43
|
|
|
}); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function down() |
47
|
|
|
{ |
48
|
|
|
DBHelpers::setFKCheckOff(); |
49
|
|
|
Schema::dropIfExists('tournament'); |
50
|
|
|
DBHelpers::setFKCheckOn(); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|