DBIx::Class::Migration::MySQLSandbox - Autocreate a mysql sandbox
use DBIx::Class::Migration; my $migration = DBIx::Class::Migration->new( schema_class=>'Local::Schema', db_sandbox_class=>'DBIx::Class::Migration::MySQLSandbox'), $migration->prepare; $migration->install;
This automatically creates a mysql sandbox in your target_dir that you can use for initial prototyping, development and demonstration. If you want to use this, you will need to add Test::mysqld to your Makefile.PL or your dist.ini file, and get that installed properly. It also requires that you have MySQL installed locally (although MySQL does not need to be running, as long as we can find in $PATH the binary installation). If your copy of MySQL is not installed in a normal location, you might need to locally alter $PATH so that we can find it.
target_dir
Makefile.PL
dist.ini
For example, on my Mac, mysqld is located at /usr/local/mysql/bin/mysqld so I could do something like this:
mysqld
/usr/local/mysql/bin/mysqld
PATH=/usr/local/mysqlbin:$PATH [command]
and alter the $PATH for one time running, or I could change the $PATH permanently by editing my .bashrc file (typically located in $HOME).
$PATH
.bashrc
$HOME
NOTE: You might find installing DBD::mysql to be easier if you edit the $PATH before trying to install it.
In addition to the MySQL sandbox, we create three helper scripts start, stop and use which can be used to start, stop and open shell level access to you mysql sandbox.
start
stop
use
These helper scripts will be located in a child directory of your target_dir (which defaults to share under your project root directory). For example:
share
[target_dir]/[schema_class]/bin/[start|stop|use]
If your schema class is MyApp::Schema you should see helper scripts like
MyApp::Schema
/MyApp-Web /lib /MyApp Schema.pm /Schema ... /share /migrations /fixtures /myapp-schema /bin start stop use
This give you a system for installing a sandbox locally for development, starting and stopping it for use (for example in a web application like one you might create with Catalyst) and for using it by opening a native mysql shell (such as if you wish to review the database manually, and run native SQL queries).
mysql
DBIx::Class::Migration, DBD::mysql, Test::mysqld.
See DBIx::Class::Migration for author information
See DBIx::Class::Migration for copyright and license information
To install DBIx::Class::Migration, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class::Migration
CPAN shell
perl -MCPAN -e shell install DBIx::Class::Migration
For more information on module installation, please visit the detailed CPAN module installation guide.