Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.33k stars 588 forks source link

[Doctrine\DBAL\DBALException] #103

Open simonorono opened 7 years ago

simonorono commented 7 years ago

Trying to generate migrations from SQL Server 2012

AVAQS@DESKTOP-F36ARF2 C:\Users\AVAQS\Code\alliance.api
# php artisan migrate:generate -vvv -t PERSONAS,ATRIBUTOS_PERSONAS,ATRIBUTOS,ATRIBUTOS_PAPELES,OPCION_PERSONAS,PAPELES,PAPELES_PERSONAS
Using connection: sqlsrv

Generating migrations for: PERSONAS, ATRIBUTOS_PERSONAS, ATRIBUTOS, ATRIBUTOS_PAPELES, OPCION_PERSONAS, PAPELES, PAPELES_PERSONAS

 Do you want to log these migrations in the migrations table? [Y/n] :
 > n

Setting up Tables and Index Migrations

  [Doctrine\DBAL\DBALException]
  Unknown database type estatus requested, Doctrine\DBAL\Platforms\SQLServer2012Platform may not support it.

Exception trace:
 () at C:\Users\AVAQS\Code\alliance.api\vendor\doctrine\dbal\lib\Doctrine\DBAL\Platforms\AbstractPlatform.php:423
 Doctrine\DBAL\Platforms\AbstractPlatform->getDoctrineTypeMapping() at C:\Users\AVAQS\Code\alliance.api\vendor\doctrine\dbal\lib\Doctrine\DBAL\Schema\SQLServerSchemaManager.php:86
 Doctrine\DBAL\Schema\SQLServerSchemaManager->_getPortableTableColumnDefinition() at C:\Users\AVAQS\Code\alliance.api\vendor\doctrine\dbal\lib\Doctrine\DBAL\Schema\AbstractSchemaManager.php:820
 Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList() at C:\Users\AVAQS\Code\alliance.api\vendor\doctrine\dbal\lib\Doctrine\DBAL\Schema\AbstractSchemaManager.php:175
 Doctrine\DBAL\Schema\AbstractSchemaManager->listTableColumns() at C:\Users\AVAQS\Code\alliance.api\vendor\xethron\migrations-generator\src\Xethron\MigrationsGenerator\Generators\FieldGenerator.php:37
 Xethron\MigrationsGenerator\Generators\FieldGenerator->generate() at C:\Users\AVAQS\Code\alliance.api\vendor\xethron\migrations-generator\src\Xethron\MigrationsGenerator\Generators\SchemaGenerator.php:67
 Xethron\MigrationsGenerator\Generators\SchemaGenerator->getFields() at C:\Users\AVAQS\Code\alliance.api\vendor\xethron\migrations-generator\src\Xethron\MigrationsGenerator\MigrateGenerateCommand.php:245
 Xethron\MigrationsGenerator\MigrateGenerateCommand->generate() at C:\Users\AVAQS\Code\alliance.api\vendor\xethron\migrations-generator\src\Xethron\MigrationsGenerator\MigrateGenerateCommand.php:175
 Xethron\MigrationsGenerator\MigrateGenerateCommand->fire() at n/a:n/a
 call_user_func_array() at C:\Users\AVAQS\Code\alliance.api\vendor\laravel\framework\src\Illuminate\Container\Container.php:508
 Illuminate\Container\Container->call() at C:\Users\AVAQS\Code\alliance.api\vendor\laravel\framework\src\Illuminate\Console\Command.php:169
 Illuminate\Console\Command->execute() at C:\Users\AVAQS\Code\alliance.api\vendor\symfony\console\Command\Command.php:254
 Symfony\Component\Console\Command\Command->run() at C:\Users\AVAQS\Code\alliance.api\vendor\laravel\framework\src\Illuminate\Console\Command.php:155
 Illuminate\Console\Command->run() at C:\Users\AVAQS\Code\alliance.api\vendor\symfony\console\Application.php:820
 Symfony\Component\Console\Application->doRunCommand() at C:\Users\AVAQS\Code\alliance.api\vendor\symfony\console\Application.php:187
 Symfony\Component\Console\Application->doRun() at C:\Users\AVAQS\Code\alliance.api\vendor\symfony\console\Application.php:118
 Symfony\Component\Console\Application->run() at C:\Users\AVAQS\Code\alliance.api\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:121
 Illuminate\Foundation\Console\Kernel->handle() at C:\Users\AVAQS\Code\alliance.api\artisan:36
Xethron commented 7 years ago

What is estatus? And how would you represent it in a migration?

simonorono commented 7 years ago

This is the relevant part of the script (autogenerated) for that table:

create rule R_ESTATUS as
      @column in ('ACTIVO','INACTIVO')
go

create type ESTATUS
   from char(15) not null
go

execute sp_bindrule R_ESTATUS, ESTATUS
go

create table PERSONAS (
-- ...
   ESTATUS              ESTATUS              not null default 'ACTIVO',
-- ...
)
go
Xethron commented 7 years ago

So it seems to be a custom type? How would you represent it in a Laravel Migration? I don't think it supports custom types?

simonorono commented 7 years ago

That particular case should be represented as an enum.

Like this:

$table->enum('ESTATUS', ['ACTIVO', 'INACTIVO']);