Git Product home page Git Product logo

fregata's People

Contributors

aymdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fregata's Issues

Databases reset feature for testing

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

Add migrators dependency management

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.

Improve testing

Actually, testing is hard:

  • Fregata mostly provides abstractions
  • some abstractions cannot be mocked (need properties, ...)
  • implementations are either saved froma string into a virtual filesystem or anonymous classes
  • creating tables "on the fly" is a bit painful

This needs a big refactoring work to make testing Fregata a breeze.

[v2] Refactor the ForeignKey constructor

$tableName parameter

Why was it useful in v1

The $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.

How to replace it in v2

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 parameter

Why was it useful in v1

This 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.

How to replace it in v2

Storing the columns that should be set back to NOT NULL using a cache system. The $allowNull parameter could simply be removed.

Add environment management

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 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.