Syncing databases
From RedBean
Contents |
RedShoe
RedShoe is a simple, tiny script for MySQL databases that updates existing databases to facilitate new RedBean software. For instance, if you deploy a RedBean program and you make some updates with RedBean this means you no longer have to compare the databases; RedShoe will do this for you and update the target database. It will add new columns (or widen existing ones), tables and indexes but it will not remove anything.
Download Redshoe
You can download RedShoe from the main site under section Downloads.
Redshoe Usage
RedShoe is an easy to use commandline deployment tool for RedBean applications. But it can also be used for other non-redbean databases as well. To update or deploy a RedBean database on a remote server you need to register the database with RedShoe first.
Adding a database
To add a database for use with RedShoe issue the following command:
php redshoe.php add mysql localhost mydatabase root - db1
In this example, mydatabase is the name of the database to be added it will be assigned the internal name db1 (because you can have multiple databases with the same databasename on different hosts). The first argument is the database type to be used; only mysql is supported right now. Then, the second argument is the host or IP on wich your database resides, in our case this is localhost. Next comes the databasename followed by username and password. If you provide a dash (-) for password, this means: no password. The final argument is the internal redshoe name or label for this database.
Listing databases
To get an overview of the databases registered for use with redshoe invoke the following command:
php redshoe.php list
This command will list the databases currently registered; it will present you a list that looks somewhat like this:
db1: (mysql) 'mydatabase' on: localhost
Deployment
To perform a deployment with RedShoe type the following:
php redshoe.php deploy db1 production1 production2
The first database label indicates the source, the other database labels refer to the targets. This command will actually do nothing at all. It will just register that you want to deploy the contents of db1 to production1 and production2, that's all. You can list as many database targets as you want but only one source. The source database is always the first argument.
Exporting
To get the queries that are needed to update the production databases use:
php redshoe.php export
This will generate a file called import.sql for each production server in the destination list. Each file contains the required SQL to update that specific database to be compliant with the source database.
Distributing databases directly
- Warning this feature should be used carefully and is not expected to work fully until version RedShoe 0.7* - This causes the deployment to be send to the target databases directly instead of saving it to SQL files. Syntax:
php redshoe.php distrib

