|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Support\Facades\DB; |
|
4
|
|
|
use Illuminate\Support\Facades\Schema; |
|
5
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
6
|
|
|
use Illuminate\Database\SQLiteConnection; |
|
7
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
8
|
|
|
use Bavix\Wallet\Models\Transfer; |
|
9
|
|
|
|
|
10
|
|
|
class UpdateTransfersTable extends Migration |
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @return string |
|
15
|
|
|
*/ |
|
16
|
|
|
protected function table(): string |
|
17
|
|
|
{ |
|
18
|
|
|
return (new Transfer())->getTable(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @return void |
|
23
|
|
|
*/ |
|
24
|
|
|
public function up(): void |
|
25
|
|
|
{ |
|
26
|
|
|
Schema::table($this->table(), function(Blueprint $table) { |
|
27
|
|
|
$table->boolean('refund') |
|
28
|
|
|
->after('withdraw_id') |
|
29
|
|
|
->default(0); |
|
30
|
|
|
|
|
31
|
|
|
$table->index(['from_type', 'from_id', 'to_type', 'to_id', 'refund'], 'from_to_refund_ind'); |
|
32
|
|
|
$table->index(['from_type', 'from_id', 'refund'], 'from_refund_ind'); |
|
33
|
|
|
$table->index(['to_type', 'to_id', 'refund'], 'to_refund_ind'); |
|
34
|
|
|
}); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return void |
|
39
|
|
|
*/ |
|
40
|
|
|
public function down(): void |
|
41
|
|
|
{ |
|
42
|
|
|
Schema::table($this->table(), function(Blueprint $table) { |
|
43
|
|
|
if (!(DB::connection() instanceof SQLiteConnection)) { |
|
44
|
|
|
$table->dropIndex('from_to_refund_ind'); |
|
45
|
|
|
$table->dropIndex('from_refund_ind'); |
|
46
|
|
|
$table->dropIndex('to_refund_ind'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
$table->dropColumn('refund'); |
|
50
|
|
|
}); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|