Is it correct to read the Migrations files and the configuration file?

Asked

Viewed 96 times

4

Files that make the database Migrations should be added in Git versioning?

I am using Phinx and I have this doubt regarding the classes that represent the tables that are generated by this library. I was wondering why the files generated from Migrations by Phinx contain names randomly generated with numbers.

I would also like to know if the Phinx configuration file that is the Phinx.yml file (or in other formats) should be versioned as well. I’m still starting with Migrations and it’s still vague to me the practices of how to use this approach (and its advantages).

  • As far as I can remember, these random numbers are a timestamp (maybe even the date and time itself, like 202005202009). This number is used only to sort which Migration is the newest. In the more the answer from Lucas is very clear.

1 answer

4


Right in the introduction of the Phinx, we face the following reflection:

Good Developers Always version their code using a SCM system, so Why don’t they do the same for their database schema?

Thinking that the philosophy of the application is to keep the database versioning, then the files migrationshould be versioned, since this ensures the traceability changes in the database.

As for the configuration file, I assume you refer to the file that has the paths, Nvironments, right? If not, please comment that if I know I will edit. Unfortunately I don’t have the reputation to comment on your question yet, so I can’t resolve that doubt before I formulate the answer.

Anyway, assuming this is the quoted configuration file, yes, this file can go to git. However, this file contains information such as a database password that may compromise your security if another individual has access, so, as mentioned in the Docs, we must be careful not to become public, even more the application in production.

If you have more than one developer working on the application, or when you need to have separate environments for separate purposes (branchs, tests, etc.) we should use the environment variable PHINX_ENVIRONMENT to replace the default environment. For more information about this, check more here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.