We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to deal with migration for many developers?

Hi,

I have a question about working with Phalcon migrations for many developers on one project. For example there is a blog project application. Blog project is contributed by developer A and developer B. Project was started, first migration was generated and first migration has number 1.0.0. Code project is hosted on git repository.

In version 1.0.0 there is a Posts model which contains title field.

Developer A add to Posts model 'content' field. Developer A generate migration and the version is 1.0.1.

In the same time Developer B add to Posts model another field and generate migration. The version is also 1.0.1.

How to deal with these situations?



10.3k

use github

As I write the code is on git repository. I have a question about flow/good practises to maintain project contributed by many developers. When migration should be generated?

I think about two cases.

Case 1)

Developer A commit changes and merge with master. No migration generated.

Developer B commit changes and merge with master (resolving conflicts if is). No migration generated.

Developer A genereate migration and push to master. (1.0.1)

Developer B pull from master, run migration. (1.0.1)

Developer B generate migration push to master. (1.0.2)

Developer A pull from master, run migration. (1.0.2)

But - this flow probably doesn't work as I expect because when developer B run migration (1.0.1) his changes on database was lost. Am I right?

Case 2)

Developer A commit changes, generate migration and merge with master (1.0.1).

Developer B commit changes. And what next? Should he generate migration? (possibilites in subcase below)

Subcase 2.1) Developer B generate migration (also 1.0.1). When he want to merge with master there is conflict with migrations/1.0.1 directory. He can use a diff tool to see which fields what added/chnaged and edit the db scheme. Next he accepts version from master. Next generate migration again (now it is 1.0.2 and contains his changes and changes made by developer A) and merge with master again.

Subcase 2.2) Developer B no generate migration. And what next he should do?


What do you think about that?



10.3k

Google "github tutorial",you can find resolution maybe.

Marcin,

Did you find a solution to your question?

Doctrine can solve this problem, but it is slower than Phalcon ORM