{"id":20801517,"url":"https://github.com/harish2704/simple-db-migrator","last_synced_at":"2025-08-04T19:35:06.924Z","repository":{"id":49556386,"uuid":"517763517","full_name":"harish2704/simple-db-migrator","owner":"harish2704","description":"A simple database migration tool written in PHP","archived":false,"fork":false,"pushed_at":"2022-09-19T11:40:12.000Z","size":23,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-18T12:33:18.410Z","etag":null,"topics":["database-migration","migration-tool","php-migration"],"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/harish2704.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":"2022-07-25T17:40:18.000Z","updated_at":"2023-12-06T19:53:47.000Z","dependencies_parsed_at":"2023-01-18T14:16:38.069Z","dependency_job_id":null,"html_url":"https://github.com/harish2704/simple-db-migrator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harish2704%2Fsimple-db-migrator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harish2704%2Fsimple-db-migrator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harish2704%2Fsimple-db-migrator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harish2704%2Fsimple-db-migrator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harish2704","download_url":"https://codeload.github.com/harish2704/simple-db-migrator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243147273,"owners_count":20243745,"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-migration","migration-tool","php-migration"],"created_at":"2024-11-17T18:18:50.409Z","updated_at":"2025-03-12T02:46:15.484Z","avatar_url":"https://github.com/harish2704.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-db-migrator\nA simple database migration tool written in PHP\n\n# Quick introduction.\n\n1. This is a simple database migration commandline application written in php.\n2. Contents of each SQL file is run as single transaction.\n3. The migrator tool will save the `down` migration (rollback SQL statement) in DB and cross verify it with the current version of the rollback SQL statement present in the disk and complain if both are different. \n\n# Usage\n\nMigrations are arranged in the following directory structure.\n```\n├── migrations\n│   ├── down\n│   │   ├── 001.sql\n│   │   ├── 002.sql\n│   │   ├── 003.sql\n│   │   └── 004.sql\n│   └── up\n│       ├── 001.sql\n│       ├── 002.sql\n│       ├── 003.sql\n│       └── 004.sql\n└── simple-db-migrator.php\n\n```\n\nTo create a new migration, Just create respective `xxx.sql` file in `up` and `down` directories.\n\n## Run initial migration ( ie, create db_migration table )\n```bash\n# '-s' option stands for 'setup'\nphp simple-db-migrator.php -s\n```\n\n## Show status ( last completed migration and pending migrations )\n```bash\nphp simple-db-migrator.php -l\n```\n\n## Apply all pending migrations ( up )\n```bash\nphp simple-db-migrator.php\n```\n\n## Rollback last migration ( down )\n```bash\nphp simple-db-migrator.php -d\n```\n\n## Show help\n```\n$ php simple-db-migrator.php -h\nDescription:\n  A simple database migration tool\n\nUsage:\n  php simple-db-migrator.php [options]\n\nOptions:\n  -l, --list            Show the current status of applied migrations\n  -s, --setup           Create db_migrations table in db and run all pending migrations\n  -d, --down            Roll back last migration\n  -h, --help            Display help for the given command. When no command is given display help for the db:migrate command\n  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1-3 =\u003e info,log,debug\n```\n\n# Supported RDBMS\nTested with Mysql , PostgreSQL and Sqlite\n\n# Cavets\n\n1. From [php docs](https://www.php.net/manual/en/pdo.begintransaction.php),  \"Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit COMMIT will prevent you from rolling back any other changes within the transaction boundary.\"\n2. history of completed up/down migrations will be stored in a table called `db_migrations` . By default, this table is created with default encoding of active database . So if your database's default encoding is not utf-8 and you are planing to write some utf-8 string in the migration file, then you need to manually fix the encoding of `db_migrations` table . otherwise, migration tool will fail to save the hisotry of migration ( ie, content of up/down SQL file ) in db. \n    - I am not integrating this feature into the tool for the sake of simplicity \n    - it will be better to apply these \"alter table\" commands as a new migration. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharish2704%2Fsimple-db-migrator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharish2704%2Fsimple-db-migrator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharish2704%2Fsimple-db-migrator/lists"}