{"id":16824116,"url":"https://github.com/gared/database-structure-diff","last_synced_at":"2025-07-08T12:33:09.482Z","repository":{"id":35078502,"uuid":"204299024","full_name":"Gared/database-structure-diff","owner":"Gared","description":"Show database structure diffs between databases and sql structure dump","archived":false,"fork":false,"pushed_at":"2024-01-01T05:45:28.000Z","size":389,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T07:51:31.534Z","etag":null,"topics":["database","diff","doctrine","php","scheme"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Gared.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-25T13:36:39.000Z","updated_at":"2022-03-26T10:25:41.000Z","dependencies_parsed_at":"2023-02-14T04:50:14.854Z","dependency_job_id":"c23f1bf9-d764-4365-b901-fc4f2fef2983","html_url":"https://github.com/Gared/database-structure-diff","commit_stats":{"total_commits":171,"total_committers":5,"mean_commits":34.2,"dds":0.5321637426900585,"last_synced_commit":"49ada82364ed191fa11b86e3ffc31a5ab7cb542b"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fdatabase-structure-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fdatabase-structure-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fdatabase-structure-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Gared%2Fdatabase-structure-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Gared","download_url":"https://codeload.github.com/Gared/database-structure-diff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902929,"owners_count":20529114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","diff","doctrine","php","scheme"],"created_at":"2024-10-13T11:10:10.706Z","updated_at":"2025-03-22T03:31:47.229Z","avatar_url":"https://github.com/Gared.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP database diff tool \r\n\r\nThis tool is written in PHP and is using doctrine to create diffs between database schemes.\r\nYou can create a diff between a sql schema dump and a database. The output format is either a list of ALTER-SQL commands or a pretty text output. Another option is to get the diff programatically and use the result in your code.\r\n\r\n## Installation\r\n\r\nUse composer\r\n```gitattributes\r\ncomposer require gared/database-structure-diff\r\n```\r\n\r\nor clone this repository\r\n\r\n```gitattributes\r\ngit clone https://github.com/gared/database-structure-diff.git\r\ncomposer install --no-dev\r\n```\r\n\r\n## Configuration\r\n\r\nCopy the file config.example.php or copy this example in a file\r\n```php\r\n\u003c?php\r\n\r\nreturn [\r\n    [\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'user' =\u003e 'username',\r\n            'password' =\u003e 'password',\r\n            'host' =\u003e 'hostname',\r\n            'driver' =\u003e 'pdo_mysql',\r\n        ],\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'path' =\u003e 'path/to/file.sql',\r\n            'driver' =\u003e 'file',\r\n        ],\r\n    ],\r\n];\r\n```\r\n\r\nYou can also define multiple groups to make diff\r\n\r\n```php\r\n\u003c?php\r\n\r\nreturn [\r\n    [\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'user' =\u003e 'username',\r\n            'password' =\u003e 'password',\r\n            'host' =\u003e 'hostname',\r\n            'driver' =\u003e 'pdo_mysql',\r\n        ],\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'path' =\u003e 'path/to/file.sql',\r\n            'driver' =\u003e 'file',\r\n        ],\r\n    ],\r\n    [\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'user' =\u003e 'username',\r\n            'password' =\u003e 'password',\r\n            'host' =\u003e 'hostname',\r\n            'driver' =\u003e 'pdo_mysql',\r\n        ],\r\n        [\r\n            'dbname' =\u003e 'database_name',\r\n            'user' =\u003e 'username',\r\n            'password' =\u003e 'password',\r\n            'host' =\u003e 'hostname',\r\n            'driver' =\u003e 'pdo_mysql',\r\n        ],\r\n    ],\r\n];\r\n```\r\n\r\nFor more database configuration read the doctrine configuration:\r\nhttps://www.doctrine-project.org/projects/doctrine-dbal/en/stable/reference/configuration.html\r\n\r\n## Usage \r\n\r\nIf you cloned this repository execute\r\n\r\n```gitattributes\r\nphp bin/console database:calculate-diff config.php\r\n```\r\n\r\nor if you installed it with composer\r\n\r\n```gitattributes\r\nphp vendor/gared/database-structure-diff/bin/console database:calculate-diff config.php\r\n```\r\n\r\nor use the option \"output-file\" to store an ALTER script to a file\r\n\r\n```gitattributes\r\nphp bin/console database:calculate-diff config.php --output-file alter.sql\r\n```\r\n\r\n### Example output\r\n\r\n```console\r\n$ php vendor/gared/database-structure-diff/bin/console database:calculate-diff config.php\r\nDatabase: example@10.10.1.1 =\u003e File: strcture.sql\r\n-------------------------------------------------\r\n\r\nNew tables\r\n==========\r\n\r\n * user: user_id, name\r\n\r\nRemoved tables\r\n==============\r\n\r\n * player\r\n\r\nChanged tables\r\n==============\r\n\r\nteam\r\n----\r\n\r\nAdded columns\r\n * team_short_name: String 10\r\n\r\nChanged columns\r\npath\r\n * length: 100 =\u003e 255\r\n\r\nRemoved columns\r\n * user_id\r\n\r\nRemoved indexes\r\n * FK_team_user\r\n\r\nAdded foreign keys\r\n * FK_C4E0A61F3A35FDA4: (team_type_id) =\u003e team_type (team_type_id)\r\n\r\ngroup\r\n-----\r\n\r\nRenamed indexes\r\n * fk_group =\u003e fk_group_idx\r\n```\r\n\r\n### Use in your code\r\nYou can also work with the response of the diff in your code.\r\nExample code:\r\n```php\r\n\u003c?php\r\nrequire __DIR__ . '/vendor/autoload.php';\r\n$fromConnection = new \\DatabaseDiffer\\Model\\Config\\Connection([\r\n    'dbname' =\u003e 'database_name',\r\n    'user' =\u003e 'username',\r\n    'password' =\u003e 'password',\r\n    'host' =\u003e 'hostname',\r\n    'driver' =\u003e 'pdo_mysql',\r\n]);\r\n$toConnection = new \\DatabaseDiffer\\Model\\Config\\Connection([\r\n    'dbname' =\u003e 'database_name',\r\n    'path' =\u003e 'path/to/file.sql',\r\n    'driver' =\u003e 'file',\r\n]);\r\n$group = new \\DatabaseDiffer\\Model\\Config\\Group($fromConnection, $toConnection);\r\n$diffService = new \\DatabaseDiffer\\Service\\SchemaDiffService($group);\r\n$schemaDiff = $diffService-\u003egetSchemaDiff();\r\n// $schemaDiff has all informations about changed tables, sequences, etc.\r\n```\r\n\r\n## Supported Platforms\r\n\r\n* Doctrine supported databases (MySQL, MariaDB, Oracle, etc.)\r\n* You need at least PHP 7.4\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgared%2Fdatabase-structure-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgared%2Fdatabase-structure-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgared%2Fdatabase-structure-diff/lists"}