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 create a model in PHP Symfony?
- How to install Symfony on Windows?
- How to do testing with PHP Symfony?
- How to use Prometheus with PHP Symfony?
- How to use dependency injection in Symfony with PHP?
- How to use PHP Symfony fixtures?
- How to use the messenger component in PHP Symfony?
- What are the required PHP Symfony extensions?
- How to install PHP Symfony on Ubuntu?
See more codes...