Skip to content

Commit c0c2135

Browse files
author
Angel Garcia
committed
Modified initial migration to create user Table
1 parent 2f1a60f commit c0c2135

File tree

6 files changed

+41
-32
lines changed

6 files changed

+41
-32
lines changed

.idea/php.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/yii2-api-template.iml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/config/main.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@
6767
],
6868
],
6969
'params' => $params,
70-
// TODO Check this Migration Controller
71-
// 'controllerMap' => [
72-
// 'migration' => [
73-
// 'class' => 'bizley\migration\controllers\MigrationController',
74-
// ],
75-
// ],
70+
'controllerMap' => [
71+
'migration' => [
72+
'class' => 'bizley\migration\controllers\MigrationController',
73+
],
74+
],
7675

7776

7877
];

api/web/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/index.php
22
/index-test.php
3+
/assets/*

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"php": ">=5.4.0",
2121
"yiisoft/yii2": "~2.0.14",
2222
"yiisoft/yii2-bootstrap": "~2.0.0",
23-
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0"
23+
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
24+
"bizley/migration": "^3.0"
2425
},
2526
"require-dev": {
2627
"yiisoft/yii2-debug": "~2.0.0",
Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
<?php
22

3-
use yii\db\Migration;
3+
use yii\db\Migration;
44

5-
class m130524_201442_init extends Migration
5+
class m130524_201442_init extends Migration
6+
{
7+
public function up()
68
{
7-
public function up()
8-
{
9-
$tableOptions = null;
10-
if ($this->db->driverName === 'mysql') {
11-
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
12-
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
13-
}
9+
$tableOptions = null;
10+
if ($this->db->driverName === 'mysql') {
11+
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
12+
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
13+
}
1414

15-
$this->createTable('{{%user}}', [
16-
'id' => $this->primaryKey(),
17-
'username' => $this->string()->notNull()->unique(),
18-
'auth_key' => $this->string(32)->notNull(),
19-
'password_hash' => $this->string()->notNull(),
20-
'password_reset_token' => $this->string()->unique(),
21-
'email' => $this->string()->notNull()->unique(),
15+
$this->createTable('{{%user}}', [
16+
'id' => $this->string(36)->notNull(),
17+
'username' => $this->string()->notNull()->unique(),
18+
'auth_key' => $this->string(32)->notNull(),
19+
'access_token' => $this->string(32)->notNull(),
20+
'refresh_token' => $this->string(32)->notNull(),
21+
'password_hash' => $this->string()->notNull(),
22+
'password_reset_token' => $this->string()->unique(),
23+
'email' => $this->string()->notNull()->unique(),
2224

23-
'status' => $this->smallInteger()->notNull()->defaultValue(10),
24-
'created_at' => $this->integer()->notNull(),
25-
'updated_at' => $this->integer()->notNull(),
26-
], $tableOptions);
27-
}
25+
'status' => $this->smallInteger()->notNull()->defaultValue(10),
26+
'created_at' => $this->integer(13)->notNull(),
27+
'updated_at' => $this->integer(13)->notNull(),
28+
'created_by' => $this->string(36)->notNull(),
29+
'updated_by' => $this->string(36)->notNull(),
30+
], $tableOptions);
2831

29-
public function down()
30-
{
31-
$this->dropTable('{{%user}}');
32-
}
32+
$this->addPrimaryKey('user_pk', '{{%user}}', ['id']);
33+
}
34+
35+
public function down()
36+
{
37+
$this->dropTable('{{%user}}');
3338
}
39+
}

0 commit comments

Comments
 (0)