Browse Source

readded migrations

v3-dev
REJack 6 years ago
parent
commit
26368e2c80
No known key found for this signature in database
GPG Key ID: 4A44B48700429F46
  1. 82
      app/Database/Migrations/20181026042034_create_user_sessions_table.php
  2. 104
      app/Database/Migrations/20181026110732_create_users_table.php
  3. 83
      app/Database/Migrations/20181031062503_create_user_variables.php
  4. 79
      app/Database/Migrations/20181031063113_create_login_attempts.php
  5. 80
      app/Database/Migrations/20181031063642_create_login_tokens.php
  6. 78
      app/Database/Migrations/20181031064211_create_groups.php
  7. 83
      app/Database/Migrations/20181031064311_create_group_variables.php
  8. 68
      app/Database/Migrations/20181031064431_create_group_to_user.php
  9. 68
      app/Database/Migrations/20181031064550_create_group_to_group.php
  10. 78
      app/Database/Migrations/20181031064714_create_perms.php
  11. 73
      app/Database/Migrations/20181031065111_create_perm_to_user.php
  12. 73
      app/Database/Migrations/20181031065240_create_perm_to_group.php
  13. 70
      app/Database/Migrations/20181031072542_create_default_groups.php
  14. 86
      app/Database/Migrations/20181031072914_create_default_users.php

82
app/Database/Migrations/20181026042034_create_user_sessions_table.php

@ -0,0 +1,82 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create CI session table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_user_sessions_table extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'VARCHAR',
'constraint' => 128,
'null' => false,
],
'ip_address' => [
'type' => 'VARCHAR',
'constraint' => 45,
'null' => false,
],
'timestamp' => [
'type' => 'INT',
'constraint' => 10,
'unsigned' => true,
'null' => false,
'default' => 0,
],
'data' => [
'type' => 'TEXT',
'null' => false,
'default' => '',
],
]);
$this->forge->addKey('id', true);
$this->forge->addKey('timestamp');
$this->forge->createTable($config->dbTableUserSessions, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableUserSessions, true);
}
}

104
app/Database/Migrations/20181026110732_create_users_table.php

@ -0,0 +1,104 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create users table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_users_table extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => 254,
],
'username' => [
'type' => 'VARCHAR',
'constraint' => 150,
'null' => true,
],
'password' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'banned' => [
'type' => 'TINYINT',
'constraint' => 1,
'null' => true,
'default' => 0,
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'last_activity' => [
'type' => 'DATETIME',
'default' => null,
],
'last_ip_address' => [
'type' => 'VARCHAR',
'constraint' => 39,
'default' => '',
],
'last_login' => [
'type' => 'DATETIME',
'default' => null,
],
'deleted' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableUsers, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableUsers, true);
}
}

83
app/Database/Migrations/20181031062503_create_user_variables.php

@ -0,0 +1,83 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create user variables table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_user_variables extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'data_key' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'data_value' => [
'type' => 'TEXT',
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'system' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableUserVariables, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableUserVariables, true);
}
}

79
app/Database/Migrations/20181031063113_create_login_attempts.php

@ -0,0 +1,79 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create login attempts table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_login_attempts extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'ip_address' => [
'type' => 'VARCHAR',
'constraint' => 39,
'default' => 0,
],
'user_agent' => [
'type' => 'TINYTEXT',
],
'count' => [
'type' => 'TINYINT',
'constraint' => 2,
'default' => 0,
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableLoginAttempts, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableLoginAttempts, true);
}
}

80
app/Database/Migrations/20181031063642_create_login_tokens.php

@ -0,0 +1,80 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create login tokens table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_login_tokens extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'default' => 0,
],
'random_hash' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'selector_hash' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'expires_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableLoginTokens, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableLoginTokens, true);
}
}

78
app/Database/Migrations/20181031064211_create_groups.php

@ -0,0 +1,78 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create group tables
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_groups extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'definition' => [
'type' => 'TEXT',
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'deleted' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableGroups, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableGroups, true);
}
}

83
app/Database/Migrations/20181031064311_create_group_variables.php

@ -0,0 +1,83 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create group variables table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_group_variables extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'data_key' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'data_value' => [
'type' => 'TEXT',
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'system' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTableGroupVariables, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableGroupVariables, true);
}
}

