
Tablas relacionadas laravel 8
Publicado por Francisco (1 intervención) el 11/04/2022 12:03:56
Muy buenas, estoy iniciando un proyecto nuevo (soy novato en Laravel) y nada mas empezar me surgen problemas, me explico:
Tengo una tabla tarifas y quiero que la tabla users tenga como clave foranea el id de las tarifas, mis migraciones están asi....
Tarifas....
Y me hace la migración perfectamente.La de users la he modificado (después de 100 pruebas) así...
Pero al intentar hacer la migración obtengo este error:

¿Alguien que me eche una mano? Gracias por adelantado.
Tengo una tabla tarifas y quiero que la tabla users tenga como clave foranea el id de las tarifas, mis migraciones están asi....
Tarifas....
1
2
3
4
5
6
7
8
public function up()
{
Schema::create('tarifas', function (Blueprint $table) {
$table->engine=("InnoDB");
$table->bigIncrements('id')->unsigned()->index();
$table->timestamps();
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->string('name');
$table->string('email');
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->unsignedBigInteger('tarifa_id');
$table->timestamps();
});
Schema::create('users', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->foreign('tarifa_id')->references('id')->on('tarifas');
});
}
¿Alguien que me eche una mano? Gracias por adelantado.
Valora esta pregunta


0