Use checksum more broadly, not specifically SHA256
This commit is contained in:
parent
4cd44d2025
commit
034a310702
8 changed files with 50 additions and 9 deletions
|
@ -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)');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue