DBIx::Class::Migration::FAQ - Answers to Frequently Asked Questions
SV = IV(0x7fb4e24dc858) at 0x7fb4e24dc868 REFCNT = 1 FLAGS = (ROK,READONLY) RV = 0x7fb4e0b0ddf8 SV = PVHV(0x7fb4e24c48a0) at 0x7fb4e0b0ddf8 REFCNT = 1 FLAGS = (OBJECT,SHAREKEYS) STASH = 0x7fb4e2174a80 "DBI::db" ARRAY = 0x0 KEYS = 0 FILL = 0 MAX = 7 RITER = -1
There's some debugging code somewhere in the DBIx::Class::DeploymentHander dependency chain. We've looked and can't find it :( A case of beer at the next YAPC we meet at to whoever can figure it out.
ALthough you see this, there's nothing wrong. The command will work as in the documentation. The only issue is that if there's a lot of debugging scroll by, you might need to page up in your terminal to catch any real error messages.
Contributing to the project is easy. First you'd fork the project over at Github (https://github.com/jjn1056/DBIx-Class-Migration), clone the repo down to your work environment and install project dependencies:
cpanm Dist::Zilla dzil authordeps | cpanm dzil listdeps | cpanm
You should first have a Modern Perl setup, including local::lib. If you need help installing Perl and getting started, please take a look at the Learning Perl website: http://learn.perl.org/installing/
I realize Dist::Zilla seems to invoke feelings on nearly religious vigor (both for and against). After considering the options I felt using it, but carefully constraining the use of plugins to the default set was a better option than what I've done on other projects, which is to have a custom wrapper on top of Module::Install (you can peek at that if you want over here: https://github.com/jjn1056/Maker). I've decided I'd rather not continue to spend my limited time dealing with dependency and installation management tools, when there's a rational solution that many people already embrace available. The only other option is to continue to build and maintain code for this purpose that nobody else uses, and possibly nobody else understands.
If a better option with equal or greater maturity and community acceptance emerges, I'll entertain changing.
If the requirement of typing
cpanm Dist::Zilla and using the
dzil command line tool for a limited number of build jobs prevents you from contributing, I think you are unreasonably stubborn.
If you do contribute to the project, please be aware that I'm not likely to accept patches that include significant changes to the way I'm using Dist::Zilla, including using plugins to weave pod, automagically guess dependencies and generate tests. I'd prefer to stick to the most simple and standard Perl practices for building and installing code for the present.
Having the database sandboxes automatically created in the
share directory is a nice feature, but can clutter your repository history. You really don't need that in the source control, since installing and controlling your database is something each developer who checks out the project should do.
If you are using
git you can modify your
.gitignore. If you sandbox is
share/myapp-schema.db or (if you are using the mysql or postgresql sandboxes)
share/myapp-schema/ you can add these lines to your
Other source control systems have similiar approaches (recipies welcome for sharing).
dbic-migration -Ilib status \ --dsn="DBI:mysql:database=test;host=127.0.0.1;port=5142" \ --user msandbox \ --password msandbox
Would be the general approach.
You didn't specify a custom
--target_dir but forgot to make the
/share directory in your project application root.
By default we expect to find a
/share directory in your primary project root directory (contains your
dist.ini, and the
t directories for example) where we will create migrations. At this time we can't automatically create this
/share directory in the same way we can create all the migration files and directory for you. You need to create that directory yourself:
Patches to fix this, or suggestions welcomed.
Not everyone loves using an ORM. Personally I've found DBIx::Class to be the only ORM that gets enough out of my way that I prefer it over plain SQL, and I highly recommend you give it a go. However if you don't want to, or can not convince your fellow programers (yet :) ), here's one way to still use this migrations and fixtures system. Strictly speaking, we are stilling using DBIx::Class behind the scenes, just you don't have to know about it or use it.
You use a subclass of DBIx::Class::Schema::Loader in a namespace for your application, like:
package MyApp::Schema; use strict; use warnings; use base 'DBIx::Class::Schema::Loader'; our $VERSION = 1; __PACKAGE__->naming('current'); __PACKAGE__->use_namespaces(1); __PACKAGE__->loader_options( ); 1;
You'd put that in
lib/MyApp/Schema.pm along with your other application code. then just use
MyApp::Schema as is discussed in the documentation. This will dynamically build a schema for you, as long as you set the schema arguments to connect to your actual database. Then everytime someone changes the database you just up the
$VERSION and take it from there. Obviously this is a bit more manual effort, but at least you can have the ability to populate to any given version, manage fixtures, do some sane testing, etc. Maybe you'll even be able to convince people to try out DBIx::Class!
By the way, if you wanted, you can always dump the generated version of your classes using
make_schema (see "make_schema" in DBIx::Class::Migrations and "make_schema" in DBIx::Class::Migrations::Script).
That's because MySQL does not support transaction DDL. Even if you have a transaction, MySQL will silently COMMIT when it bumps into some DDL.
You don't always have the luxury of building a new database from the start. For example, you may have an existing database that you want to start to create migrations for. In this case you probably want to dump some data directly from that existing database in order to create fixtures for testing or for seeding a new database.
DBIx::Class::Migration will let you run the
dump_named_sets commands against an unversioned database. For example:
dbic-migration -Ilib -SMyApp::Schema dump_all_sets / --dsn="dbi:mysql:database=myapp;host=10.0.88.98;port=3306" / --username johnn / --password $PASSWORD
In this case let's say "dbi:mysql:database=myapp;host=10.0.88.98;port=3306" is a database that you've been managing manually and it has some data that is useful for creating your fixture sets.
When you run these commands against an unversioned database you will be warned because we have no way of being sure what version of the fixture sets you should be dumping. We will just assume that whatever the Schema version is, is correct. This can of course lead to bad or undumpable fixtures should your Schema and the unversioned DB not match properly. Buyer beware!
Sorry this error is vague and I am working on a fix. You will get this if you have failed to provide a
schema_class, either by setting it with the -S or -schema_class commandline option flag:
dbic-migration -Ilib -SMyApp::Schema dbic-migration -Ilib --schema_class MyApp::Schema
or by exporting the %ENV:
Or, if you have a custom version of DBIx::Class::Migration::Script as discussed in the tutorial, you are not providing a good
You probably forgot to include your project
lib directory in the Perl search path. The easiest way to fix this is to use the
lib command line: option flag:
dbic-migration -Ilib -SMyApp::Schema [command]
There will be more like this:
FATAL: could not create shared memory segment: Cannot allocate memory DETAIL: Failed system call was shmget(key=1, size=2138112, 03600). HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space, or exceeded your kernel's SHMALL parameter. You can either reduce the request size or reconfigure the kernel with larger SHMALL. To reduce the request size (currently 2138112 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
The solution is as presented. Since I prefer not to change my system settings permanently, " just add the following to a little bash script in my application
sudo sysctl -w kern.sysv.shmall=65536 sudo sysctl -w kern.sysv.shmmax=16777216
I don't know enough about Postgresql to know if the above settings are good, but they work for my testing. Corrections very welcome! Ideally I'd try to find a way to offer a patch to Test::postgresql, although this seems to be limited to people using Macs.
See DBIx::Class::Migration for author information
See DBIx::Class::Migration for copyright and license information