Dead-simple PHP migrations controlled from code.
- Asynchronous migrations build with Amp.
- Developed to use from code and cli.
- Developed to use any database with these tool. Currently supported official Amp Postgres & MySQL clients.
- You can extend console commands to use tool with your custom config definitions instead of always use
--connect
flag. - You can use migrations/seeds files from anywhere and with any paths.
Install tool:
composer require spacetab-io/rdb
and install database client, like this:
composer require amphp/postgres
use Spacetab\Rdb\Notifier\StdoutNotifier;
use Spacetab\Rdb\Rdb;
use Spacetab\Rdb\Driver;
use Amp\Postgres;
use Amp\Postgres\ConnectionConfig;
Amp\Loop::run(function () {
$config = ConnectionConfig::fromString('host=localhost user=root dbname=test');
/** @var Postgres\Pool $pool */
$pool = Postgres\pool($config);
$driver = new Driver\SQL\Postgres($pool);
$rdb = new Rdb($driver, new StdoutNotifier()); // Optional. By default notifications is muted.
$migrator = $rdb->getMigrator();
yield $migrator->install();
yield $migrator->migrate();
yield $rdb->getSeeder()->run();
});
vendor/bin/rdb list
Rdb – dead-simple async PHP migrations controlled from code. (v1.0).
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
make
make:migration Create a new migration files
make:seed Create a new seeder file
migrate
migrate:down [migrate:rollback] Rollback the last database migration
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:status Show the status of each migration
migrate:up Run the database migrations
seed
seed:run Seed the database with records
- >= PHP 7.4
- Composer for install package
- Unit
vendor/bin/phpunit --testsuite Unit
- Integration
vendor/bin/phpunit --testsuite Integration
. Accept ENV's:PHPUNIT_RDB_PG_HOST
,PHPUNIT_RDB_PG_PORT
,PHPUNIT_RDB_PG_DBNAME
,PHPUNIT_RDB_PG_USER
,PHPUNIT_RDB_PG_PWD
The MIT License
Copyright © 2020 spacetab.io, Inc. https://spacetab.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.