Hopefully fixes #3203 and #3439

This commit is contained in:
snipe
2017-06-15 19:42:43 -07:00
parent 5d4920c741
commit 99f65cbf69
3 changed files with 117 additions and 4 deletions
@@ -0,0 +1,47 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\Asset;
class AddNextAutoincrementToSettings extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$assets = Asset::select('asset_tag')->whereNull('deleted_at')->get();
if (!$next = Asset::nextAutoIncrement($assets)) {
$next = 1;
}
Schema::table('settings', function (Blueprint $table) use ($next) {
$table->bigInteger('next_auto_tag_base')->nullable()->default(null);
});
\Log::debug('Setting '.$next.' as default auto-increment');
$settings = App\Models\Setting::first();
$settings->next_auto_tag_base = $next;
$settings->save();
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function ($table) {
$table->dropColumn('next_auto_tag_base');
});
}
}