Skip to content

Commit 55ae4cf

Browse files
committed
fix migrations
1 parent 0f77a43 commit 55ae4cf

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Yii2 App
22

3-
Yii2-app is my advanced project template.
3+
Yii2-app is Fast and Ready-to-production advanced project template.
44

55
Default, the template includes three tiers: `frontend`, `backend`, and `console`, each of which is a separate Yii application.
66
> **NOTE:** Template is in initial development. Anything may change at any time.
@@ -29,7 +29,7 @@ After installation run `init`
2929

3030
### Migrations
3131

32-
Make sure that you have properly configured `db` application component and run the following command
32+
> **NOTE:** Make sure that you have properly configured `db` application component and run the following command
3333
3434
```
3535
php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations

console/config/main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'class' => 'yii\console\controllers\MigrateController',
2525
//'migrationPath' => null,
2626
'migrationNamespaces' => [
27-
// ...
27+
'console\migrations',
2828
'yii\queue\db\migrations',
2929
],
3030
],
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace console\migrations;
4+
5+
use yii\db\Migration;
6+
7+
/**
8+
* Class M180422195051Insert_adminus
9+
*/
10+
class M180422195051Insert_adminus extends Migration
11+
{
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
public function safeUp()
16+
{
17+
$this->insert('{{%user}}', [
18+
'id' => 1,
19+
'username' => 'adminus',
20+
'email' => 'admin@admin.ru',
21+
'password_hash' => '$2y$12$BJu3H91IIWNKhcmfK7QnkeUUB90FTEl4xb12cVvWAuV6dJXGho8JS',
22+
'auth_key' => 'vYghSpiPCeP60_jCLo9hIVrGlFUMY3xJ',
23+
'confirmed_at' => '1524426563',
24+
'created_at' => '1524426563',
25+
'updated_at' => '1524426563',
26+
'flags' => '0',
27+
]);
28+
29+
$this->insert('{{%profile}}', [
30+
'user_id' => '1'
31+
]);
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function safeDown()
38+
{
39+
$this->delete('{{%user}}', ['id' => 1]);
40+
$this->delete('{{%profile}}', ['id' => 1]);
41+
42+
return true;
43+
}
44+
45+
/*
46+
// Use up()/down() to run migration code without a transaction.
47+
public function up()
48+
{
49+
50+
}
51+
52+
public function down()
53+
{
54+
echo "M180422195051Insert_adminus cannot be reverted.\n";
55+
56+
return false;
57+
}
58+
*/
59+
}

console/migrations/m180422_170849_create_email_form_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
namespace console\migrations;
23

34
use yii\db\Migration;
45

0 commit comments

Comments
 (0)