|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace DoctrineMigrations; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
6
|
|
|
use Doctrine\Migrations\AbstractMigration; |
|
7
|
|
|
|
|
8
|
|
|
final class Version20180804082737 extends AbstractMigration |
|
9
|
|
|
{ |
|
10
|
|
|
public function up(Schema $schema): void |
|
11
|
|
|
{ |
|
12
|
|
|
$pass = ''; |
|
13
|
|
|
$roles = '["ROLE_USER","ROLE_ADMIN"]'; |
|
14
|
|
|
$this->addSql("INSERT INTO users_profiles (id, first_name, last_name, birth_date, about, public_email) VALUES (1, 'Support', 'Support', NULL, NULL, '[email protected]')"); |
|
15
|
|
|
$this->addSql("INSERT INTO users (id, profile_id, email, is_email_confirmed, username, password, roles) VALUES (1, 1, '[email protected]', 1, 'support', '$pass', '$roles')"); |
|
16
|
|
|
|
|
17
|
|
|
$genresJson = $this->getGenresJson(); |
|
18
|
|
|
$genres = json_decode($genresJson, true); |
|
19
|
|
|
|
|
20
|
|
|
foreach ($genres as $genre) { |
|
21
|
|
|
$this->addSql("INSERT INTO genres (id, tmdb_id) VALUES (NEXTVAL('genres_id_seq'), {$genre['id']})"); |
|
22
|
|
|
|
|
23
|
|
|
foreach ($genre['translations'] as $locale => $name) { |
|
24
|
|
|
$this->addSql("INSERT INTO genres_translations (id, genre_id, locale, \"name\") VALUES (NEXTVAL('genres_translations_id_seq'), CURRVAL('genres_id_seq'), '$locale', '$name')"); |
|
25
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function down(Schema $schema): void |
|
31
|
|
|
{ |
|
32
|
|
|
$this->addSql('DELETE FROM users WHERE id = 1'); |
|
33
|
|
|
$this->addSql('DELETE FROM users_profiles WHERE id = 1'); |
|
34
|
|
|
$this->addSql('DELETE FROM genres WHERE tmdb_id > 0'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
private function getGenresJson(): string |
|
38
|
|
|
{ |
|
39
|
|
|
return <<<JSON |
|
40
|
|
|
[ |
|
41
|
|
|
{ |
|
42
|
|
|
"id": 28, |
|
43
|
|
|
"name": "Action", |
|
44
|
|
|
"translations": { |
|
45
|
|
|
"en": "Action", |
|
46
|
|
|
"ru": "Экшн", |
|
47
|
|
|
"uk": "Екшн", |
|
48
|
|
|
"pl": "Action" |
|
49
|
|
|
} |
|
50
|
|
|
}, |
|
51
|
|
|
{ |
|
52
|
|
|
"id": 12, |
|
53
|
|
|
"name": "Adventure", |
|
54
|
|
|
"translations": { |
|
55
|
|
|
"en": "Adventure", |
|
56
|
|
|
"ru": "Приключения", |
|
57
|
|
|
"uk": "Пригоди", |
|
58
|
|
|
"pl": "Adventure" |
|
59
|
|
|
} |
|
60
|
|
|
}, |
|
61
|
|
|
{ |
|
62
|
|
|
"id": 16, |
|
63
|
|
|
"name": "Animation", |
|
64
|
|
|
"translations": { |
|
65
|
|
|
"en": "Animation", |
|
66
|
|
|
"ru": "Анимация", |
|
67
|
|
|
"uk": "Анімація", |
|
68
|
|
|
"pl": "Animation" |
|
69
|
|
|
} |
|
70
|
|
|
}, |
|
71
|
|
|
{ |
|
72
|
|
|
"id": 35, |
|
73
|
|
|
"name": "Comedy", |
|
74
|
|
|
"translations": { |
|
75
|
|
|
"en": "Comedy", |
|
76
|
|
|
"ru": "Комедия", |
|
77
|
|
|
"uk": "Комедія", |
|
78
|
|
|
"pl": "Comedy" |
|
79
|
|
|
} |
|
80
|
|
|
}, |
|
81
|
|
|
{ |
|
82
|
|
|
"id": 80, |
|
83
|
|
|
"name": "Crime", |
|
84
|
|
|
"translations": { |
|
85
|
|
|
"en": "Crime", |
|
86
|
|
|
"ru": "Криминальный", |
|
87
|
|
|
"uk": "Кримінальний", |
|
88
|
|
|
"pl": "Crime" |
|
89
|
|
|
} |
|
90
|
|
|
}, |
|
91
|
|
|
{ |
|
92
|
|
|
"id": 99, |
|
93
|
|
|
"name": "Documentary", |
|
94
|
|
|
"translations": { |
|
95
|
|
|
"en": "Documentary", |
|
96
|
|
|
"ru": "Документальный", |
|
97
|
|
|
"uk": "Документальний", |
|
98
|
|
|
"pl": "Documentary" |
|
99
|
|
|
} |
|
100
|
|
|
}, |
|
101
|
|
|
{ |
|
102
|
|
|
"id": 18, |
|
103
|
|
|
"name": "Drama", |
|
104
|
|
|
"translations": { |
|
105
|
|
|
"en": "Drama", |
|
106
|
|
|
"ru": "Драма", |
|
107
|
|
|
"uk": "Драма", |
|
108
|
|
|
"pl": "Drama" |
|
109
|
|
|
} |
|
110
|
|
|
}, |
|
111
|
|
|
{ |
|
112
|
|
|
"id": 10751, |
|
113
|
|
|
"name": "Family", |
|
114
|
|
|
"translations": { |
|
115
|
|
|
"en": "Family", |
|
116
|
|
|
"ru": "Семейный", |
|
117
|
|
|
"uk": "Сімейний", |
|
118
|
|
|
"pl": "Family" |
|
119
|
|
|
} |
|
120
|
|
|
}, |
|
121
|
|
|
{ |
|
122
|
|
|
"id": 14, |
|
123
|
|
|
"name": "Fantasy", |
|
124
|
|
|
"translations": { |
|
125
|
|
|
"en": "Fantasy", |
|
126
|
|
|
"ru": "Фэнтези", |
|
127
|
|
|
"uk": "Фентезі", |
|
128
|
|
|
"pl": "Fantasy" |
|
129
|
|
|
} |
|
130
|
|
|
}, |
|
131
|
|
|
{ |
|
132
|
|
|
"id": 36, |
|
133
|
|
|
"name": "History", |
|
134
|
|
|
"translations": { |
|
135
|
|
|
"en": "History", |
|
136
|
|
|
"ru": "Исторический", |
|
137
|
|
|
"uk": "Історичний", |
|
138
|
|
|
"pl": "History" |
|
139
|
|
|
} |
|
140
|
|
|
}, |
|
141
|
|
|
{ |
|
142
|
|
|
"id": 27, |
|
143
|
|
|
"name": "Horror", |
|
144
|
|
|
"translations": { |
|
145
|
|
|
"en": "Horror", |
|
146
|
|
|
"ru": "Ужасы", |
|
147
|
|
|
"uk": "Жахи", |
|
148
|
|
|
"pl": "Horror" |
|
149
|
|
|
} |
|
150
|
|
|
}, |
|
151
|
|
|
{ |
|
152
|
|
|
"id": 10402, |
|
153
|
|
|
"name": "Music", |
|
154
|
|
|
"translations": { |
|
155
|
|
|
"en": "Music", |
|
156
|
|
|
"ru": "Мюзикл", |
|
157
|
|
|
"uk": "Мюзікл", |
|
158
|
|
|
"pl": "Music" |
|
159
|
|
|
} |
|
160
|
|
|
}, |
|
161
|
|
|
{ |
|
162
|
|
|
"id": 9648, |
|
163
|
|
|
"name": "Mystery", |
|
164
|
|
|
"translations": { |
|
165
|
|
|
"en": "Mystery", |
|
166
|
|
|
"ru": "Мистика", |
|
167
|
|
|
"uk": "Містика", |
|
168
|
|
|
"pl": "Mystery" |
|
169
|
|
|
} |
|
170
|
|
|
}, |
|
171
|
|
|
{ |
|
172
|
|
|
"id": 10749, |
|
173
|
|
|
"name": "Romance", |
|
174
|
|
|
"translations": { |
|
175
|
|
|
"en": "Romance", |
|
176
|
|
|
"ru": "Роман", |
|
177
|
|
|
"uk": "Роман", |
|
178
|
|
|
"pl": "Romance" |
|
179
|
|
|
} |
|
180
|
|
|
}, |
|
181
|
|
|
{ |
|
182
|
|
|
"id": 878, |
|
183
|
|
|
"name": "Science Fiction", |
|
184
|
|
|
"translations": { |
|
185
|
|
|
"en": "Science Fiction", |
|
186
|
|
|
"ru": "Научно-популярный", |
|
187
|
|
|
"uk": "Науково-популярний", |
|
188
|
|
|
"pl": "Science Fiction" |
|
189
|
|
|
} |
|
190
|
|
|
}, |
|
191
|
|
|
{ |
|
192
|
|
|
"id": 10770, |
|
193
|
|
|
"name": "TV Movie", |
|
194
|
|
|
"translations": { |
|
195
|
|
|
"en": "TV Movie", |
|
196
|
|
|
"ru": "Телесериал", |
|
197
|
|
|
"uk": "Телесеріал", |
|
198
|
|
|
"pl": "TV Movie" |
|
199
|
|
|
} |
|
200
|
|
|
}, |
|
201
|
|
|
{ |
|
202
|
|
|
"id": 53, |
|
203
|
|
|
"name": "Thriller", |
|
204
|
|
|
"translations": { |
|
205
|
|
|
"en": "Thriller", |
|
206
|
|
|
"ru": "Триллер", |
|
207
|
|
|
"uk": "Триллер", |
|
208
|
|
|
"pl": "Thriller" |
|
209
|
|
|
} |
|
210
|
|
|
}, |
|
211
|
|
|
{ |
|
212
|
|
|
"id": 10752, |
|
213
|
|
|
"name": "War", |
|
214
|
|
|
"translations": { |
|
215
|
|
|
"en": "War", |
|
216
|
|
|
"ru": "Военный", |
|
217
|
|
|
"uk": "Військовий", |
|
218
|
|
|
"pl": "War" |
|
219
|
|
|
} |
|
220
|
|
|
}, |
|
221
|
|
|
{ |
|
222
|
|
|
"id": 37, |
|
223
|
|
|
"name": "Western", |
|
224
|
|
|
"translations": { |
|
225
|
|
|
"en": "Western", |
|
226
|
|
|
"ru": "Вестерн", |
|
227
|
|
|
"uk": "Вестерн", |
|
228
|
|
|
"pl": "Western" |
|
229
|
|
|
} |
|
230
|
|
|
} |
|
231
|
|
|
] |
|
232
|
|
|
JSON; |
|
233
|
|
|
|
|
234
|
|
|
} |
|
235
|
|
|
} |
|
236
|
|
|
|