3

I just created fresh migration. After running it I see my field type not ENUM type. It has a VARCHAR(255) type instead

Schema::create('payments', function (Blueprint $table) {
          $table->increments('id');
          $table->text('response');
          $table->enum('type', ['apple', 'paypal']);
          $table->smallInteger('flags');
          $table->timestamps();

        });

Can somebody tell me what can be the reason. Am I missing something, I tried multiple times - getting same result.

I'm using PostgreSQL 9.5.4

alvery
  • 1,863
  • 2
  • 15
  • 35

1 Answers1

5

From the Laravel source code

protected function typeEnum(Fluent $column)
{
    $allowed = array_map(function ($a) {
        return "'{$a}'";
    }, $column->allowed);
    return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed).'))';
}

It will create a varchar(255) column and will add a constraint so that it allows only the specified strings.

Amit Gupta
  • 17,072
  • 4
  • 41
  • 53