Migration to drop stored_eula_column

It’s extraneous, since we already have a file field in the action_logs, and we already store the stored_eula_file in checkout_acceptances.

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-05-17 06:54:26 -07:00
parent 266a9e5328
commit bcd0671213

View file

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Models\Actionlog;
class RemoveStoredEulaField extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$actionlog_eulas = Actionlog::whereNotNull('stored_eula_file')->get();
foreach ($actionlog_eulas as $eula_file) {
$eula_file->filename = $eula_file->stored_eula_file;
$eula_file->save();
}
$actionlog_bad_action_type = Actionlog::where('item_id', '=', 0)->whereNull('target_type')->whereNull('action_type')->whereNull('target_type')->get();
foreach ($actionlog_bad_action_type as $bad_action_type) {
$bad_action_type->delete();
}
Schema::table('action_logs', function (Blueprint $table) {
$table->dropColumn('stored_eula_file');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->string('stored_eula_file')->nullable()->default(null);
});
}
}