zend-blog-3-backend

Форк
0
/
Version20170831214559.php 
65 строк · 1.8 Кб
1
<?php
2

3
namespace Application\Migrations;
4

5
use Doctrine\DBAL\Schema\Schema;
6
use Doctrine\Migrations\AbstractMigration;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9

10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
class Version20170831214559 extends AbstractMigration implements ContainerAwareInterface
14
{
15
    /**
16
     * @var ContainerInterface
17
     */
18
    protected $container;
19

20
    /**
21
     * @param ContainerInterface|null $container
22
     */
23
    public function setContainer(ContainerInterface $container = null)
24
    {
25
        $this->container = $container;
26
    }
27

28
    /**
29
     * @param Schema $schema
30
     */
31
    public function up(Schema $schema): void
32
    {
33
        // this up() migration is auto-generated, please modify it to your needs
34
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
35

36
        $this->addSql('SELECT NOW()');
37
    }
38

39
    /**
40
     * @param Schema $schema
41
     */
42
    public function down(Schema $schema): void
43
    {
44
        // this down() migration is auto-generated, please modify it to your needs
45
        $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
46

47
        $this->addSql('DROP PROCEDURE `tracking_to_archive`');
48
    }
49

50
    /**
51
     * @param Schema $schema
52
     */
53
    public function postUp(Schema $schema): void
54
    {
55
        parent::postUp($schema);
56

57
        $sql = file_get_contents(__DIR__ . '/sql/tracking_to_archive_01.sql');
58

59
        $em = $this->container->get('doctrine.orm.entity_manager');
60
        $stmt = $em->getConnection()->prepare($sql);
61
        $stmt->execute();
62

63
        $this->write('     <comment>-></comment> CREATE PROCEDURE `tracking_to_archive`');
64
    }
65
}
66

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.