1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Schema\Blueprint; |
4
|
|
|
use Illuminate\Database\Migrations\Migration; |
5
|
|
|
|
6
|
|
|
class CreateToDoListTables extends Migration |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
View Code Duplication |
Schema::create('Task', function (Blueprint $table) { |
|
|
|
|
18
|
|
|
$table->increments('id'); |
19
|
|
|
$table->string('title', 50); |
20
|
|
|
$table->string('description', 250)->nullable(); |
21
|
|
|
$table->tinyInteger('status'); |
22
|
|
|
$table->timestamps(); |
23
|
|
|
$table->softDeletes(); |
24
|
|
|
}); |
25
|
|
|
|
26
|
|
View Code Duplication |
Schema::create('TaskList', function (Blueprint $table) { |
|
|
|
|
27
|
|
|
$table->increments('id'); |
28
|
|
|
$table->string('name', 50); |
29
|
|
|
$table->string('description', 250)->nullable(); |
30
|
|
|
$table->timestamps(); |
31
|
|
|
$table->softDeletes(); |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
View Code Duplication |
Schema::create('Task_TaskList', function (Blueprint $table) { |
|
|
|
|
35
|
|
|
$table->increments('id'); |
36
|
|
|
$table->integer('task')->unsigned(); |
37
|
|
|
$table->integer('tasklist')->unsigned(); |
38
|
|
|
$table->integer('order'); |
39
|
|
|
|
40
|
|
|
$table->foreign('task')->references('id')->on('Task'); |
41
|
|
|
$table->foreign('tasklist')->references('id')->on('TaskList'); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
View Code Duplication |
Schema::create('Task_User', function (Blueprint $table) { |
|
|
|
|
45
|
|
|
$table->increments('id'); |
46
|
|
|
$table->integer('task')->unsigned(); |
47
|
|
|
$table->integer('user')->unsigned(); |
48
|
|
|
|
49
|
|
|
$table->foreign('task')->references('id')->on('Task'); |
50
|
|
|
$table->foreign('user')->references('id')->on('User'); |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
View Code Duplication |
Schema::create('TaskList_User', function (Blueprint $table) { |
|
|
|
|
54
|
|
|
$table->increments('id'); |
55
|
|
|
$table->integer('tasklist')->unsigned(); |
56
|
|
|
$table->integer('user')->unsigned(); |
57
|
|
|
|
58
|
|
|
$table->foreign('tasklist')->references('id')->on('TaskList'); |
59
|
|
|
$table->foreign('user')->references('id')->on('User'); |
60
|
|
|
}); |
61
|
|
|
|
62
|
|
|
Schema::create('TaskLog', function (Blueprint $table) { |
63
|
|
|
$table->increments('id'); |
64
|
|
|
$table->integer('task')->unsigned(); |
65
|
|
|
$table->tinyInteger('status'); |
66
|
|
|
$table->timestamps(); |
67
|
|
|
$table->softDeletes(); |
68
|
|
|
|
69
|
|
|
$table->foreign('task')->references('id')->on('Task'); |
70
|
|
|
}); |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Reverse the migrations. |
76
|
|
|
* |
77
|
|
|
* @return void |
78
|
|
|
*/ |
79
|
|
|
public function down() |
80
|
|
|
{ |
81
|
|
|
|
82
|
|
|
Schema::drop('Task'); |
83
|
|
|
Schema::drop('TaskList'); |
84
|
|
|
Schema::drop('Task_TaskList'); |
85
|
|
|
Schema::drop('Task_User'); |
86
|
|
|
Schema::drop('TaskList_User'); |
87
|
|
|
Schema::drop('TaskLog'); |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.