{"id":27158904,"url":"https://github.com/activecollab/databasemigrations","last_synced_at":"2026-02-06T00:01:03.258Z","repository":{"id":56940228,"uuid":"53782133","full_name":"activecollab/databasemigrations","owner":"activecollab","description":"Database migrations for Active Collab Database Connection and Database Structure","archived":false,"fork":false,"pushed_at":"2025-01-09T00:12:39.000Z","size":162,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T02:40:20.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/activecollab.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}},"created_at":"2016-03-13T11:44:04.000Z","updated_at":"2022-03-03T10:16:17.000Z","dependencies_parsed_at":"2022-08-21T01:40:30.888Z","dependency_job_id":null,"html_url":"https://github.com/activecollab/databasemigrations","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/activecollab/databasemigrations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/activecollab%2Fdatabasemigrations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/activecollab%2Fdatabasemigrations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/activecollab%2Fdatabasemigrations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/activecollab%2Fdatabasemigrations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/activecollab","download_url":"https://codeload.github.com/activecollab/databasemigrations/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/activecollab%2Fdatabasemigrations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29140049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T23:14:48.546Z","status":"ssl_error","status_checked_at":"2026-02-05T23:14:35.724Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-04-08T22:39:26.664Z","updated_at":"2026-02-06T00:01:03.229Z","avatar_url":"https://github.com/activecollab.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Database Migrations\n\n[![Build Status](https://travis-ci.org/activecollab/databasemigrations.svg?branch=master)](https://travis-ci.org/activecollab/databasemigrations)\n\n## Migrations\n\nTo write a migration, create a class that is discoverable by Finder that you are using, and extend `Migration` class:\n\n```php\n\u003c?php\n\nnamespace Acme\\App\\Migrations;\n\nuse ActiveCollab\\DatabaseMigrations\\Migration\\Migration;\n\nclass AddUserRolesTable extends Migration\n{\n    /**\n     * {@inheritdoc}\n     */\n    public function up()\n    {\n    }\n}\n```\n\nIf you don't like how `Migration` class is structured, you can write your migrations any way you want, as long as you implement `MigrationInterface`:\n\n```php\n\u003c?php\n\nnamespace Acme\\App\\Migrations;\n\nuse ActiveCollab\\DatabaseMigrations\\Migration\\MigrationInterface;\n\nclass AddUserRolesTable implements MigrationInterface\n{\n    …\n}\n```\n\nMigrations that extend `Migration` class get two important properties injected via constructor:\n\n1. `connection` - a `ActiveCollab\\DatabaseConnection\\ConnectionInterface` instance with valid connection to the database, and\n2. `log` - a PSR-3 `LoggerInterface` instance.\n\n```php\n\u003c?php\n\nnamespace Acme\\App\\Migrations;\n\nuse ActiveCollab\\DatabaseMigrations\\Migration\\Migration;\n\nclass AddUserRolesTable extends Migration\n{\n    /**\n     * {@inheritdoc}\n     */\n    public function up()\n    {\n        if (!in_array('user_roles', $this-\u003econnection-\u003egetTableNames()) {\n            $this-\u003elogger-\u003edebug('{table} not found in the database', ['table' =\u003e 'user_roles']);\n            $thos-\u003econnection-\u003eexecute('CREATE TABLE STATEMENT');\n            $this-\u003elogger-\u003edebug('{table} created', ['table' =\u003e 'user_roles']);\n        }\n    }\n}\n```\n\n## Finders\n\nMigration classes are \"discovered\" using objects that implement `FinderInterface` interface. All that we expect from finders is that they return an array where key is migration class name, and value is path where we can expect to find the class definition. This makes migration library independent on directory and file structure that you decide to use to organize your migrations.\n\nThis library currently implements only one Finder - Migrations in Changesets.\n\n### Migrations in a Changeset Finder\n\nWhat we found to work really well for [Active Collab](https://www.activecollab.com/index.html) project are migrations that are grouped in changesets. A changeset is a directory that has one or more related migrations. Valid format of the changeset directory name is `YYYY-MM-DD-what-this-is-all-about`. Here's a couple of valid changeset names:\n\n* `2016-01-02-add-invoicing-module`\n* `2016-03-12-remove-is-trashed-project-field`\n* `2016-12-09-fix-users-table-indexes`\n\nTimestamp part of the changeset name is used for sorting, and details part is used to make it clear what the changeset is all about.\n\n## Command Line\n\nDatabase Migrations package includes a couple of traits that make implementation of commands that work with migrations easy. These commands are:\n\n* List all migrations and their status (All)\n* Run all non-executed migrations (Up)\n* Create a new migration file (Create)\n\nIn order to use these traits, you need to include them in a regular Symfony Console class, and provide implementation of `getMigrations()` method. This method needs to return a valid, configured `MigrationsInterface` instance.\n\nCreate helper has extra requirements and extension points that lets you configure how migration stubs are created. Please check protected and abstract methods under `Override` comment in `/src/Command/Create.php` file for details.\n\n## To Do\n\n1. Add basic field, index and foreign key management helper methods to the base `Migration` implementation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivecollab%2Fdatabasemigrations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factivecollab%2Fdatabasemigrations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivecollab%2Fdatabasemigrations/lists"}