Postgresql 如何在Yii2中使用新创建的自定义Postgres模式类型(ENUM)
使用带有Yii2的Postgres在带有Postgresql 如何在Yii2中使用新创建的自定义Postgres模式类型(ENUM),postgresql,enums,yii2,migration,Postgresql,Enums,Yii2,Migration,使用带有Yii2的Postgres在带有 createCommand("CREATE TYPE colorEnum AS ENUM ('red', 'black', 'white');); 创建表时,如何在Yii2迁移类中使用它,如: $this->createTable('myTable’, [ 'color' => 'what should go here?' 以下任何一项都应该有效,包括@rob006的评论: public function saf
createCommand("CREATE TYPE colorEnum AS ENUM ('red', 'black', 'white'););
创建表时,如何在Yii2迁移类中使用它,如:
$this->createTable('myTable’, [
'color' => 'what should go here?'
以下任何一项都应该有效,包括@rob006的评论:
public function safeUp()
{
$this->execute("CREATE TYPE colorEnum AS ENUM ('red', 'black', 'white')");
$this->createTable('myTable', [
"color0" => "colorEnum",
"color1" => "colorEnum default 'black'",
"color2" => $this->getDb()->getSchema()->createColumnSchemaBuilder("colorEnum default 'black'"),
];
// ...
}
public function safeDown()
{
// ...
$this->execute('DROP TYPE colorEnum');
}
你刚才试过了吗?
“color”=>“colorEnum”
?