@@ -9,24 +9,24 @@ public function safeUp()
9
9
{
10
10
$ this ->execute ('CREATE TYPE "enum_itt_v2_users_role" AS ENUM( \'admin \', \'editor \', \'reader \') ' );
11
11
$ this ->addColumn ('{{%v2_users}} ' , 'login ' , $ this ->text ()->notNull ());
12
+ $ this ->dropIndex ('v2_users_username_key ' , '{{%v2_users}} ' );
13
+ $ this ->createIndex ('v2_users_login_key ' , '{{%v2_users}} ' , 'login ' , true );
14
+ $ this ->createIndex ('v2_users_role_flags_hash_index ' , '{{%v2_users}} ' , ["role " , "flags " ], 'hash ' );
12
15
$ this ->dropColumn ('{{%v2_users}} ' , 'username ' );
13
16
$ this ->db ->createCommand ('ALTER TABLE {{%v2_users}} ALTER COLUMN "email" SET DATA TYPE varchar(255) ' )->execute ();
14
17
$ this ->alterColumn ('{{%v2_users}} ' , 'role ' , '"enum_itt_v2_users_role" USING "role"::"enum_itt_v2_users_role" ' );
15
18
$ this ->alterColumn ('{{%v2_users}} ' , 'role ' , "DROP DEFAULT " );
16
19
$ this ->alterColumn ('{{%v2_users}} ' , 'created_at ' , "DROP DEFAULT " );
17
- $ this ->dropIndex ('v2_users_username_key ' , '{{%v2_users}} ' );
18
- $ this ->createIndex ('v2_users_login_key ' , '{{%v2_users}} ' , 'login ' , true );
19
- $ this ->createIndex ('v2_users_role_flags_hash_index ' , '{{%v2_users}} ' , ["role " , "flags " ], 'hash ' );
20
20
}
21
21
22
22
public function safeDown ()
23
23
{
24
- $ this ->dropIndex ('v2_users_role_flags_hash_index ' , '{{%v2_users}} ' );
25
- $ this ->dropIndex ('v2_users_login_key ' , '{{%v2_users}} ' );
26
- $ this ->createIndex ('v2_users_username_key ' , '{{%v2_users}} ' , 'username ' , true );
27
24
$ this ->alterColumn ('{{%v2_users}} ' , 'role ' , 'varchar(20) NULL USING "role"::varchar ' );
28
25
$ this ->alterColumn ('{{%v2_users}} ' , 'email ' , $ this ->string (200 )->notNull ());
29
26
$ this ->addColumn ('{{%v2_users}} ' , 'username ' , $ this ->string (200 )->notNull ());
27
+ $ this ->dropIndex ('v2_users_role_flags_hash_index ' , '{{%v2_users}} ' );
28
+ $ this ->dropIndex ('v2_users_login_key ' , '{{%v2_users}} ' );
29
+ $ this ->createIndex ('v2_users_username_key ' , '{{%v2_users}} ' , 'username ' , true );
30
30
$ this ->dropColumn ('{{%v2_users}} ' , 'login ' );
31
31
$ this ->alterColumn ('{{%v2_users}} ' , 'role ' , "SET DEFAULT 'reader' " );
32
32
$ this ->execute ('DROP TYPE "enum_itt_v2_users_role" ' );
0 commit comments