Closed Romaixn closed 3 years ago
Hi @Romaixn
I use doctrine migrations bundle, which is included in the orm-pack dependency.
From inside the container, ones your doctrine entities are modified, execute /bin/console doctrine:migrations:generate
and it will create a new migration file.
Happy to add it to the makefile if helps.
Doesn't it generate migrations automatically like the Symfony maker?
I don't have experience with symfony maker, but it probably use doctrine bundle under the hood https://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html
If you can provide a bit more context about the work flow you want to accomplish, I could help you better
Yes of course, for the moment I just want to change MySQL to PostgreSQL to my project. So I deleted Migrations and wanted to regenerate them. (automatically)
But the command /bin/console doctrine:migrations:generate
generate me an empty Migration file.
Did you write this line by hand in the Migration file ?
$this->addSql('CREATE TABLE users (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', credentials_email VARCHAR(255) NOT NULL COMMENT \'(DC2Type:email)\', credentials_password VARCHAR(255) NOT NULL COMMENT \'(DC2Type:hashed_password)\', UNIQUE INDEX UNIQ_1483A5E9299C9369 (credentials_email), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE
utf8mb4_unicode_ciENGINE = InnoDB');
Let me open a branch to test this use case. It can be a configuration issue. Will be back to you ASAP
I've test it and it works to for me: I've deleted the user table migration and in the container runned:
ae07feeaf91b:/app# ./bin/console doctrine:migrations:diff
Generated new migration class to "/app/src/App/Shared/Infrastructure/Persistence/Doctrine/Migrations/Version20210528143745.php"
To run just this migration for testing purposes, you can use migrations:execute --up 'App\\Shared\\Infrastructure\\Persistence\\Doctrine\\Migrations\\Version20210528143745'
To revert the migration you can use migrations:execute --down 'App\\Shared\\Infrastructure\\Persistence\\Doctrine\\Migrations\\Version20210528143745'
The result:
<?php
declare(strict_types=1);
namespace App\Shared\Infrastructure\Persistence\Doctrine\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210528143745 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE users (uuid BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid_binary)\', created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', credentials_email VARCHAR(255) NOT NULL COMMENT \'(DC2Type:email)\', credentials_password VARCHAR(255) NOT NULL COMMENT \'(DC2Type:hashed_password)\', UNIQUE INDEX UNIQ_1483A5E9299C9369 (credentials_email), PRIMARY KEY(uuid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE users');
}
}
Added this one. Maybe some lines in the readme if helps #216
Thanks it's worked ! Thanks for your work ! 👍🏻
Great. I added few lines about doctrine migrations on the Projections
section in the documentation.
How do you generate new migration ? (I'm new in DDD and CQRS concept, sorry if it's dumb question)