Orders tablosuna bağlamaya çalışıyorum country_id'yi ama foreignId'de problem yaşıyorum tam olarak nerede hata yapıyorum
SQLSTATE[HY000]: General error: 1005 Can't create table logistdepo
.orders
(errno: 150 "Foreign key constraint is incorrectly formed") (Connection: mysql, SQL: alter table orders
add constraint orders_country_id_foreign
foreign key (country_id
) references country
(id
))
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->string('plate_number')->nullable();
$table->string('driver_name')->nullable();
$table->string('driver_phone_number')->nullable();
$table->string('transporter_info')->nullable();
$table->date('exit_date')->default(now());
$table->date('enter_date')->default(now());
$table->date('exit_customs')->default(now());
$table->foreignId('country_id')->constrained()->on('country')->references('id');
$table->string('barcode_number')->nullable()->unique();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('order_type')->nullable();
$table->string('status')->default('new');
$table->rememberToken();
$table->softDeletes();
$table->timestamps();
});
Schema::create('country', function (Blueprint $table) {
$table->id();
$table->integer('country_id');
$table->string('country');
$table->string('code');
$table->string('iso');
$table->timestamps();
$table->softDeletes();
});