Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Automatically skip migrations #963

Closed
grachevko opened this issue Apr 18, 2020 · 6 comments
Closed

[RFC] Automatically skip migrations #963

grachevko opened this issue Apr 18, 2020 · 6 comments

Comments

@grachevko
Copy link
Contributor

Feature Request

Q A
New Feature yes
RFC yes
BC Break no

Summary

I have two databases with different schemas. After generating migration i need manualy add skip instruction to it, or on execute migration it will try to apply to both databases and it will fail on a one of it.
Like this

$this->skipIf(0 !== strpos($this->connection->getDatabase(), 'landlord'), 'landlord only');
$this->skipIf(0 !== strpos($this->connection->getDatabase(), 'tenant'), 'tenant only');

Automatically add this skip can be through custom template, but for it doesn't contain placeholder for database name.
So, could we add this placeholder, or maybe another more better solution?

@goetas
Copy link
Member

goetas commented Apr 19, 2020

It is not clear to me what is here the feature request. Can you clarify please? (from your description it seems that what you want already works...)

@grachevko
Copy link
Contributor Author

For now it works only if manually add skiIf after doctrine::diff generate migration.
RFC is about automate adding skipIf to up and down.
I can add skipIf to custom_template, but still need to manually edit which database must no be skipped. Because of now in temlate doesn't exists placeholder like <database>

@TomHAnderson
Copy link
Member

@grachevko I think you're just doing it wrong. I've worked with multiple databases each with their own distinct schemas and migrations. So this advice comes from experience:

Generate separate migrations for each database. The Doctrine migrations comes as a .phar file so you are not limited to any integration to any particular framework in order to create migrations.

If you are using the orm schema tool to diff your databases to create migrations do it on a per-object manager basis and don't intermingle your schema. I mean, that's just plain wrong IMHO.

Instead of using the framework integration create shell scripts to execute the migrations for each database independently.

@grachevko
Copy link
Contributor Author

@TomHAnderson not much clear. Ofcourse i'm already use two separate command to generate and separate command to migrate. But for now it put all migrations to one directory. When i run migrate for first database it also use migration for second. And second migration command use migration for first database.
You suggest separate folder for migrations per database? This make sense.
Maybe will be good idea to wait release of 3.0 with feature "Multiple namespaces and paths are allowed" and try something on top of it. I want separate migrations per bounded context, but for now not clear how it will be with multiply connections.

@TomHAnderson
Copy link
Member

Create separate configs for each database using the .phar file
You're over thinking it.

Good luck.

@goetas
Copy link
Member

goetas commented Apr 20, 2020

I think that the approach explained in doctrine/DoctrineMigrationsBundle#311 (comment) can solve your usecase.

I see that here the feature request is not clear, thus I'm closing it.

If you can specify the exact change request, expected inputs and outcomes, I can certainly re open the ticket.

@goetas goetas closed this as completed Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants