Описана базовая миграция, добавлена модель аккаунта, добавлена модель авторизации, написаны первичные тесты для этой модели, добавлен модуль авторизации, настроен базовый контроллер. Короче много чего сделано

This commit is contained in:
ErickSkrauch
2016-01-03 03:18:37 +03:00
parent 841303b8ab
commit 7b650e2654
40 changed files with 694 additions and 292 deletions

View File

@@ -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
View 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;
}
}

View File

@@ -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}}');
}
}

View 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() {
}
}