mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
Fix auto increment bug
This commit is contained in:
parent
77fa77081d
commit
b8d68bd74f
1 changed files with 36 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Artist;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class FixArtistAutoindexValue extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
// This is to fix the auto increment bug caused by 2016_04_16_082627_create_various_artists
|
||||
|
||||
// Return if the database driver is not MySQL.
|
||||
if (DB::getDriverName() !== 'mysql') {
|
||||
return;
|
||||
}
|
||||
|
||||
$latestArtist = Artist::orderBy('id', 'DESC')->first();
|
||||
DB::statement("ALTER TABLE artists AUTO_INCREMENT=".($latestArtist->id + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue