Symfony – How do I handle custom SQL functions in architecture updates?

Sometimes, when you are looking for performance, you need to use some complexity functions and triggers to delegate some responsibilities to the database. I want to know that when you call the doctrine:schema:update command, What is the best practice for handling these custom sql functions to create/update.
the simpler solution you have The scheme (I think) is to create your own command, execute logic internally, and call doctrine: schema: update at end.

For this, you can extend the command from UpdateSchemaDoctrineCommand or use it in the command Process.

I prefer the first solution and I will tell you too.

Create a command in src/Acme/AppBundle/Command/CustomUpdateSchemaDoctrineCommand.php
( For example, use a package of your own)

Then, extend it from the parent command as follows:

< br />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);

}
}

If you need a tool that allows SQL migration to be run, please use DoctrineMigrationsBundle

Sometimes, when you are looking for performance, you need to use a certain complexity function And triggers delegate some responsibilities to the database. I want to know what is the best practice for handling these custom sql functions to create/update when calling the doctrine:schema:update command.

The simpler solution you have (I think) is to create your own command, execute the logic internally, and call doctrine: schema: update at end.

For this, You can extend the command from UpdateSchemaDoctrineCommand or use Process in the command.

I prefer the first solution and I will tell you too.

In src/Acme/AppBundle/Command / CustomUpdateSchemaDoctrineCommand.php to create a command
(for example, use a package of your own)

Then, extend it from the parent command as follows:


namespace Acme\AppBundle\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console \Input\InputInterface;
use Symfony\Compon ent\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);

}
}

If you need a tool that allows you to run SQL migrations, please use DoctrineMigrationsBundle

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2869 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.