Esta es la de la tabla tipoAutos
:
Schema::create('tipoAutos', function (Blueprint $table) { $table->increments('id'); $table->string('tipoAuto'); $table->timestamps();});
Y esta la de la tabla automoviles
:
Schema::create('automoviles', function (Blueprint $table) { $table->increments('id'); $table->string('patente',6)->unique(); $table->string('marca'); $table->string('modelo'); $table->string('color'); $table->string('VIN',17)->unique(); $table->integer('ano'); $table->integer('automovil_id')->unsigned(); $table->integer('kilometros'); $table->integer('precio'); $table->double('cc_Motor'); $table->enum('transmision', ['Mecánico', 'Automático', 'Semi-Automático']); $table->enum('tipo_combustible', ['Bencina', 'Petroleo', 'Eléctrico']); $table->enum('traccion', ['Delantera', 'Trasera', 'Integral/4X4']); //campo auxilliares de Laravel $table->rememberToken(); $table->timestamps(); $table->softDeletes(); //Nueva línea, para el borrado lógico $table->foreign('automovil_id')->references('id')->on('tipoAutos');});
En consola me sale este error:
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table
concesionaria
.automoviles
(errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter tableautomoviles
add constraintautomoviles_automovil_id_foreign
foreign key (automovil_id
) referencestipoAutos
(id
))