api-skeletons/zf-doctrine-orm-data-validation

There is no license information available for the latest version (1.0.2) of this package.

Validate foreign key relationships in data

1.0.2 2016-04-01 22:16 UTC

This package is auto-updated.

Last update: 2024-10-11 15:04:10 UTC


README

Gitter Total Downloads

For one reason or another you will build an ORM on top of an existing database. The existing database may not have referential integrity for all it's relationships.

You now have a database with an ORM and there is probably bad data in the database which does not conform to the relationships defined in the ORM.

This tool is intended for devleopment only.

Foreign Key Validation

Create a report by scanning every relationship defined in your ORM for data which is missing it's foreign key. Nullable relationships are not evaluated.

php index.php orm:data-validation:relationship --object-manager="doctrine.entitymanager.orm_default"

This will output TSV with the Count, Distinct Values, Child Field, Child Entity, Parent Entity, and the SQL to duplicate the results for all relationships where data is found in the child which references data not found in the parent.

Configure Zend Framework 2 Module

composer require "api-skeletons/zf-doctrine-orm-data-validation": "^1.0"

Add to config/development.config.php.dist:

return array(
    'modules' => array(
        'ZF\\Doctrine\\ORM\\DataValidation'
        ...
    ),

Enable development mode to copy development.config.php.dist to development.config.php