This commit is contained in:
miroman-afk
2023-05-04 10:41:36 +03:00
parent fb46c8e739
commit 5c3a8a464b
13 changed files with 623 additions and 251 deletions

View File

@@ -0,0 +1,50 @@
<?php
use App\Component\Models\Filesystem;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class AddIndexesForTables extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::table('exchange_actions', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_actions');
if (! array_key_exists('action_type_index', $indexesFound)) {
$table->index('action_type', 'action_type_index');
}
});
Schema::table('exchange_actions', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_actions');
if (! array_key_exists('order_code_index', $indexesFound)) {
$table->index('order_code', 'order_code_index');
}
});
Schema::table('exchange_actions', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_actions');
if (! array_key_exists('shift_id_index', $indexesFound)) {
$table->index('shift_id', 'shift_id_index');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
//
}
}

View File

@@ -0,0 +1,91 @@
<?php
use App\Component\Models\Filesystem;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class AddIndexesForTablesV2 extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::table('dishes', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('dishes');
if (! array_key_exists('code_index', $indexesFound)) {
$table->index('code', 'code_index');
}
if (! array_key_exists('legacy_code_index', $indexesFound)) {
$table->index('legacy_code', 'legacy_code_index');
}
});
Schema::table('exchange_deleted', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_deleted');
if (! array_key_exists('shift_id_index', $indexesFound)) {
$table->index('shift_id', 'shift_id_index');
}
if (! array_key_exists('menu_code_index', $indexesFound)) {
$table->index('menu_code', 'menu_code_index');
}
if (! array_key_exists('dishes_code_index', $indexesFound)) {
$table->index('dishes_code', 'dishes_code_index');
}
});
Schema::table('exchange_items', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_items');
if (! array_key_exists('shift_id_index', $indexesFound)) {
$table->index('shift_id', 'shift_id_index');
}
if (! array_key_exists('menu_code_index', $indexesFound)) {
$table->index('menu_code', 'menu_code_index');
}
if (! array_key_exists('dishes_code_index', $indexesFound)) {
$table->index('dishes_code', 'dishes_code_index');
}
});
Schema::table('exchange_orders', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('exchange_orders');
if (! array_key_exists('shift_id_index', $indexesFound)) {
$table->index('shift_id', 'shift_id_index');
}
if (! array_key_exists('code_index', $indexesFound)) {
$table->index('code', 'code_index');
}
});
Schema::table('shift_online_actions', static function (Blueprint $table) {
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
$indexesFound = $schemaManager->listTableIndexes('shift_online_actions');
if (! array_key_exists('order_code_index', $indexesFound)) {
$table->index('order_code', 'order_code_index');
}
if (! array_key_exists('type_action_index', $indexesFound)) {
$table->index('type_action', 'type_action_index');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
//
}
}