mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Описана базовая миграция, добавлена модель аккаунта, добавлена модель авторизации, написаны первичные тесты для этой модели, добавлен модуль авторизации, настроен базовый контроллер. Короче много чего сделано
This commit is contained in:
@@ -21,5 +21,11 @@ return [
|
||||
],
|
||||
],
|
||||
],
|
||||
'controllerMap' => [
|
||||
'migrate' => [
|
||||
'class' => 'yii\console\controllers\MigrateController',
|
||||
'templateFile' => '@console/views/migration.php',
|
||||
],
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
||||
|
21
console/db/Migration.php
Normal file
21
console/db/Migration.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace console\db;
|
||||
|
||||
use yii\db\Migration as YiiMigration;
|
||||
|
||||
/**
|
||||
* @property string $tableOptions
|
||||
*/
|
||||
class Migration extends YiiMigration {
|
||||
|
||||
public function getTableOptions($engine = 'InnoDB') {
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=' . $engine;
|
||||
}
|
||||
|
||||
return $tableOptions;
|
||||
}
|
||||
|
||||
}
|
@@ -1,34 +1,26 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
use console\db\Migration;
|
||||
|
||||
class m130524_201442_init extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
class m130524_201442_init extends Migration {
|
||||
|
||||
$this->createTable('{{%user}}', [
|
||||
public function up() {
|
||||
$this->createTable('{{%accounts}}', [
|
||||
'id' => $this->primaryKey(),
|
||||
'username' => $this->string()->notNull()->unique(),
|
||||
'auth_key' => $this->string(32)->notNull(),
|
||||
'password_hash' => $this->string()->notNull(),
|
||||
'password_reset_token' => $this->string()->unique(),
|
||||
'uuid' => $this->string(36)->notNull(),
|
||||
'email' => $this->string()->notNull()->unique(),
|
||||
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||
'password_hash' => $this->string()->notNull(),
|
||||
'password_hash_strategy' => $this->smallInteger()->notNull(),
|
||||
'password_reset_token' => $this->string()->unique(),
|
||||
'status' => $this->smallInteger()->notNull()->defaultValue(0),
|
||||
'auth_key' => $this->string(32)->notNull(),
|
||||
'created_at' => $this->integer()->notNull(),
|
||||
'updated_at' => $this->integer()->notNull(),
|
||||
], $tableOptions);
|
||||
], $this->tableOptions);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dropTable('{{%user}}');
|
||||
public function down() {
|
||||
$this->dropTable('{{%accounts}}');
|
||||
}
|
||||
|
||||
}
|
||||
|
19
console/views/migration.php
Normal file
19
console/views/migration.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/* @var $className string the new migration class name */
|
||||
|
||||
echo "<?php\n";
|
||||
?>
|
||||
|
||||
use console\db\Migration;
|
||||
|
||||
class <?= $className ?> extends Migration {
|
||||
|
||||
public function safeUp() {
|
||||
|
||||
}
|
||||
|
||||
public function safeDown() {
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user