Fix sqlite 'not null error' during alter table migration

This commit is contained in:
Bubka 2022-04-01 16:28:06 +02:00
parent b47e9de4c9
commit 109940c002

View File

@ -16,11 +16,20 @@ class SplitTwofaccountsUriInMultipleColumns extends Migration
*/ */
public function up() public function up()
{ {
Schema::table('twofaccounts', function (Blueprint $table) { $driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
$table->string('otp_type', 10);
$table->text('secret'); Schema::table('twofaccounts', function (Blueprint $table) use ($driver) {
$table->string('algorithm', 20); if ('sqlite' === $driver) {
$table->unsignedTinyInteger('digits'); $table->string('otp_type', 10)->default('');
$table->text('secret')->default('');
$table->string('algorithm', 20)->default('');
$table->unsignedTinyInteger('digits')->default(6);
} else {
$table->string('otp_type', 10);
$table->text('secret');
$table->string('algorithm', 20);
$table->unsignedTinyInteger('digits');
}
$table->unsignedInteger('period')->nullable(); $table->unsignedInteger('period')->nullable();
$table->unsignedBigInteger('counter')->nullable(); $table->unsignedBigInteger('counter')->nullable();
}); });