DBIx-Class-Fixtures
view release on metacpan or search on metacpan
- Allow passing schema object to ->populate
- Check that fixture population dir was created
1.001001
- debug defaults to 0 rather than undef
- cleanup only deletes what's necessary
- added db specific dbi files so that postgres can use deferrable
1.001000
- Added includes functionality
- Added post_ddl and cascade attributes to populate (Drew Taylor)
- Scalar refs in cond clauses handled in sets as well as fetches (Sebastian Willert)
- Directory separators in primary keys do not cause a crash (Sebastian Willert)
- Optimised populate to take advantage of insert_bulk (Drew Taylor)
1.000001
- Added missing deps
1.000000
- Released
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
my @tables = map { $self->_name_for_source($pre_schema->source($_)) } $pre_schema->sources;
$self->msg("Tables to drop: [". join(', ', sort @tables) . "]");
my $dbh = $pre_schema->storage->dbh;
# clear existing db
$self->msg("- clearing DB of existing tables");
$pre_schema->storage->txn_do(sub {
$pre_schema->storage->with_deferred_fk_checks(sub {
foreach my $table (@tables) {
eval {
$dbh->do("drop table $table" . ($params->{cascade} ? ' cascade' : '') )
};
}
});
});
# import new ddl file to db
my $ddl_file = $params->{ddl};
$self->msg("- deploying schema using $ddl_file");
my $data = _read_sql($ddl_file);
foreach (@$data) {
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
# DDL to deploy
ddl => '/home/me/app/sql/ddl.sql',
# database to clear, deploy and then populate
connection_details => ['dbi:mysql:dbname=app_dev', 'me', 'password'],
# DDL to deploy after populating records, ie. FK constraints
post_ddl => '/home/me/app/sql/post_ddl.sql',
# use CASCADE option when dropping tables
cascade => 1,
# optional, set to 1 to run ddl but not populate
no_populate => 0,
# optional, set to 1 to run each fixture through ->create rather than have
# each $rs populated using $rs->populate. Useful if you have overridden new() logic
# that effects the value of column(s).
use_create => 0,
# optional, same as use_create except with find_or_create.
lib/DBIx/Class/Fixtures.pm view on Meta::CPAN
DBIx::Class schema from the DDL rather than being passed one to use. This is
better as custom insert methods are avoided which can to get in the way. In
some cases you might not have a DDL, and so this method will eventually allow a
$schema object to be passed instead.
If needed, you can specify a post_ddl attribute which is a DDL to be applied
after all the fixtures have been added to the database. A good use of this
option would be to add foreign key constraints since databases like Postgresql
cannot disable foreign key checks.
If your tables have foreign key constraints you may want to use the cascade
attribute which will make the drop table functionality cascade, ie 'DROP TABLE
$table CASCADE'.
C<directory> is a required attribute.
If you wish for DBIx::Class::Fixtures to clear the database for you pass in
C<dll> (path to a DDL sql file) and C<connection_details> (array ref of DSN,
user and pass).
If you wish to deal with cleaning the schema yourself, then pass in a C<schema>
attribute containing the connected schema you wish to operate on and set the
( run in 0.766 second using v1.01-cache-2.11-cpan-49f99fa48dc )