mleontenko
5 months ago
951
4
Laravel

Changing field type with migration

Posted 5 months ago by mleontenko

I have a table with an integer field type that I want to change to varchar (postgres database)

I installed:

composer require doctrine/dbal

and created a new migration with:

public function up()
    {
        Schema::table('obrasciProcjeneVrste', function ($table) {
            $table->string('sifra', 256)->change();
        });
    }

When I run php artisan migrate

I get the following error:

Doctrine\DBAL\Exception\TableNotFoundException  : An exception occurred while executing 'SELECT obj_description('obrasciProcjeneVrste'::regclass) AS table_comment;':

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "obrasciprocjenevrste" does not exist
LINE 1: SELECT obj_description('obrasciProcjeneVrste'::regclass) AS ...
                               ^

  at C:\xampp\htdocs\crveni-popis\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractPostgreSQLDriver.php:63
    59|             case '42703':
    60|                 return new Exception\InvalidFieldNameException($message, $exception);
    61| 
    62|             case '42P01':
  > 63|                 return new Exception\TableNotFoundException($message, $exception);
    64| 
    65|             case '42P07':
    66|                 return new Exception\TableExistsException($message, $exception);
    67| 

  Exception trace:

  1   Doctrine\DBAL\Driver\AbstractPostgreSQLDriver::convertException("An exception occurred while executing 'SELECT obj_description('obrasciProcjeneVrste'::regclass) AS table_comment;':

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "obrasciprocjenevrste" does not exist
LINE 1: SELECT obj_description('obrasciProcjeneVrste'::regclass) AS ...
                               ^", Object(Doctrine\DBAL\Driver\PDOException))
      C:\xampp\htdocs\crveni-popis\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:166

  2   Doctrine\DBAL\DBALException::wrapException(Object(Doctrine\DBAL\Driver\PDOPgSql\Driver), Object(Doctrine\DBAL\Driver\PDOException), "An exception occurred while executing 'SELECT obj_description('obrasciProcjeneVrste'::regclass) AS table_comment;':

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "obrasciprocjenevrste" does not exist
LINE 1: SELECT obj_description('obrasciProcjeneVrste'::regclass) AS ...
                               ^")
      C:\xampp\htdocs\crveni-popis\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php:146

What is the problem here? Table name in migration file exists in database ("obrasciProcjeneVrste") and field name is correct ("sifra").

Please sign in or create an account to participate in this conversation.