Answer the question
In order to leave comments, you need to log in
How to correctly add data type in migration(postgresql) Yii2?
Good afternoon
This is an example migration file
public function safeUp() {
$this->execute('DROP TYPE IF EXISTS users_status;');
$this->execute("CREATE TYPE user_status AS ENUM ('active','inactive','blocked','deleted');");
$this->createTable('{{%user}}', [
'id' => $this->bigPrimaryKey(),
'status' => 'user_status',
'phone' => $this->bigInteger(),
'email' => $this->string(50),
'first_name' => $this->string(30),
'last_name' => $this->string(30),
'middle_name' => $this->string(30),
'password' => $this->string(100),
'create_at' => $this->bigInteger(),
'update_at' => $this->bigInteger()
]);
$this->createIndex('idx-user-status', '{{%user}}', 'status');
$this->createIndex('idx-user-phone', '{{%user}}', 'phone');
$this->createIndex('idx-user-email', '{{%user}}', 'email');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question