1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
5
|
|
|
use Illuminate\Support\Facades\Schema; |
6
|
|
|
|
7
|
|
|
class CreateTicketsTable extends Migration |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Run the migrations. |
11
|
|
|
* |
12
|
|
|
* @return void |
13
|
|
|
*/ |
14
|
|
|
public function up() |
15
|
|
|
{ |
16
|
|
|
Schema::create(config('laravel-tickets.database.tickets-table'), function (Blueprint $table) { |
17
|
|
|
$table->id(); |
18
|
|
|
$table->unsignedBigInteger('user_id'); |
19
|
|
|
$table->string('subject'); |
20
|
|
|
$table->enum('priority', config('laravel-tickets.priorities')); |
21
|
|
|
$table->enum('state', [ 'OPEN', 'ANSWERED', 'CLOSED' ])->default('OPEN'); |
22
|
|
|
$table->timestamps(); |
23
|
|
|
|
24
|
|
|
$table->foreign('user_id')->on(config('laravel-tickets.database.users-table'))->references('id'); |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
Schema::create(config('laravel-tickets.database.ticket-messages-table'), function (Blueprint $table) { |
28
|
|
|
$table->id(); |
29
|
|
|
$table->unsignedBigInteger('ticket_id'); |
30
|
|
|
$table->unsignedBigInteger('user_id'); |
31
|
|
|
$table->text('message'); |
32
|
|
|
$table->timestamps(); |
33
|
|
|
|
34
|
|
|
$table->foreign('user_id')->on(config('laravel-tickets.database.users-table'))->references('id'); |
35
|
|
|
$table->foreign('ticket_id')->on(config('laravel-tickets.database.tickets-table'))->references('id'); |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
Schema::create(config('laravel-tickets.database.ticket-uploads-table'), function (Blueprint $table) { |
39
|
|
|
$table->id(); |
40
|
|
|
$table->unsignedBigInteger('ticket_message_id'); |
41
|
|
|
$table->string('path'); |
42
|
|
|
$table->timestamps(); |
43
|
|
|
|
44
|
|
|
$table->foreign('ticket_message_id')->on(config('laravel-tickets.database.ticket-messages-table'))->references('id'); |
45
|
|
|
}); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Reverse the migrations. |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function down() |
54
|
|
|
{ |
55
|
|
|
Schema::dropIfExists(config('laravel-tickets.database.tickets-table')); |
56
|
|
|
Schema::dropIfExists(config('laravel-tickets.database.ticket-messages-table')); |
57
|
|
|
Schema::dropIfExists(config('laravel-tickets.database.ticket-uploads-table')); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|