Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
company_id dropped on user invitations
- Loading branch information
1 parent
90a2330
commit d7c101e
Showing
5 changed files
with
107 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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\DB; | ||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class Version304 extends Listener | ||
{ | ||
const ALIAS = 'core'; | ||
|
||
const VERSION = '3.0.4'; | ||
|
||
/** | ||
* Handle the event. | ||
* | ||
* @param $event | ||
* @return void | ||
*/ | ||
public function handle(Event $event) | ||
{ | ||
if ($this->skipThisUpdate($event)) { | ||
return; | ||
} | ||
|
||
Log::channel('stderr')->info('Starting the Akaunting 3.0.4 update...'); | ||
|
||
$this->updateDatabase(); | ||
|
||
$this->deleteOldFiles(); | ||
|
||
Log::channel('stderr')->info('Akaunting 3.0.4 update finished.'); | ||
} | ||
|
||
public function updateDatabase() | ||
{ | ||
Log::channel('stderr')->info('Updating database...'); | ||
|
||
DB::table('migrations')->insert([ | ||
'id' => DB::table('migrations')->max('id') + 1, | ||
'migration' => '2022_06_28_000000_core_v304', | ||
'batch' => DB::table('migrations')->max('batch') + 1, | ||
]); | ||
|
||
Artisan::call('migrate', ['--force' => true]); | ||
|
||
Log::channel('stderr')->info('Database updated.'); | ||
} | ||
|
||
public function deleteOldFiles() | ||
{ | ||
Log::channel('stderr')->info('Deleting old files...'); | ||
|
||
$files = [ | ||
'app/Events/Auth/InvitationCreated.php', | ||
'app/Listeners/Auth/SendUserInvitation.php', | ||
]; | ||
|
||
foreach ($files as $file) { | ||
File::delete(base_path($file)); | ||
} | ||
|
||
Log::channel('stderr')->info('Old files deleted.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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() | ||
{ | ||
Schema::table('user_invitations', function (Blueprint $table) { | ||
$table->dropColumn('company_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
// | ||
} | ||
}; |