Conditions | 6 |
Paths | 16 |
Total Lines | 585 |
Code Lines | 435 |
Lines | 0 |
Ratio | 0 % |
Changes | 9 | ||
Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
167 | private static function initSchema(Connection $connection): void |
||
168 | { |
||
169 | $fromSchema = $connection->getSchemaManager()->createSchema(); |
||
170 | $toSchema = clone $fromSchema; |
||
171 | |||
172 | $db = new TdbmFluidSchema($toSchema, new \TheCodingMachine\FluidSchema\DefaultNamingStrategy($connection->getDatabasePlatform())); |
||
173 | |||
174 | $db->table('country') |
||
175 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
176 | ->column('label')->string(255)->unique(); |
||
177 | |||
178 | $db->table('person') |
||
179 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
180 | ->column('name')->string(255); |
||
181 | |||
182 | if ($connection->getDatabasePlatform() instanceof OraclePlatform) { |
||
183 | $toSchema->getTable($connection->quoteIdentifier('person')) |
||
184 | ->addColumn( |
||
185 | $connection->quoteIdentifier('created_at'), |
||
186 | 'datetime', |
||
187 | ['columnDefinition' => 'TIMESTAMP(0) DEFAULT SYSDATE NOT NULL'] |
||
188 | ); |
||
189 | } else { |
||
190 | $toSchema->getTable('person') |
||
191 | ->addColumn( |
||
192 | $connection->quoteIdentifier('created_at'), |
||
193 | 'datetime', |
||
194 | ['columnDefinition' => 'timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP'] |
||
195 | ); |
||
196 | } |
||
197 | |||
198 | $db->table('person') |
||
199 | ->column('modified_at')->datetime()->null()->index() |
||
200 | ->column('order')->integer()->null(); |
||
201 | |||
202 | |||
203 | $db->table('contact') |
||
204 | ->extends('person') |
||
205 | ->column('email')->string(255) |
||
206 | ->column('manager_id')->references('contact')->null(); |
||
207 | |||
208 | $db->table('users') |
||
209 | ->addAnnotation('AddTrait', ['name'=>TestUserTrait::class], false) |
||
210 | ->addAnnotation('AddTrait', ['name'=>TestOtherUserTrait::class, 'modifiers'=>['\\'.TestOtherUserTrait::class.'::method1 insteadof \\'.TestUserTrait::class, '\\'.TestUserTrait::class.'::method1 as method1renamed']], false) |
||
211 | ->addAnnotation('AddTraitOnDao', ['name'=>TestUserDaoTrait::class], false) |
||
212 | ->implementsInterface(TestUserInterface::class) |
||
213 | ->implementsInterfaceOnDao(TestUserDaoInterface::class) |
||
214 | ->extends('contact') |
||
215 | ->column('login')->string(255) |
||
216 | ->column('password')->string(255)->null() |
||
217 | ->column('status')->string(10)->null()->default(null) |
||
218 | ->column('country_id')->references('country') |
||
219 | // Used to test generation for a column that starts with a digit |
||
220 | ->then()->column('3d_view')->boolean()->default(true); |
||
221 | |||
222 | $db->table('rights') |
||
223 | ->column('label')->string(255)->primaryKey()->comment('Non autoincrementable primary key'); |
||
224 | |||
225 | $db->table('roles') |
||
226 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
227 | ->column('name')->string(255) |
||
228 | ->column('created_at')->date()->null() |
||
229 | ->column('status')->boolean()->null()->default(1); |
||
230 | |||
231 | $db->table('roles_rights') |
||
232 | ->column('role_id')->references('roles') |
||
233 | ->column('right_label')->references('rights')->then() |
||
234 | ->primaryKey(['role_id', 'right_label']); |
||
235 | |||
236 | $db->table('users_roles') |
||
237 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
238 | ->column('user_id')->references('users') |
||
239 | ->column('role_id')->references('roles'); |
||
240 | |||
241 | $db->table('all_nullable') |
||
242 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
243 | ->column('label')->string(255)->null() |
||
244 | ->column('country_id')->references('country')->null(); |
||
245 | |||
246 | $db->table('animal') |
||
247 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
248 | ->column('name')->string(45)->index() |
||
249 | ->column('UPPERCASE_COLUMN')->string(45)->null() |
||
250 | ->column('order')->integer()->null(); |
||
251 | |||
252 | $db->table('dog') |
||
253 | ->extends('animal') |
||
254 | ->column('race')->string(45)->null(); |
||
255 | |||
256 | $db->table('cat') |
||
257 | ->extends('animal') |
||
258 | ->column('cuteness_level')->integer()->null(); |
||
259 | |||
260 | $db->table('panda') |
||
261 | ->extends('animal') |
||
262 | ->column('weight')->float()->null(); |
||
263 | |||
264 | $db->table('boats') |
||
265 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
266 | ->column('name')->string(255) |
||
267 | ->column('anchorage_country')->references('country')->notNull()->then() |
||
268 | ->column('current_country')->references('country')->null()->then() |
||
269 | ->column('length')->decimal(10, 2)->null()->then() |
||
270 | ->unique(['anchorage_country', 'name']); |
||
271 | |||
272 | $db->table('sailed_countries') |
||
273 | ->column('boat_id')->references('boats') |
||
274 | ->column('country_id')->references('country') |
||
275 | ->then()->primaryKey(['boat_id', 'country_id']); |
||
276 | |||
277 | $db->table('category') |
||
278 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
279 | ->column('label')->string(255) |
||
280 | ->column('parent_id')->references('category')->null(); |
||
281 | |||
282 | $db->table('article') |
||
283 | ->column('id')->string(36)->primaryKey()->comment('@UUID') |
||
284 | ->column('content')->string(255) |
||
285 | ->column('author_id')->references('users')->null() |
||
286 | ->column('attachment')->blob()->null(); |
||
287 | |||
288 | $db->table('article2') |
||
289 | ->column('id')->string(36)->primaryKey()->comment('@UUID v4') |
||
290 | ->column('content')->string(255); |
||
291 | |||
292 | $db->table('files') |
||
293 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
294 | ->column('file')->blob() |
||
295 | ->column('md5')->string()->null()->comment("@ProtectedGetter\n@ProtectedSetter") |
||
296 | ->column('article_id')->references('article')->null()->comment("@ProtectedGetter\n@ProtectedSetter\n@ProtectedOneToMany"); |
||
297 | |||
298 | $toSchema->getTable('users') |
||
299 | ->addUniqueIndex([$connection->quoteIdentifier('login')], 'users_login_idx') |
||
300 | ->addIndex([$connection->quoteIdentifier('status'), $connection->quoteIdentifier('country_id')], 'users_status_country_idx'); |
||
301 | |||
302 | // We create the same index twice |
||
303 | // except for Oracle that won't let us create twice the same index. |
||
304 | if (!$connection->getDatabasePlatform() instanceof OraclePlatform) { |
||
305 | $toSchema->getTable('users') |
||
306 | ->addUniqueIndex([$connection->quoteIdentifier('login')], 'users_login_idx_2'); |
||
307 | } |
||
308 | |||
309 | // A table with a foreign key that references a non primary key. |
||
310 | $db->table('ref_no_prim_key') |
||
311 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@Autoincrement') |
||
312 | ->column('from')->string(50) |
||
313 | ->column('to')->string(50)->unique(); |
||
314 | |||
315 | $toSchema->getTable($connection->quoteIdentifier('ref_no_prim_key'))->addForeignKeyConstraint($connection->quoteIdentifier('ref_no_prim_key'), [$connection->quoteIdentifier('from')], [$connection->quoteIdentifier('to')]); |
||
316 | |||
317 | // A table with multiple primary keys. |
||
318 | $db->table('states') |
||
319 | ->column('country_id')->references('country') |
||
320 | ->column('code')->string(3) |
||
321 | ->column('name')->string(50)->then() |
||
322 | ->primaryKey(['country_id', 'code']); |
||
323 | |||
324 | // Tables using @Json annotations |
||
325 | $db->table('accounts') |
||
326 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
327 | ->column('name')->string(); |
||
328 | |||
329 | $db->table('nodes') |
||
330 | ->column('id')->integer()->primaryKey()->autoIncrement()->comment('@JsonIgnore') |
||
331 | ->column('alias_id')->references('nodes')->null()->comment('@JsonRecursive') |
||
332 | ->column('parent_id')->references('nodes')->null()->comment('@JsonInclude') |
||
333 | ->column('root_id')->references('nodes')->null()->comment('@JsonIgnore') |
||
334 | ->column('owner_id')->references('accounts')->null()->comment('@JsonFormat(property="name") @JsonInclude') |
||
335 | ->column('name')->string()->comment('@JsonKey("basename")') |
||
336 | ->column('size')->integer()->notNull()->default(0)->comment('@JsonFormat(unit=" o")') |
||
337 | ->column('weight')->float()->null()->comment('@JsonFormat(decimals=2,unit="g")') |
||
338 | ->column('created_at')->date()->null()->comment('@JsonFormat("Y-m-d")'); |
||
339 | |||
340 | $db->table('nodes_guests') |
||
341 | ->column('node_id')->references('nodes')->comment('@JsonIgnore') |
||
342 | ->column('guest_id')->references('accounts')->comment('@JsonKey("guests") @JsonFormat(method="getName")'); |
||
343 | |||
344 | $db->table('node_entries') |
||
345 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
346 | ->column('node_id')->references('nodes')->comment('@JsonCollection("entries") @JsonFormat(property="entry")') |
||
347 | ->column('entry')->string()->null(); |
||
348 | |||
349 | $db->table('artists') |
||
350 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
351 | ->column('children')->array()->null() //used to test conflicts with autopivot |
||
352 | ->column('name')->string(); |
||
353 | |||
354 | $db->table('albums') |
||
355 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
356 | ->column('artist_id')->references('artists')->comment('@JsonCollection(key="discography")') |
||
357 | ->column('account_id')->references('accounts') |
||
358 | ->column('node_id')->references('nodes')->null() |
||
359 | ->column('title')->string() |
||
360 | ->then()->unique(['artist_id', 'account_id'])->unique(['artist_id', 'node_id']); |
||
361 | |||
362 | $db->table('tracks') |
||
363 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
364 | ->column('album_id')->references('albums')->comment('@JsonCollection @JsonRecursive') |
||
365 | ->column('title')->string() |
||
366 | ->column('duration')->time()->comment('@JsonFormat("H:i:s")'); |
||
367 | |||
368 | $db->table('featuring') |
||
369 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
370 | ->column('track_id')->references('tracks') |
||
371 | ->column('artist_id')->references('artists')->comment('@JsonKey("feat") @JsonInclude'); |
||
372 | |||
373 | $db->table('artists_relations') //used to test the auto pivot case |
||
374 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
375 | ->column('parent_id')->references('artists') |
||
376 | ->column('child_id')->references('artists'); |
||
377 | |||
378 | $db->table('children') //used to test conflicts with autopivot |
||
379 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
380 | ->column('artist_id')->references('artists'); |
||
381 | |||
382 | $db->junctionTable('person', 'boats'); |
||
383 | |||
384 | $db->table('base_objects') |
||
385 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
386 | ->column('label')->string(); |
||
387 | $db->table('inherited_objects') |
||
388 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
389 | ->column('base_object_id')->references('base_objects')->unique()->comment('@JsonCollection'); |
||
390 | |||
391 | $targetTable = $db->table('composite_fk_target') |
||
392 | ->column('id_1')->integer() |
||
393 | ->column('id_2')->integer() |
||
394 | ->then()->primaryKey(['id_1', 'id_2']); |
||
395 | $db->table('composite_fk_source') |
||
396 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
397 | ->column('fk_1')->integer() |
||
398 | ->column('fk_2')->integer() |
||
399 | ->then()->getDbalTable()->addForeignKeyConstraint($targetTable->getDbalTable(), ['fk_1', 'fk_2'], ['id_1', 'id_2']); |
||
400 | |||
401 | // Test case, the problem here is: |
||
402 | // - `inheritance_agency` have an FK to `inheritance_society.**id_entity**` |
||
403 | // - `inheritance_society` have an FK to `inheritance_entity.**id**` |
||
404 | $db->table('inheritance_entity') |
||
405 | ->column('id')->integer()->primaryKey()->autoIncrement(); |
||
406 | $db->table('inheritance_society') |
||
407 | ->column('id_entity')->references('inheritance_entity')->primaryKey() |
||
408 | ->then(); |
||
409 | $db->table('inheritance_agency') |
||
410 | ->column('id')->integer()->primaryKey()->autoIncrement() |
||
411 | ->column('id_parent_society')->references('inheritance_society'); |
||
412 | |||
413 | $sqlStmts = $toSchema->getMigrateFromSql($fromSchema, $connection->getDatabasePlatform()); |
||
414 | |||
415 | foreach ($sqlStmts as $sqlStmt) { |
||
416 | $connection->exec($sqlStmt); |
||
417 | } |
||
418 | |||
419 | // Let's generate computed columns |
||
420 | if ($connection->getDatabasePlatform() instanceof MySqlPlatform && !self::isMariaDb($connection)) { |
||
421 | $connection->exec('CREATE TABLE `players` ( |
||
422 | `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, |
||
423 | `player_and_games` JSON NOT NULL, |
||
424 | `names_virtual` VARCHAR(20) GENERATED ALWAYS AS (`player_and_games` ->> \'$.name\') NOT NULL COMMENT \'@Generated\', |
||
425 | PRIMARY KEY (`id`) |
||
426 | ); |
||
427 | '); |
||
428 | } |
||
429 | |||
430 | self::insert($connection, 'country', [ |
||
431 | 'label' => 'France', |
||
432 | ]); |
||
433 | self::insert($connection, 'country', [ |
||
434 | 'label' => 'UK', |
||
435 | ]); |
||
436 | self::insert($connection, 'country', [ |
||
437 | 'label' => 'Jamaica', |
||
438 | ]); |
||
439 | |||
440 | self::insert($connection, 'person', [ |
||
441 | 'name' => 'John Smith', |
||
442 | 'created_at' => '2015-10-24 11:57:13', |
||
443 | ]); |
||
444 | self::insert($connection, 'person', [ |
||
445 | 'name' => 'Jean Dupont', |
||
446 | 'created_at' => '2015-10-24 11:57:13', |
||
447 | ]); |
||
448 | self::insert($connection, 'person', [ |
||
449 | 'name' => 'Robert Marley', |
||
450 | 'created_at' => '2015-10-24 11:57:13', |
||
451 | ]); |
||
452 | self::insert($connection, 'person', [ |
||
453 | 'name' => 'Bill Shakespeare', |
||
454 | 'created_at' => '2015-10-24 11:57:13', |
||
455 | ]); |
||
456 | |||
457 | self::insert($connection, 'contact', [ |
||
458 | 'id' => 1, |
||
459 | 'email' => '[email protected]', |
||
460 | 'manager_id' => null, |
||
461 | ]); |
||
462 | self::insert($connection, 'contact', [ |
||
463 | 'id' => 2, |
||
464 | 'email' => '[email protected]', |
||
465 | 'manager_id' => null, |
||
466 | ]); |
||
467 | self::insert($connection, 'contact', [ |
||
468 | 'id' => 3, |
||
469 | 'email' => '[email protected]', |
||
470 | 'manager_id' => null, |
||
471 | ]); |
||
472 | self::insert($connection, 'contact', [ |
||
473 | 'id' => 4, |
||
474 | 'email' => '[email protected]', |
||
475 | 'manager_id' => 1, |
||
476 | ]); |
||
477 | |||
478 | self::insert($connection, 'rights', [ |
||
479 | 'label' => 'CAN_SING', |
||
480 | ]); |
||
481 | self::insert($connection, 'rights', [ |
||
482 | 'label' => 'CAN_WRITE', |
||
483 | ]); |
||
484 | |||
485 | self::insert($connection, 'roles', [ |
||
486 | 'name' => 'Admins', |
||
487 | 'created_at' => '2015-10-24' |
||
488 | ]); |
||
489 | self::insert($connection, 'roles', [ |
||
490 | 'name' => 'Writers', |
||
491 | 'created_at' => '2015-10-24' |
||
492 | ]); |
||
493 | self::insert($connection, 'roles', [ |
||
494 | 'name' => 'Singers', |
||
495 | 'created_at' => '2015-10-24' |
||
496 | ]); |
||
497 | |||
498 | self::insert($connection, 'roles_rights', [ |
||
499 | 'role_id' => 1, |
||
500 | 'right_label' => 'CAN_SING' |
||
501 | ]); |
||
502 | self::insert($connection, 'roles_rights', [ |
||
503 | 'role_id' => 3, |
||
504 | 'right_label' => 'CAN_SING' |
||
505 | ]); |
||
506 | self::insert($connection, 'roles_rights', [ |
||
507 | 'role_id' => 1, |
||
508 | 'right_label' => 'CAN_WRITE' |
||
509 | ]); |
||
510 | self::insert($connection, 'roles_rights', [ |
||
511 | 'role_id' => 2, |
||
512 | 'right_label' => 'CAN_WRITE' |
||
513 | ]); |
||
514 | |||
515 | self::insert($connection, 'users', [ |
||
516 | 'id' => 1, |
||
517 | 'login' => 'john.smith', |
||
518 | 'password' => null, |
||
519 | 'status' => 'on', |
||
520 | 'country_id' => 2 |
||
521 | ]); |
||
522 | self::insert($connection, 'users', [ |
||
523 | 'id' => 2, |
||
524 | 'login' => 'jean.dupont', |
||
525 | 'password' => null, |
||
526 | 'status' => 'on', |
||
527 | 'country_id' => 1 |
||
528 | ]); |
||
529 | self::insert($connection, 'users', [ |
||
530 | 'id' => 3, |
||
531 | 'login' => 'robert.marley', |
||
532 | 'password' => null, |
||
533 | 'status' => 'off', |
||
534 | 'country_id' => 3 |
||
535 | ]); |
||
536 | self::insert($connection, 'users', [ |
||
537 | 'id' => 4, |
||
538 | 'login' => 'bill.shakespeare', |
||
539 | 'password' => null, |
||
540 | 'status' => 'off', |
||
541 | 'country_id' => 2 |
||
542 | ]); |
||
543 | |||
544 | self::insert($connection, 'users_roles', [ |
||
545 | 'user_id' => 1, |
||
546 | 'role_id' => 1, |
||
547 | ]); |
||
548 | self::insert($connection, 'users_roles', [ |
||
549 | 'user_id' => 2, |
||
550 | 'role_id' => 1, |
||
551 | ]); |
||
552 | self::insert($connection, 'users_roles', [ |
||
553 | 'user_id' => 3, |
||
554 | 'role_id' => 3, |
||
555 | ]); |
||
556 | self::insert($connection, 'users_roles', [ |
||
557 | 'user_id' => 4, |
||
558 | 'role_id' => 2, |
||
559 | ]); |
||
560 | self::insert($connection, 'users_roles', [ |
||
561 | 'user_id' => 3, |
||
562 | 'role_id' => 2, |
||
563 | ]); |
||
564 | |||
565 | self::insert($connection, 'ref_no_prim_key', [ |
||
566 | 'from' => 'foo', |
||
567 | 'to' => 'foo', |
||
568 | ]); |
||
569 | |||
570 | self::insert($connection, 'accounts', [ |
||
571 | 'id' => 1, |
||
572 | 'name' => 'root' |
||
573 | ]); |
||
574 | self::insert($connection, 'accounts', [ |
||
575 | 'id' => 2, |
||
576 | 'name' => 'user' |
||
577 | ]); |
||
578 | self::insert($connection, 'accounts', [ |
||
579 | 'id' => 3, |
||
580 | 'name' => 'www' |
||
581 | ]); |
||
582 | self::insert($connection, 'nodes', [ |
||
583 | 'id' => 1, |
||
584 | 'owner_id' => 1, |
||
585 | 'name' => '/', |
||
586 | 'created_at' => (new DateTime('last year'))->format('Y-m-d H:i:s'), |
||
587 | ]); |
||
588 | self::insert($connection, 'nodes', [ |
||
589 | 'id' => 2, |
||
590 | 'name' => 'private', |
||
591 | 'created_at' => (new DateTime('last year'))->format('Y-m-d H:i:s'), |
||
592 | 'parent_id' => 1, |
||
593 | ]); |
||
594 | self::insert($connection, 'nodes', [ |
||
595 | 'id' => 3, |
||
596 | 'name' => 'var', |
||
597 | 'created_at' => (new DateTime('last year'))->format('Y-m-d H:i:s'), |
||
598 | 'parent_id' => 2, |
||
599 | ]); |
||
600 | self::insert($connection, 'nodes', [ |
||
601 | 'id' => 4, |
||
602 | 'name' => 'var', |
||
603 | 'created_at' => (new DateTime('last year'))->format('Y-m-d H:i:s'), |
||
604 | 'parent_id' => 1, |
||
605 | 'alias_id' => 3 |
||
606 | ]); |
||
607 | self::insert($connection, 'nodes', [ |
||
608 | 'id' => 5, |
||
609 | 'name' => 'www', |
||
610 | 'created_at' => (new DateTime('last week'))->format('Y-m-d H:i:s'), |
||
611 | 'parent_id' => 4 |
||
612 | ]); |
||
613 | self::insert($connection, 'nodes', [ |
||
614 | 'id' => 6, |
||
615 | 'owner_id' => 2, |
||
616 | 'name' => 'index.html', |
||
617 | 'created_at' => (new DateTime('now'))->format('Y-m-d H:i:s'), |
||
618 | 'size' => 512, |
||
619 | 'weight' => 42.5, |
||
620 | 'parent_id' => 5 |
||
621 | ]); |
||
622 | self::insert($connection, 'nodes', [ |
||
623 | 'id' => 7, |
||
624 | 'name' => 'index.html', |
||
625 | 'created_at' => (new DateTime('now'))->format('Y-m-d H:i:s'), |
||
626 | 'alias_id' => 6, |
||
627 | 'parent_id' => 1 |
||
628 | ]); |
||
629 | self::insert($connection, 'nodes', [ |
||
630 | 'id' => 8, |
||
631 | 'name' => 'index.htm', |
||
632 | 'created_at' => (new DateTime('now'))->format('Y-m-d H:i:s'), |
||
633 | 'alias_id' => 7, |
||
634 | 'parent_id' => 1 |
||
635 | ]); |
||
636 | self::insert($connection, 'nodes_guests', [ |
||
637 | 'node_id' => 6, |
||
638 | 'guest_id' => 1 |
||
639 | ]); |
||
640 | self::insert($connection, 'nodes_guests', [ |
||
641 | 'node_id' => 6, |
||
642 | 'guest_id' => 3 |
||
643 | ]); |
||
644 | self::insert($connection, 'node_entries', [ |
||
645 | 'node_id' => 6, |
||
646 | 'entry' => '<h1>' |
||
647 | ]); |
||
648 | self::insert($connection, 'node_entries', [ |
||
649 | 'node_id' => 6, |
||
650 | 'entry' => 'Hello, World' |
||
651 | ]); |
||
652 | self::insert($connection, 'node_entries', [ |
||
653 | 'node_id' => 6, |
||
654 | 'entry' => '</h1>' |
||
655 | ]); |
||
656 | |||
657 | self::insert($connection, 'artists', [ |
||
658 | 'id' => 1, |
||
659 | 'name' => 'Pink Floyd' |
||
660 | ]); |
||
661 | self::insert($connection, 'artists', [ |
||
662 | 'id' => 2, |
||
663 | 'name' => 'Roger Waters' |
||
664 | ]); |
||
665 | self::insert($connection, 'artists', [ |
||
666 | 'id' => 3, |
||
667 | 'name' => 'David Gilmour' |
||
668 | ]); |
||
669 | self::insert($connection, 'albums', [ |
||
670 | 'id' => 1, |
||
671 | 'artist_id' => 1, |
||
672 | 'account_id' => 1, |
||
673 | 'title' => 'Animals' |
||
674 | ]); |
||
675 | self::insert($connection, 'artists_relations', [ |
||
676 | 'parent_id' => 1, |
||
677 | 'child_id' => 2 |
||
678 | ]); |
||
679 | |||
680 | $timeType = Type::getType(Type::TIME_IMMUTABLE); |
||
681 | |||
682 | self::insert($connection, 'tracks', [ |
||
683 | 'album_id' => 1, |
||
684 | 'title' =>'Pigs on the Wing 1', |
||
685 | // Note: Oracle does not have a TIME column type |
||
686 | 'duration' => $timeType->convertToDatabaseValue(new DateTimeImmutable('1970-01-01 00:01:25'), $connection->getDatabasePlatform()), |
||
687 | ]); |
||
688 | self::insert($connection, 'tracks', [ |
||
689 | 'album_id' => 1, |
||
690 | 'title' => 'Dogs', |
||
691 | 'duration' => $timeType->convertToDatabaseValue(new DateTimeImmutable('1970-01-01 00:17:04'), $connection->getDatabasePlatform()), |
||
692 | ]); |
||
693 | self::insert($connection, 'tracks', [ |
||
694 | 'album_id' => 1, |
||
695 | 'title' => 'Pigs (Three Different Ones)', |
||
696 | 'duration' => $timeType->convertToDatabaseValue(new DateTimeImmutable('1970-01-01 00:11:22'), $connection->getDatabasePlatform()), |
||
697 | ]); |
||
698 | self::insert($connection, 'tracks', [ |
||
699 | 'album_id' => 1, |
||
700 | 'title' => 'Sheep', |
||
701 | 'duration' => $timeType->convertToDatabaseValue(new DateTimeImmutable('1970-01-01 00:10:24'), $connection->getDatabasePlatform()), |
||
702 | ]); |
||
703 | self::insert($connection, 'tracks', [ |
||
704 | 'album_id' => 1, |
||
705 | 'title' => 'Pigs on the Wing 2', |
||
706 | 'duration' => $timeType->convertToDatabaseValue(new DateTimeImmutable('1970-01-01 00:01:26'), $connection->getDatabasePlatform()), |
||
707 | ]); |
||
708 | self::insert($connection, 'featuring', [ |
||
709 | 'track_id' => 1, |
||
710 | 'artist_id' => 2 |
||
711 | ]); |
||
712 | self::insert($connection, 'featuring', [ |
||
713 | 'track_id' => 2, |
||
714 | 'artist_id' => 3 |
||
715 | ]); |
||
716 | self::insert($connection, 'featuring', [ |
||
717 | 'track_id' => 2, |
||
718 | 'artist_id' => 2 |
||
719 | ]); |
||
720 | self::insert($connection, 'featuring', [ |
||
721 | 'track_id' => 3, |
||
722 | 'artist_id' => 2 |
||
723 | ]); |
||
724 | self::insert($connection, 'featuring', [ |
||
725 | 'track_id' => 4, |
||
726 | 'artist_id' => 2 |
||
727 | ]); |
||
728 | self::insert($connection, 'featuring', [ |
||
729 | 'track_id' => 5, |
||
730 | 'artist_id' => 2 |
||
731 | ]); |
||
732 | |||
733 | self::insert($connection, 'boats', [ |
||
734 | 'name' => 'RoseBud', |
||
735 | 'anchorage_country' => 1, |
||
736 | 'current_country' => 1, |
||
737 | 'length' => '13.5', |
||
738 | ]); |
||
739 | |||
740 | self::insert($connection, 'person_boats', [ |
||
741 | 'person_id' => 1, |
||
742 | 'boat_id' => 1, |
||
743 | ]); |
||
744 | self::insert($connection, 'composite_fk_target', [ |
||
745 | 'id_1' => 1, |
||
746 | 'id_2' => 1 |
||
747 | ]); |
||
748 | self::insert($connection, 'composite_fk_source', [ |
||
749 | 'id' => 1, |
||
750 | 'fk_1' => 1, |
||
751 | 'fk_2' => 1 |
||
752 | ]); |
||
782 |