7 if (!Yii::app()->getModule(
'user')) {
8 echo
"\n\nAdd to console.php :\n"
12 .
" ... # copy settings from main config\n"
23 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'create_at',
"TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP");
24 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit_at',
"TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'");
25 $this->execute(
"UPDATE ".Yii::app()->getModule(
'user')->tableUsers.
" SET create_at = FROM_UNIXTIME(createtime), lastvisit_at = IF(lastvisit,FROM_UNIXTIME(lastvisit),'0000-00-00 00:00:00')");
26 $this->dropColumn(Yii::app()->getModule(
'user')->tableUsers,
'createtime');
27 $this->dropColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit');
31 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'create_at',
"TIMESTAMP");
32 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit_at',
"TIMESTAMP");
33 $this->execute(
"UPDATE ".Yii::app()->getModule(
'user')->tableUsers.
" SET create_at = datetime(createtime, 'unixepoch'), lastvisit_at = datetime(lastvisit, 'unixepoch')");
34 $this->execute(
'ALTER TABLE "'.Yii::app()->getModule(
'user')->tableUsers.
'" RENAME TO "'.__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers.
'"');
35 $this->createTable(Yii::app()->getModule(
'user')->tableUsers, array(
37 "username" =>
"varchar(20) NOT NULL",
38 "password" =>
"varchar(128) NOT NULL",
39 "email" =>
"varchar(128) NOT NULL",
40 "activkey" =>
"varchar(128) NOT NULL",
41 "superuser" =>
"int(1) NOT NULL",
42 "status" =>
"int(1) NOT NULL",
43 "create_at" =>
"TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP",
44 "lastvisit_at" =>
"TIMESTAMP",
46 $this->execute(
'INSERT INTO "'.Yii::app()->getModule(
'user')->tableUsers.
'" SELECT "id","username","password","email","activkey","superuser","status","create_at","lastvisit_at" FROM "'.__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers.
'"');
47 $this->dropTable(__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers);
56 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'createtime',
"int(10) NOT NULL");
57 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit',
"int(10) NOT NULL");
58 $this->execute(
"UPDATE ".Yii::app()->getModule(
'user')->tableUsers.
" SET createtime = UNIX_TIMESTAMP(create_at), lastvisit = UNIX_TIMESTAMP(lastvisit_at)");
59 $this->dropColumn(Yii::app()->getModule(
'user')->tableUsers,
'create_at');
60 $this->dropColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit_at');
64 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'createtime',
"int(10)");
65 $this->addColumn(Yii::app()->getModule(
'user')->tableUsers,
'lastvisit',
"int(10)");
66 $this->execute(
"UPDATE ".Yii::app()->getModule(
'user')->tableUsers.
" SET createtime = strftime('%s',create_at), lastvisit = strftime('%s',lastvisit_at)");
67 $this->execute(
'ALTER TABLE "'.Yii::app()->getModule(
'user')->tableUsers.
'" RENAME TO "'.__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers.
'"');
68 $this->createTable(Yii::app()->getModule(
'user')->tableUsers, array(
70 "username" =>
"varchar(20) NOT NULL",
71 "password" =>
"varchar(128) NOT NULL",
72 "email" =>
"varchar(128) NOT NULL",
73 "activkey" =>
"varchar(128) NOT NULL",
74 "createtime" =>
"int(10) NOT NULL",
75 "lastvisit" =>
"int(10) NOT NULL",
76 "superuser" =>
"int(1) NOT NULL",
77 "status" =>
"int(1) NOT NULL",
79 $this->execute(
'INSERT INTO "'.Yii::app()->getModule(
'user')->tableUsers.
'" SELECT "id","username","password","email","activkey","createtime","lastvisit","superuser","status" FROM "'.__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers.
'"');
80 $this->execute(
'DROP TABLE "'.__CLASS__.
'_'.Yii::app()->getModule(
'user')->tableUsers.
'"');
87 list($type) = explode(
':', Yii::app()->db->connectionString);
88 echo
"type db: ".$type.
"\n";