add update listener and migrations..

This commit is contained in:
Cüneyt Şentürk 2023-05-31 14:47:46 +03:00
parent 203eeb1885
commit d50daa3fd8
3 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?php
namespace App\Listeners\Update\V30;
use App\Abstracts\Listeners\Update as Listener;
use App\Events\Install\UpdateFinished as Event;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Log;
class Version3015 extends Listener
{
const ALIAS = 'core';
const VERSION = '3.0.15';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
if ($this->skipThisUpdate($event)) {
return;
}
Log::channel('stdout')->info('Updating to 3.0.15 version...');
$this->updateDatabase();
Log::channel('stdout')->info('Done!');
}
public function updateDatabase(): void
{
Log::channel('stdout')->info('Updating database...');
Artisan::call('migrate', ['--force' => true]);
Log::channel('stdout')->info('Database updated.');
}
}

View File

@ -23,6 +23,7 @@ class Event extends Provider
'App\Listeners\Update\V30\Version309',
'App\Listeners\Update\V30\Version3013',
'App\Listeners\Update\V30\Version3014',
'App\Listeners\Update\V30\Version3015',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',

View File

@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Documents
Schema::table('documents', function(Blueprint $table) {
$table->index('contact_id');
});
// User Companies
Schema::table('user_companies', function(Blueprint $table) {
$table->index('user_id');
$table->index('company_id');
});
// User Roles
Schema::table('user_companies', function(Blueprint $table) {
$table->index('user_id');
$table->index('role_id');
});
// Transactions
Schema::table('transactions', function(Blueprint $table) {
$table->index('number');
});
// Roles
Schema::table('roles', function(Blueprint $table) {
$table->index('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};