alv*_*ery 3 postgresql laravel eloquent laravel-schema-builder laravel-5.3
我刚刚创建了新的迁移。运行它后,我看到我的字段type 不是 ENUM type。它有一个VARCHAR(255) 类型
Schema::create('payments', function (Blueprint $table) {
$table->increments('id');
$table->text('response');
$table->enum('type', ['apple', 'paypal']);
$table->smallInteger('flags');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我可能是什么原因。我是否遗漏了什么,我尝试了多次 - 得到相同的结果。
我正在使用 PostgreSQL 9.5.4
来自 Laravel源代码
protected function typeEnum(Fluent $column)
{
$allowed = array_map(function ($a) {
return "'{$a}'";
}, $column->allowed);
return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed).'))';
}
Run Code Online (Sandbox Code Playgroud)
它将创建一个varchar(255)列并添加一个约束,以便它只允许指定的字符串。
| 归档时间: |
|
| 查看次数: |
962 次 |
| 最近记录: |