Completed
Push — master ( 6daf10...1140ad )
by Anton
13s
created

DefaultUsers   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 68
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 53 1
A down() 0 5 1
1
<?php
2
3
use Phinx\Migration\AbstractMigration;
4
5
class DefaultUsers extends AbstractMigration
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * Migrate Up.
9
     */
10
    public function up()
11
    {
12
        $data = [
13
            [
14
                'id' => 1,
15
                'login' => 'system',
16
                'email' => 'system@localhost',
17
                'created' => date('Y-m-d H:i:s'),
18
                'status' => 'disabled'
19
            ],
20
            [
21
                'id' => 2,
22
                'login' => 'admin',
23
                'email' => 'admin@localhost',
24
                'created' => date('Y-m-d H:i:s'),
25
                'status' => 'active'
26
            ],
27
            [
28
                'id' => 3,
29
                'login' => 'member',
30
                'email' => 'member@localhost',
31
                'created' => date('Y-m-d H:i:s'),
32
                'status' => 'active'
33
            ],
34
        ];
35
36
        $users = $this->table('users');
37
        $users->insert($data)
38
            ->save();
39
40
        $data = [
41
            [
42
                'userId' => 2,
43
                'provider' => 'equals',
44
                'foreignKey' => 'admin',
45
                'token' => '$2y$10$4a454775178c3f89d510fud2T.xtw01Ir.Jo.91Dr3nL2sz3OyVpK', // admin
46
                'tokenType' => 'access',
47
                'created' => date('Y-m-d H:i:s')
48
            ],
49
            [
50
                'userId' => 3,
51
                'provider' => 'equals',
52
                'foreignKey' => 'member',
53
                'token' => '$2y$10$poVyazyQKXlfsGuUwxj/su.w0nnNJKzgyQyAnN3zjx9In3BaBeusq', // member
54
                'tokenType' => 'access',
55
                'created' => date('Y-m-d H:i:s')
56
            ],
57
        ];
58
59
        $auth = $this->table('auth');
60
        $auth->insert($data)
61
            ->save();
62
    }
63
64
    /**
65
     * Migrate Down.
66
     */
67
    public function down()
68
    {
69
        $this->execute('DELETE FROM auth');
70
        $this->execute('DELETE FROM users');
71
    }
72
}
73