|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Database\Migrations\Migration; |
| 4 | +use Illuminate\Database\Schema\Blueprint; |
| 5 | +use Illuminate\Support\Facades\DB; |
| 6 | +use Illuminate\Support\Facades\Schema; |
| 7 | + |
| 8 | +class CreateXHProfTable extends Migration |
| 9 | +{ |
| 10 | + /** |
| 11 | + * Run the migrations. |
| 12 | + * |
| 13 | + * @return void |
| 14 | + */ |
| 15 | + public function up() |
| 16 | + { |
| 17 | + if (DB::connection()->getDriverName() !== 'mysql') { |
| 18 | + return; |
| 19 | + } |
| 20 | + |
| 21 | + Schema::create('details', function (Blueprint $table) { |
| 22 | + $table->id('idcount'); |
| 23 | + $table->char('id', 64); |
| 24 | + $table->char('url', 255)->nullable(); |
| 25 | + $table->char('c_url', 255)->nullable(); |
| 26 | + $table->timestamp('timestamp')->useCurrent()->useCurrentOnUpdate(); |
| 27 | + $table->char('server name', 64)->nullable(); |
| 28 | + $table->binary('perfdata')->nullable(); |
| 29 | + $table->tinyInteger('type')->nullable(); |
| 30 | + $table->binary('cookie')->nullable(); |
| 31 | + $table->binary('post')->nullable(); |
| 32 | + $table->binary('get')->nullable(); |
| 33 | + $table->integer('pmu')->nullable(); |
| 34 | + $table->integer('wt')->nullable(); |
| 35 | + $table->integer('cpu')->nullable(); |
| 36 | + $table->char('server_id', 64)->nullable(); |
| 37 | + $table->char('aggregateCalls_include', 255)->nullable(); |
| 38 | + |
| 39 | + $table->index('url'); |
| 40 | + $table->index('c_url'); |
| 41 | + $table->index('cpu'); |
| 42 | + $table->index('wt'); |
| 43 | + $table->index('pmu'); |
| 44 | + $table->index('timestamp'); |
| 45 | + $table->index(['server name', 'timestamp']); |
| 46 | + }); |
| 47 | + |
| 48 | + if (DB::connection()->getDriverName() === 'mysql') { |
| 49 | + DB::statement('ALTER TABLE details MODIFY COLUMN `perfdata` LONGBLOB'); |
| 50 | + DB::statement('ALTER TABLE details MODIFY COLUMN `cookie` LONGBLOB'); |
| 51 | + DB::statement('ALTER TABLE details MODIFY COLUMN `post` LONGBLOB'); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + /** |
| 56 | + * Reverse the migrations. |
| 57 | + * |
| 58 | + * @return void |
| 59 | + */ |
| 60 | + public function down() |
| 61 | + { |
| 62 | + if (DB::connection()->getDriverName() !== 'mysql') { |
| 63 | + return; |
| 64 | + } |
| 65 | + |
| 66 | + Schema::dropIfExists('details'); |
| 67 | + } |
| 68 | +} |
0 commit comments