mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 03:38:06 +02:00
Fix sqlite 'not null error' another way
This commit is contained in:
parent
109940c002
commit
e749e3d98e
@ -16,24 +16,25 @@ class SplitTwofaccountsUriInMultipleColumns extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
|
// as SQLITE disallow to add a not nullable column without default
|
||||||
|
// value when altering a table we add all columns as nullable and
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) use ($driver) {
|
// change them right after to not nullable column
|
||||||
if ('sqlite' === $driver) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->string('otp_type', 10)->default('');
|
$table->string('otp_type', 10)->nullable();
|
||||||
$table->text('secret')->default('');
|
$table->text('secret')->nullable();
|
||||||
$table->string('algorithm', 20)->default('');
|
$table->string('algorithm', 20)->nullable();
|
||||||
$table->unsignedTinyInteger('digits')->default(6);
|
$table->unsignedTinyInteger('digits')->nullable();
|
||||||
} 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();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table){
|
||||||
|
$table->string('otp_type')->nullable(false)->change();
|
||||||
|
$table->string('secret')->nullable(false)->change();
|
||||||
|
$table->string('algorithm')->nullable(false)->change();
|
||||||
|
$table->string('digits')->nullable(false)->change();
|
||||||
|
});
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->renameColumn('uri', 'legacy_uri');
|
$table->renameColumn('uri', 'legacy_uri');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user