68
app/Database/Migrations/20181031064431_create_group_to_user.php

@ -0,0 +1,68 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create group to user table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_group_to_user extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
]);
$this->forge->addKey(['group_id', 'user_id'], true);
$this->forge->createTable($config->dbTableGroupToUser, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableGroupToUser, true);
}
}

68
app/Database/Migrations/20181031064550_create_group_to_group.php

@ -0,0 +1,68 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create group to group table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_group_to_group extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'subgroup_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
]);
$this->forge->addKey(['group_id', 'subgroup_id'], true);
$this->forge->createTable($config->dbTableGroupToGroup, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTableGroupToGroup, true);
}
}

78
app/Database/Migrations/20181031064714_create_perms.php

@ -0,0 +1,78 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create perms table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_perms extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => 100,
],
'definition' => [
'type' => 'TEXT',
],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'deleted' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
]);
$this->forge->addKey('id', true);
$this->forge->createTable($config->dbTablePerms, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTablePerms, true);
}
}

73
app/Database/Migrations/20181031065111_create_perm_to_user.php

@ -0,0 +1,73 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create perm to user table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_perm_to_user extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'perm_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'user_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'state' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 1,
],
]);
$this->forge->addKey(['perm_id', 'user_id'], true);
$this->forge->createTable($config->dbTablePermToUser, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTablePermToUser, true);
}
}

73
app/Database/Migrations/20181031065240_create_perm_to_group.php

@ -0,0 +1,73 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create perm to group table
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_perm_to_group extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$this->forge->addField([
'perm_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'group_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'state' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 1,
],
]);
$this->forge->addKey(['perm_id', 'user_id'], true);
$this->forge->createTable($config->dbTablePermToGroup, true);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->forge->dropTable($config->dbTablePermToGroup, true);
}
}

70
app/Database/Migrations/20181031072542_create_default_groups.php

@ -0,0 +1,70 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create default groups
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_default_groups extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$data = [
[
'name' => $config->groupAdmin,
'definition' => 'Administators',
],
[
'name' => $config->groupDefault,
'definition' => 'Users',
],
[
'name' => $config->groupPublic,
'definition' => 'Guests',
],
];
$this->db->table($config->dbTableGroups)->insertBatch($data);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->db->table($config->dbTableGroups)->truncate();
}
}

86
app/Database/Migrations/20181031072914_create_default_users.php

@ -0,0 +1,86 @@
<?php
/**
* CodeIgniter-Aauth
*
* Aauth is a User Authorization Library for CodeIgniter 4.x, which aims to make
* easy some essential jobs such as login, permissions and access operations.
* Despite ease of use, it has also very advanced features like grouping,
* access management, public access etc..
*
* @package CodeIgniter-Aauth
* @author Emre Akay
* @author Raphael "REJack" Jackstadt
* @copyright 2014-2019 Emre Akay
* @license https://opensource.org/licenses/MIT MIT License
* @link https://github.com/emreakay/CodeIgniter-Aauth
*/
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use Config\Aauth as AauthConfig;
/**
* Create default admin
*
* @package CodeIgniter-Aauth
*
* @codeCoverageIgnore
*/
class Migration_create_default_users extends Migration
{
/**
* Create Table
*
* @return void
*/
public function up()
{
$config = new AauthConfig();
$data = [
[
'username' => 'admin',
'email' => '[email protected]',
'password' => password_hash('password123456', $config->passwordHashAlgo, $config->passwordHashOptions),
],
[
'username' => 'user',
'email' => '[email protected]',
'password' => password_hash('password123456', $config->passwordHashAlgo, $config->passwordHashOptions),
],
];
$this->db->table($config->dbTableUsers)->insertBatch($data);
$data = [
[
'group_id' => 1,
'user_id' => 1,
],
[
'group_id' => 2,
'user_id' => 1,
],
[
'group_id' => 2,
'user_id' => 2,
],
];
$this->db->table($config->dbTableGroupToUser)->insertBatch($data);
}
//--------------------------------------------------------------------
/**
* Drops Table
*
* @return void
*/
public function down()
{
$config = new AauthConfig();
$this->db->table($config->dbTableUsers)->truncate();
$this->db->table($config->dbTableGroupToUser)->truncate();
}
}
Loading…
Cancel
Save