1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Support\Facades\Schema; |
6
|
|
|
|
7
|
|
|
class CreateProjectsTable extends Migration |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
Schema::create('projects', function (Blueprint $table) { |
17
|
|
|
$table->bigIncrements('id'); |
18
|
|
|
|
19
|
|
|
$table->foreignId('author_id')->nullable() |
20
|
|
|
->references(user_model()->getKeyName()) |
21
|
|
|
->on(user_model()->getTable()); |
22
|
|
|
|
23
|
|
|
$table->foreignId('owner_id')->nullable() |
24
|
|
|
->references(user_model()->getKeyName()) |
25
|
|
|
->on(user_model()->getTable()); |
26
|
|
|
|
27
|
|
|
$table->foreignId('status_id')->nullable() |
28
|
|
|
->references('id') |
29
|
|
|
->on('statuses'); |
30
|
|
|
|
31
|
|
|
$table->string('title'); |
32
|
|
|
$table->text('description')->nullable(); |
33
|
|
|
$table->text('notes')->nullable(); |
34
|
|
|
$table->integer('visible')->default(1)->nullable(); |
35
|
|
|
|
36
|
|
|
$table->timestamp('started_at')->nullable(); |
37
|
|
|
$table->timestamp('delivered_at')->nullable(); |
38
|
|
|
$table->timestamp('expected_at')->nullable(); |
39
|
|
|
|
40
|
|
|
$table->timestamps(); |
41
|
|
|
$table->softDeletes(); |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
Schema::create('projectables', function (Blueprint $table) { |
45
|
|
|
$table->increments('id'); |
46
|
|
|
$table->integer('project_id'); |
47
|
|
|
$table->integer('projectable_id'); |
48
|
|
|
$table->string('projectable_type'); |
49
|
|
|
}); |
50
|
|
|
|
51
|
|
|
Schema::create('project_users', function (Blueprint $table) { |
52
|
|
|
$table->increments('id'); |
53
|
|
|
|
54
|
|
|
$table->foreignId('project_id') |
55
|
|
|
->references('id') |
56
|
|
|
->on('projects'); |
57
|
|
|
|
58
|
|
|
$table->foreignId('user_id') |
59
|
|
|
->references(user_model()->getKeyName()) |
60
|
|
|
->on(user_model()->getTable()); |
61
|
|
|
|
62
|
|
|
$table->string('status')->nullable(); |
63
|
|
|
$table->string('role')->nullable(); |
64
|
|
|
}); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Reverse the migrations. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
public function down() |
73
|
|
|
{ |
74
|
|
|
Schema::dropIfExists('project_users'); |
75
|
|
|
|
76
|
|
|
Schema::dropIfExists('projectables'); |
77
|
|
|
|
78
|
|
|
Schema::dropIfExists('projects'); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|