@@ 402-427 (lines=26) @@ | ||
399 | /** |
|
400 | * creates database schema. |
|
401 | */ |
|
402 | public function createSchema() |
|
403 | { |
|
404 | $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( |
|
405 | `id` int NOT NULL AUTO_INCREMENT, |
|
406 | `uuid` varchar(255) UNIQUE NOT NULL, |
|
407 | `headers` text DEFAULT NULL, |
|
408 | `created_at` TIMESTAMP NOT NULL, |
|
409 | `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), |
|
410 | PRIMARY KEY (`id`) |
|
411 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; |
|
412 | ||
413 | $this->pdo->exec($query); |
|
414 | ||
415 | $query2 = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'` ( |
|
416 | `id` int NOT NULL AUTO_INCREMENT, |
|
417 | `uuid` varchar(255) NOT NULL, |
|
418 | `list` varchar(255) NOT NULL, |
|
419 | `body` text DEFAULT NULL, |
|
420 | `created_at` TIMESTAMP NOT NULL, |
|
421 | `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), |
|
422 | PRIMARY KEY (`id`), |
|
423 | CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'.self::LIST_COLLECTION_TABLE_NAME.'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE |
|
424 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; |
|
425 | ||
426 | $this->pdo->exec($query2); |
|
427 | } |
|
428 | ||
429 | /** |
|
430 | * destroys database schema. |
|
@@ 432-441 (lines=10) @@ | ||
429 | /** |
|
430 | * destroys database schema. |
|
431 | */ |
|
432 | public function destroySchema() |
|
433 | { |
|
434 | $query = 'DROP TABLE IF EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'`'; |
|
435 | ||
436 | $this->pdo->exec($query); |
|
437 | ||
438 | $query2 = 'DROP TABLE IF EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'`'; |
|
439 | ||
440 | $this->pdo->exec($query2); |
|
441 | } |
|
442 | } |
|
443 |