2016-10-30 04:05:04 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
use console\db\Migration;
|
|
|
|
|
|
|
|
class m161030_013122_ely_by_admin_app extends Migration {
|
|
|
|
|
|
|
|
public function safeUp() {
|
|
|
|
$exists = $this->db->createCommand('
|
|
|
|
SELECT COUNT(*)
|
|
|
|
FROM {{%oauth_clients}}
|
|
|
|
WHERE id = :app_name
|
|
|
|
LIMIT 1
|
|
|
|
', [
|
2018-04-18 02:17:25 +05:30
|
|
|
'app_name' => 'ely_admin',
|
2016-10-30 04:05:04 +05:30
|
|
|
])->queryScalar();
|
|
|
|
|
|
|
|
if (!$exists) {
|
|
|
|
$this->insert('{{%oauth_clients}}', [
|
2018-04-18 02:17:25 +05:30
|
|
|
'id' => 'ely_admin',
|
2016-10-30 04:05:04 +05:30
|
|
|
'secret' => 'change_this_on_production',
|
|
|
|
'name' => 'Admin Ely.by',
|
|
|
|
'description' => '',
|
|
|
|
'redirect_uri' => 'http://admin.ely.by/authorization/oauth',
|
|
|
|
'is_trusted' => 1,
|
|
|
|
'created_at' => time(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function safeDown() {
|
2018-04-18 02:17:25 +05:30
|
|
|
$this->delete('{{%oauth_clients}}', ['id' => 'ely_admin']);
|
2016-10-30 04:05:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|