Laravel - Tablas relacionadas laravel 8

 
Vista:
sin imagen de perfil

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....
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();
        });
    }
Y me hace la migración perfectamente.La de users la he modificado (después de 100 pruebas) así...
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');
        });
    }
Pero al intentar hacer la migración obtengo este error:

Captura
¿Alguien que me eche una mano? Gracias por adelantado.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder