mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-29 03:33:17 +01:00
Add migrations to prevent multiple Schema::table in a single migration
This commit is contained in:
parent
ad5f493c3c
commit
7932228e71
@ -17,7 +17,7 @@ public function up()
|
|||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->string('service');
|
$table->string('service');
|
||||||
$table->string('uri');
|
$table->string('uri');
|
||||||
$table->string('account')->nullable();;
|
$table->string('account')->nullable();
|
||||||
$table->string('icon')->nullable();
|
$table->string('icon')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AlterEncryptedColumnsToTextForSqlite extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
|
||||||
|
|
||||||
|
if ('sqlite' === $driver) {
|
||||||
|
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
$table->text('account')->change();
|
||||||
|
$table->text('uri')->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class RenameUriToLegacyUri extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('uri', 'legacy_uri');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('legacy_uri', 'uri');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@
|
|||||||
use Illuminate\Support\Facades\Crypt;
|
use Illuminate\Support\Facades\Crypt;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class ChangeAccountNotNullableTwofaccountsTable extends Migration
|
class ChangeNullableInTwofaccountsTable extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
@ -16,13 +16,6 @@ class ChangeAccountNotNullableTwofaccountsTable extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
|
|
||||||
$driver = Schema::connection($this->getConnection())->getConnection()->getDriverName();
|
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->renameColumn('uri', 'legacy_uri');
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
Schema::table('twofaccounts', function (Blueprint $table) {
|
||||||
$table->text('account')->nullable(false)->change();
|
$table->text('account')->nullable(false)->change();
|
||||||
$table->string('service')->nullable()->change();
|
$table->string('service')->nullable()->change();
|
||||||
@ -32,18 +25,6 @@ public function up()
|
|||||||
$table->unsignedSmallInteger('digits')->nullable(false)->change();
|
$table->unsignedSmallInteger('digits')->nullable(false)->change();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply migration 'AlterEncryptedColumnsToText' even to sqlite base
|
|
||||||
if ('sqlite' === $driver) {
|
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->text('account')->change();
|
|
||||||
});
|
|
||||||
|
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->text('legacy_uri')->change();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$twofaccounts = DB::table('twofaccounts')->select('id', 'legacy_uri')->get();
|
$twofaccounts = DB::table('twofaccounts')->select('id', 'legacy_uri')->get();
|
||||||
$settingService = resolve('App\Services\SettingService');
|
$settingService = resolve('App\Services\SettingService');
|
||||||
@ -78,8 +59,5 @@ public function up()
|
|||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('twofaccounts', function (Blueprint $table) {
|
|
||||||
$table->renameColumn('legacy_uri', 'uri');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user