backups: default is_successful to false (#3522)

* backups: default is_successful to false
* backups: properly query backups
This commit is contained in:
Matthew Penner 2021-08-03 20:45:25 -06:00 committed by GitHub
parent b19a1640f0
commit 970f281859
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 10 deletions

View file

@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ChangeSuccessfulFieldToDefaultToFalseOnBackupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('backups', function (Blueprint $table) {
$table->boolean('is_successful')->after('uuid')->default(false)->change();
});
// Convert currently processing backups to the new format so things don't break.
DB::table('backups')->select('id')->where('is_successful', 1)->whereNull('completed_at')->update([
'is_successful' => 0,
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('backups', function (Blueprint $table) {
$table->boolean('is_successful')->after('uuid')->default(true)->change();
});
}
}