domingo, 19 de marzo de 2017

Errores en Laravel



Errores al ejecutar php artisan migrate
Error 1:
[Illuminate\Database\QueryException]
  SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password:
  YES) (SQL: select * from information_schema.tables where table_schema = homestead and t
  able_name = migrations)



  [PDOException]
  SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password:
  YES)

Solución: modificar el archivo .env
Referencias:
https://laracasts.com/discuss/channels/general-discussion/laravel-5-php-artisan-migrate-problem
http://stackoverflow.com/questions/29756194/access-denied-for-user-homesteadlocalhost-using-password-yes

Error 2:
[Illuminate\Database\QueryException]
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max
   key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`ema
  il`))



  [PDOException]
  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max
   key length is 767 bytes
Solución: Agregar Schema::defaultStringLength(191); al archivo AppServiceProvider.php
use Illuminate\Support\Facades\Schema;

function boot()
{
    Schema::defaultStringLength(191);
}
Referencias:
https://laracasts.com/discuss/channels/laravel/laravel-54-failing-on-php-artisan-migrate-after-php-artisan-makeauth
http://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-w

Error 3:
[Symfony\Component\Debug\Exception\FatalThrowableError]
  Class 'App\Providers\Schema' not found

Solución: Agregar use Illuminate\Support\Facades\Schema; al archivo AppServiceProvider.php
Referencias:
https://laracasts.com/discuss/channels/laravel/php-artisan-migrate-errorclass-appprovidersschema-not-found

Error al eliminar una columna foránea:
[Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1025 Error on rename of '.\lv5test\#sql-dd4_68
  ' to '.\lv5test\users' (errno: 150) (SQL: alter table `users` drop `country_id
  `)
[Illuminate\Database\QueryException]
  SQLSTATE[HY000]: General error: 1025 Error on rename of '.\lv5test\users' to '
  .\lv5test\#sql2-dd4-69' (errno: 152) (SQL: alter table `users` drop foreign ke
  y `country_id`)
Solución: eliminar primero la clave foránea y luego la columna.
Schema::table('users', function (Blueprint $table) {

            $table->dropForeign('users_country_id_foreign');
            $table->dropColumn('country_id');
        });
https://laravel.io/forum/03-22-2014-migratereset-erring-when-dropping-foreign-key
https://stackoverflow.com/questions/4080611/1025-error-on-rename-of-database-sql-2e0f-1254ba7-to-database-table
http://debuggernote.blogspot.com/2017/06/database-migrations-en-laravel-5.html

Néstor Mercedes

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comentarios:

Publicar un comentario