i have 9 tables, when i run command :
php artisan migrate
only users table, migration table and password_reset table are created in my database. this is my sample code
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAlatsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('alats', function (Blueprint $table) {
$table->increments('id');
$table->integer('merk_id')->unsigned();
$table->integer('kategori_id')->unsigned();
$table->integer('operator_id')->unsigned();
$table->string('nama');
$table->string('no_plat',15);
$table->date('tahun');
$table->string('volume',20);
$table->text('keterangan');
$table->enum('status',['ada','disewa','servis']);
// $table->timestamp('created_at');
// $table->timestamp('updated_at');
$table->timestamps();
$table->foreign('merk_id')->references('id')->on('merks')->onDelete('CASCADE');
$table->foreign('kategori_id')->references('id')->on('kategoris')->onDelete('CASCADE');
$table->foreign('operator_id')->references('id')->on('operators')->onDelete('CASCADE');
});
}
public function down()
{
Schema::dropIfExists('alats');
}
}
please help me..?
db_sidewiratih
.# sql-53c_8d
(errno: 150 "Foreign key constraint is incorrectly formed") (SQ L: alter tablealats
add constraintalats_merk_id_foreign
foreign key (merk_id
) referencesmerks
(id
) on delete CASCADE) [PDOException] SQLSTATE[HY000]: General error: 1005 Can't create tabledb_sidewiratih
.# sql-53c_8d
(errno: 150 "Foreign key constraint is incorrectly formed") – Juliar Nasution