{"id":21771138,"url":"https://github.com/initphp/barbarian","last_synced_at":"2026-04-09T20:13:44.811Z","repository":{"id":57703357,"uuid":"511371635","full_name":"InitPHP/Barbarian","owner":"InitPHP","description":"It is a primitive Migration library. The biggest advantage of being primitive is that it is simple and understandable.","archived":false,"fork":false,"pushed_at":"2022-07-10T05:24:09.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T03:13:46.083Z","etag":null,"topics":["migration","migrations","mysql","pdo","php","php-migration","php7","postgresql","sql-migration","sql-migrations","sqlite3"],"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/InitPHP.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-07T03:38:24.000Z","updated_at":"2022-07-08T06:32:04.000Z","dependencies_parsed_at":"2022-09-26T21:31:56.018Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Barbarian","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FBarbarian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FBarbarian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FBarbarian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FBarbarian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Barbarian/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244746790,"owners_count":20503264,"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":["migration","migrations","mysql","pdo","php","php-migration","php7","postgresql","sql-migration","sql-migrations","sqlite3"],"created_at":"2024-11-26T14:15:11.065Z","updated_at":"2026-04-09T20:13:44.776Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","readme":"# Barbarian\nSmall library that can be used for database migrations.\n\n_**Warning :** This library has not yet been fully tested and is under development. Please consider this information when using._\n\n## Requirements\n\n- PHP 7.4 or higher\n- PHP PDO Extension\n- PHP JSON Extension\n- [InitPHP Console Library](https://github.com/InitPHP/Console) \n\n## Installation\n\n```\ncomposer require initphp/barbarian\n```\n\n## Usage\n\nStart by creating a directory for the Migrations classes. \n\nLet your working directory be `/Migrations/` for example. \n\nAn example migration class would look like this;\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nnamespace App\\Migrations;\n\nuse InitPHP\\Barbarian\\QueryInterface;\n\nclass Migration_20220718152243 extends \\InitPHP\\Barbarian\\MigrationAbstract\n{\n\n    public function up(QueryInterface $query) : bool\n    {\n        $query-\u003equery(\"CREATE TABLE IF NOT EXISTS `users` (\n                    `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n                    `name` varchar(255) NOT NULL,\n                    `mail` varchar(255) NOT NULL,\n                    `status` tinyint(1) NOT NULL DEFAULT 1,\n                    PRIMARY KEY (`id`)\n                    ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;\");\n        return true;\n    }\n    \n    public function down(QueryInterface $query) : bool\n    {\n        $query-\u003equery(\"DROP TABLE `users`\");\n        return true;\n    }\n    \n}\n```\n\n### Usage in your PHP code\n\n```php\nrequire_once \"vendor/autoload.php\";\n\n$pdo = new PDO(\"mysql:host=localhost;dbname=test;charset=utf8mb4\", \"root\", \"\");\n\n$migration = new \\InitPHP\\Barbarian\\Migrations($pdo, __DIR__ . '/Migrations/', [\n    'migrationTable'    =\u003e 'migrations_versions',\n    'namespace'         =\u003e '\\\\App\\\\Migrations\\\\' // If you are not using namespace, define NULL.\n]);\n\n\n// Runs the up() method of a migration object.\n$migration-\u003eupMigration(new \\App\\Migrations\\Migration_20221230153013());\n\n// Runs the down() method of a migration object.\n$migration-\u003eupMigration(new \\App\\Migrations\\Migration_20221230153013());\n```\n\n### Using the Basic CLI\n\nTo use the CLI interface, first create the \"`barbarian.json`\" file in your working directory and save the following structure by editing it according to you.\n\n```json\n{\n  \"dsn\":\"mysql:host=localhost;dbname=test;charset=utf8mb4\",\n  \"username\":\"root\",\n  \"password\":\"\",\n  \"folder\":\"C:\\\\xampp\\\\Projects\\\\App\\\\Migrations\\\\\",\n  \"table_name\":\"migrations_versions\",\n  \"namespace\":null\n}\n```\n\nOr you can try to create this file with the command below.\n\n```\nvendor/bin/barbarian json\n```\n\nYou can use the command below to create a new migration class.\n\n```\nvendor/bin/barbarian create\n```\n\nYou can use the command below to up all migrations.\n\n```\nvendor/bin/barbarian up\n```\n\nYou can use the `-version` flag to only up a migration.\n\n```\nvendor/bin/barbarian up -version=20221230153013\n```\n\nor\n\n```\nvendor/bin/barbarian up -version=Migration_20221230153013\n```\n\n\nYou can use the command below to down all migrations.\n\n```\nvendor/bin/barbarian down\n```\n\nYou can use the `-version` flag to only up a migration.\n\n```\nvendor/bin/barbarian down -version=20221230153013\n```\n\nor\n\n```\nvendor/bin/barbarian down -version=Migration_20221230153013\n```\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) \u003c\u003cinfo@muhammetsafak.com.tr\u003e\u003e\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fbarbarian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Fbarbarian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fbarbarian/lists"}