php-symfonyHow to create a migration in PHP Symfony?
Creating a migration in PHP Symfony is a simple process.
Create a migration class in the src/Migrations
directory:
<?php
namespace App\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20200101000000 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
Generate the SQL code for the migration:
$ php bin/console doctrine:migrations:diff
Execute the migration:
$ php bin/console doctrine:migrations:migrate
Check the status of the migration:
$ php bin/console doctrine:migrations:status
Revert the migration if needed:
$ php bin/console doctrine:migrations:migrate prev
Helpful links
More of Php Symfony
- How to generate a model in PHP Symfony?
- How to install Symfony on Windows?
- How to install PHP Symfony on Ubuntu?
- How to create a model in PHP Symfony?
- How to use Twig in Symfony with PHP?
- How to implement pagination in PHP Symfony?
- How to check PHP Symfony version?
- How to use Swagger with Symfony and PHP?
- How to use websockets in PHP Symfony?
- How to use the PHP Symfony findBy method?
See more codes...