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.
43 lines
892 B
43 lines
892 B
7 years ago
|
<?php
|
||
|
namespace App\Database\Migrations;
|
||
7 years ago
|
|
||
|
use CodeIgniter\Database\Migration;
|
||
7 years ago
|
use Config\Aauth as AauthConfig;
|
||
7 years ago
|
|
||
|
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();
|
||
|
}
|
||
|
}
|