You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
916 B
42 lines
916 B
7 years ago
|
<?php namespace Magefly\Aauth\Database\Migrations;
|
||
|
|
||
|
use CodeIgniter\Database\Migration;
|
||
|
use Magefly\Aauth\Config\Aauth as AauthConfig;
|
||
|
|
||
|
class Migration_create_default_admin extends Migration
|
||
|
{
|
||
|
public function up()
|
||
|
{
|
||
|
$config = new AauthConfig();
|
||
|
|
||
|
$data = [
|
||
|
'username' => 'admin',
|
||
|
'email' => '[email protected]',
|
||
|
'password' => password_hash('password123456', $config->passwordHashAlgo, $config->passwordHashOptions),
|
||
|
];
|
||
|
|
||
|
$this->db->table($config->dbTableUsers)->insert($data);
|
||
|
|
||
|
$data = [
|
||
|
[
|
||
|
'group_id' => 1,
|
||
|
'user_id' => 1,
|
||
|
],
|
||
|
[
|
||
|
'group_id' => 2,
|
||
|
'user_id' => 1,
|
||
|
],
|
||
|
];
|
||
|
|
||
|
$this->db->table($config->dbTableGroupToUser)->insertBatch($data);
|
||
|
}
|
||
|
|
||
|
//--------------------------------------------------------------------
|
||
|
|
||
|
public function down()
|
||
|
{
|
||
|
$this->db->table($config->dbTableUsers)->truncate();
|
||
|
$this->db->table($config->dbTableGroupToUser)->truncate();
|
||
|
}
|
||
|
}
|