aymdev / fregata Goto Github PK
View Code? Open in Web Editor NEWFregata - a PHP database migrator
License: MIT License
Fregata - a PHP database migrator
License: MIT License
Testing the migration requires manually resetting the target database to delete migrated data.
Solution:
Especially if #4 is implemented, target connections databases could reset themselves in development, if a SQL script is provided.
UPDATE 2021-05-17:
Tests using a database can extend AbstractDbalTestCase. It still resets manually.
A test has been made to use an in-memory SQLite database but the DBAL platform does not support foreign key constraints and is incompatible with the foreign key feature as mentionned in ForeignKeyBeforeTask.
Leaving open until doctrine/dbal#4288 is fixed
Migrators are registered and executed in the order they are listed in the migrators
config key or in alphabetical order with the migrators_directory
key.
The later will break some (if not most) apps with foreign key constraints that need to be migrated.
Solution:
Add a method to list migrators that need to be executed before the current one. The best would be to auto-order but not sure it can be done.
Actually, testing is hard:
This needs a big refactoring work to make testing Fregata a breeze.
$tableName
parameterThe $tableName
parameter of the constructor is required because of doctrine/dbal#4506 which prevents getting the local table from a ForeignKeyConstraint
.
This issue is now closed and the circular reference has been removed, deprecating the use of ForeignKeyConstraint::getLocalTableName()
among other methods.
Actually the internal and user code have to use the SchemaManager
to get the table.
Replacing the string $tableName
parameter with a Table $table
one would only require the user to provide the object. The parameter count would be the same but it would enforce a better type for the ForeignKey
class and remove most of the SchemaManager
usage in ForeignKeyBeforeTask and ForeignKeyAfterTask.
$allowNull
parameterThis parameter is required to reset a column of a foreign key constraint back to NOT NULL
after a migration, during an after task. This is necessary because some of the columns of a foreign key constraint may accept NULL
. This parameter helps keeping track of the columns that were NOT NULL
before the migration.
Storing the columns that should be set back to NOT NULL
using a cache system. The $allowNull
parameter could simply be removed.
Migrations should be tested in a development environment and then run on production databases. Switching from one environment to another requires manually change the connections properties.
Solution (suggestion):
Manage environment with .env files ?
In the Configuration
class, to get all the migrators in a directory, it parses PHP tokens in files manually. Could seem like reinventing the wheel.
Solution:
Replace with an external library, maybe Roave/BetterReflection.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.