В строке Connection.php 664:
SQLSTATE[HY000]: Общая ошибка: 3780 Ссылки на столбец «user_id» и столбец «id», на который ссылаются, в ограничении внешнего ключа «almacen_movimientos_user_id_foreign» несовместимы. (SQL: изменить таблицу almacen_movimientos добавить ограничение almacen_movimientos_user_id_foreign внешний ключ (
Код: Выделить всё
user_id
Код: Выделить всё
id
В строке 129 PDOStatement.php:
SQLSTATE[HY000]: Общая ошибка: 3780 Ссылки на столбец «user_id» и столбец, на который ссылаются, «id» в ограничении внешнего ключа «almacen_movimientos_user_id_foreign» несовместимы.
< /blockquote>
Мои миграции выглядят следующим образом:
таблица almacen_movimientos
Код: Выделить всё
public function up()
{
Schema::create('almacen_movimientos', function (Blueprint $table) {
$table->unsignedBigInteger('id');
$table->integer('cliente_proveedor_id');
$table->integer('empresa_id');
$table->integer('user_id');
$table->enum('tipo' , ['ENTRADA' , 'SALIDA' , 'REUBICACION' , 'TRASPASO' , 'DEVOLUCION' , 'MSRO' , 'ENTRADA POR TRASPASO' , 'SALIDA POR TRASPASO'])->nullable();
$table->string('referencia' , 255)->nullable();
$table->string('observaciones' , 255)->nullable();
$table->timestamp('created_at');
$table->timestamp('updated_at');
$table->timestamp('deleted_at');
$table->string('transportista' , 255)->nullable();
$table->string('operador' , 255)->nullable();
$table->string('procedencia' , 255)->nullable();
$table->integer('almacen_id')->nullable();
$table->foreign('cliente_proveedor_id')->references('id')->on('empresas')->onDelete('restrict');
$table->foreign('empresa_id')->references('id')->on('empresas')->onDelete('restrict');
$table->foreign('user_id')->references('id')->on('users')->onDelete('restrict');
$table->foreign('almacen_id')->references('id')->on('almacenes')->onDelete('restrict');
});
}
Код: Выделить всё
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->unsignedBigInteger('id');
$table->string('name' , 255);
$table->string('apellido_paterno' , 115)->nullable();
$table->string('apellido_materno' , 115)->nullable();
$table->dateTime('fecha_nacimiento')->nullable();
$table->string('telefono1' , 10)->nullable();
$table->string('telefono2' , 10)->nullable();
$table->string('calle' , 255)->nullable();
$table->string('numero' , 45)->nullable();
$table->string('colonia' , 255)->nullable();
$table->string('codigo_postal' , 6)->nullable();
$table->string('email' , 255)->unique();
$table->string('user' , 20)->nullable()->unique();
$table->string('password' , 255);
$table->string('palabra_secreta' , 255);
$table->string('remember_token' , 100)->nullable();
$table->unsignedInteger('empresa_id')->nullable();
$table->timestamp('created_at');
$table->timestamp('updated_at');
$table->timestamp('deleted_at');
$table->foreign('empresa_id')->references('id')->on('empresas')->onDelete('restrict');
});
}
Спасибо.
С уважением.
Подробнее здесь: https://stackoverflow.com/questions/635 ... referenced