Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

install_app_table-2016-12-04-15-31-46.php (1 issue)

1
<?php
2
3
use Ffcms\Core\Migrations\MigrationInterface;
4
use Ffcms\Core\Migrations\Migration;
5
6
/**
7
 * Class install_app_table.
8
 */
9
class install_app_table extends Migration implements MigrationInterface
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...
10
{
11
    /**
12
     * Execute actions when migration is up
13
     * @return void
14
     */
15
    public function up()
16
    {
17
        $this->getSchema()->create('apps', function($table) {
18
            $table->increments('id');
19
            $table->enum('type', ['widget', 'app']);
20
            $table->string('sys_name');
21
            $table->text('name');
22
            $table->text('configs')->nullable();
23
            $table->boolean('disabled')->default(false);
24
            $table->string('version', 32)->default('1.0.0'); // symantic version style
25
            $table->timestamps();
26
        });
27
        parent::up();
28
    }
29
30
    /**
31
     * Seed created table via up() method with some data
32
     * @return void
33
     */
34
    public function seed()
35
    {
36
        $now = date('Y-m-d H:i:s', time());
37
38
        $configs = new stdClass();
39
        $names = new stdClass();
40
41
        $configs->user = serialize([
42
            'registrationType' => 1, // 0 = invites, 1 = validation via email, 2 = full open without validation
43
            'captchaOnLogin' => 0,
44
            'captchaOnRegister' => 1
45
        ]);
46
47
        $configs->profile = serialize([
48
            'guestView' => 1,
49
            'wallPostOnPage' => 5,
50
            'wallPostOnFeed' => 10,
51
            'delayBetweenPost' => 30,
52
            'rating' => 1,
53
            'ratingDelay' => 60 * 60 * 24,
54
            'usersOnPage' => 10
55
        ]);
56
57
        $configs->content = serialize([
58
            'itemPerCategory' => 10,
59
            'userAdd' => 0,
60
            'multiCategories' => 1,
61
            'rss' => 1,
62
            'gallerySize' => 500,
63
            'galleryResize' => 250
64
        ]);
65
66
        $configs->feedback = serialize([
67
            'useCaptcha' => 1,
68
            'guestAdd' => 1
69
        ]);
70
71
        $configs->comments = serialize([
72
            'perPage' => 10,
73
            'delay' => 60,
74
            'minLength' => 10,
75
            'maxLength' => 5000,
76
            'guestAdd' => 0,
77
            'guestModerate' => 1,
78
            'onlyLocale' => 0
79
        ]);
80
81
        $configs->newcontent = serialize([
82
            'categories' => ['2','3'],
83
            'count' => '5',
84
            'cache' => '60'
85
        ]);
86
87
        $configs->contenttag = serialize([
88
            'count' => 10,
89
            'cache' => 120
90
        ]);
91
92
        $configs->newcomment = serialize([
93
            'snippet' => 50,
94
            'count' => 5,
95
            'cache' => 60
96
        ]);
97
98
        $configs->search = serialize([
99
            'itemPerApp' => 10,
100
            'minLength' => 3
101
        ]);
102
103
        $names->user = serialize([
104
            'en' => 'User identity',
105
            'ru' => 'Идентификация пользователя'
106
        ]);
107
108
        $names->profile = serialize([
109
            'en' => 'User profiles',
110
            'ru' => 'Профили пользователей'
111
        ]);
112
113
        $names->content = serialize([
114
            'en' => 'Content',
115
            'ru' => 'Контент'
116
        ]);
117
118
        $names->feedback = serialize([
119
            'en' => 'Feedback',
120
            'ru' => 'Обратная связь'
121
        ]);
122
123
        $names->comments = serialize([
124
            'en' => 'Comments',
125
            'ru' => 'Комментарии'
126
        ]);
127
128
        $names->newcontent = serialize([
129
            'en' => 'New content',
130
            'ru' => 'Новый контент'
131
        ]);
132
133
        $names->contenttag = serialize([
134
            'en' => 'Content tags',
135
            'ru' => 'Метки контента'
136
        ]);
137
138
        $names->newcomment = serialize([
139
            'en' => 'New comments',
140
            'ru' => 'Новые комментарии'
141
        ]);
142
143
        $names->search = serialize([
144
            'en' => 'Search',
145
            'ru' => 'Поиск'
146
        ]);
147
148
        $names->sitemap = serialize([
149
            'en' => 'Sitemap',
150
            'ru' => 'Карта сайта'
151
        ]);
152
153
        $this->getConnection()->table('apps')->insert([
154
            ['type' => 'app', 'sys_name' => 'User', 'name' => $names->user, 'configs' => $configs->user, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
155
            ['type' => 'app', 'sys_name' => 'Profile', 'name' => $names->profile, 'configs' => $configs->profile, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
156
            ['type' => 'app', 'sys_name' => 'Content', 'name' => $names->content, 'configs' => $configs->content, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
157
            ['type' => 'app', 'sys_name' => 'Feedback', 'name' => $names->feedback, 'configs' => $configs->feedback, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
158
            ['type' => 'app', 'sys_name' => 'Search', 'name' => $names->search, 'configs' => $configs->search, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
159
            ['type' => 'app', 'sys_name' => 'Sitemap', 'name' => $names->sitemap, 'configs' => '', 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
160
            ['type' => 'widget', 'sys_name' => 'Comments', 'name' => $names->comments, 'configs' => $configs->comments, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
161
            ['type' => 'widget', 'sys_name' => 'Newcontent', 'name' => $names->newcontent, 'configs' => $configs->newcontent, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
162
            ['type' => 'widget', 'sys_name' => 'Contenttag', 'name' => $names->contenttag, 'configs' => $configs->contenttag, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now],
163
            ['type' => 'widget', 'sys_name' => 'Newcomment', 'name' => $names->newcomment, 'configs' => $configs->newcomment, 'version' => '1.0.0', 'created_at' => $now, 'updated_at' => $now]
164
        ]);
165
166
    }
167
168
    /**
169
     * Execute actions when migration is down
170
     * @return void
171
     */
172
    public function down()
173
    {
174
        $this->getSchema()->dropIfExists('apps');
175
        parent::down();
176
    }
177
}