| Total Complexity | 3 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class CreateTransactionsTable extends Migration |
||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @return string |
||
| 13 | */ |
||
| 14 | protected function table(): string |
||
| 15 | { |
||
| 16 | return (new Transaction())->getTable(); |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return void |
||
| 21 | */ |
||
| 22 | public function up(): void |
||
| 23 | { |
||
| 24 | Schema::create($this->table(), function(Blueprint $table) { |
||
| 25 | $table->increments('id'); |
||
| 26 | $table->morphs('payable'); |
||
| 27 | $table->enum('type', ['deposit', 'withdraw'])->index(); |
||
| 28 | $table->bigInteger('amount'); |
||
| 29 | $table->boolean('confirmed'); |
||
| 30 | $table->json('meta')->nullable(); |
||
| 31 | $table->uuid('uuid')->unique(); |
||
| 32 | $table->timestamps(); |
||
| 33 | |||
| 34 | $table->index(['payable_type', 'payable_id', 'type'], 'payable_type_ind'); |
||
| 35 | $table->index(['payable_type', 'payable_id', 'confirmed'], 'payable_confirmed_ind'); |
||
| 36 | $table->index(['payable_type', 'payable_id', 'type', 'confirmed'], 'payable_type_confirmed_ind'); |
||
| 37 | }); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return void |
||
| 42 | */ |
||
| 43 | public function down(): void |
||
| 44 | { |
||
| 45 | Schema::drop($this->table()); |
||
| 46 | } |
||
| 49 |