Merhabalar,
table1
`
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('announcement_categories', function (Blueprint $table) {
$table->id();
$table->integer('statu')->default(1);
$table->integer('order')->default(1);
$table->timestamps();
$table->softDeletes();
});
Schema::table('announcements', function (Blueprint $table) {
$table->foreignId('announcement_category_id')->after('order')->constrained()->cascadeOnDelete()->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::enableForeignKeyConstraints();
Schema::disableForeignKeyConstraints();
Schema::dropIfExists('announcement_categories');
}
};
`
table2
`
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('announcement_category_translations', function (Blueprint $table) {
$table->id();
$table->string('locale')->index();
$table->string('title')->nullable();
$table->foreignId('announcement_category_id')->constrained()->cascadeOnDelete()->cascadeOnUpdate();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('announcement_category_translations');
}
};
`
bu şekilde iki tablom var, migrate etmek istediğimde
SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'announcement_category_translations_announcement_category_id_foreign' is too long (Connection: mysql, SQL: alter table
announcement_category_translationsadd constraint
announcement_category_translations_announcement_category_id_foreignforeign key (
announcement_category_id) references
announcement_categories(
id) on delete cascade on update cascade)
bu şekilde hata almaktayım. Nasıl çözebilirim?