Revert to generic migration changes

This commit is contained in:
Bubka 2022-04-04 13:29:34 +02:00
parent 227b2b2870
commit 9751f9f648

View File

@ -16,23 +16,28 @@ class SplitTwofaccountsUriInMultipleColumns extends Migration
*/ */
public function up() public function up()
{ {
// as SQLITE disallow to add a not nullable column without default $driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
// value when altering a table we add all columns as nullable and
// change them right after to not nullable column
Schema::table('twofaccounts', function (Blueprint $table) { Schema::table('twofaccounts', function (Blueprint $table) {
$table->string('otp_type', 10)->nullable(); $table->string('otp_type', 10);
$table->text('secret')->nullable(); $table->text('secret');
$table->string('algorithm', 20)->nullable(); $table->string('algorithm', 20);
$table->unsignedTinyInteger('digits')->default(6); $table->unsignedTinyInteger('digits');
$table->unsignedInteger('period')->nullable(); $table->unsignedInteger('period')->nullable();
$table->unsignedBigInteger('counter')->nullable(); $table->unsignedBigInteger('counter')->nullable();
}); });
Schema::table('twofaccounts', function (Blueprint $table){ // Apply previous migration 'AlterEncryptedColumnsToText' even to sqlite base
$table->string('otp_type', 10)->nullable(false)->change(); if ('sqlite' === $driver) {
$table->text('secret')->nullable(false)->change();
$table->string('algorithm', 20)->nullable(false)->change(); Schema::table('twofaccounts', function (Blueprint $table) {
}); $table->text('account')->change();
});
Schema::table('twofaccounts', function (Blueprint $table) {
$table->text('uri')->change();
});
}
Schema::table('twofaccounts', function (Blueprint $table) { Schema::table('twofaccounts', function (Blueprint $table) {
$table->renameColumn('uri', 'legacy_uri'); $table->renameColumn('uri', 'legacy_uri');