Use checksum more broadly, not specifically SHA256

This commit is contained in:
Dane Everitt 2020-08-23 18:06:47 -07:00
parent 4cd44d2025
commit 034a310702
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 50 additions and 9 deletions

View file

@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ModifyChecksumsColumnForBackups extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('backups', function (Blueprint $table) {
$table->renameColumn('sha256_hash', 'checksum');
});
Schema::table('backups', function (Blueprint $table) {
DB::update('UPDATE backups SET checksum = CONCAT(\'sha256:\', checksum)');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('backups', function (Blueprint $table) {
$table->renameColumn('checksum', 'sha256_hash');
});
Schema::table('backups', function (Blueprint $table) {
DB::update('UPDATE backups SET sha256_hash = SUBSTRING(sha256_hash, 8)');
});
}
}