How to handle custom sql functions when updating a schema?

Sometimes, when you are looking for performance, you need to delegate some responsibilities to the database using some complexity features and triggers. I would like to know that it is best to process these custom sql functions to create / update when the doctrine: schema: update command is called.

+4
source share
2 answers

The simpler solution that you have (I think) is to create your own team, make your logic inside and call doctrine:schema:updatein the end.

, UpdateSchemaDoctrineCommand Process .

, .

src/Acme/AppBundle/Command/CustomUpdateSchemaDoctrineCommand.php (, )

:

<?php

namespace Acme\AppBundle\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand;

class CustomUpdateSchemaDoctrineCommand extends UpdateSchemaDoctrineCommand
{
    protected function configure()
    {
        parent::configure();

        $this->setName('custom:schema:update')
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Do your logic

        // Update your database schema
        return parent::execute($input, $output);

    }
}

, SQL-, DoctrineMigrationsBundle

+1

, SQL-, DoctrineMigration. , SQL - , .

0

Source: https://habr.com/ru/post/1627045/


All Articles