[Bast-commits] r4793 -
DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class
jgoulah at dev.catalyst.perl.org
jgoulah at dev.catalyst.perl.org
Tue Sep 2 22:28:56 BST 2008
Author: jgoulah
Date: 2008-09-02 22:28:55 +0100 (Tue, 02 Sep 2008)
New Revision: 4793
Modified:
DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm
Log:
adding no_populate option back in
Modified: DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm
===================================================================
--- DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm 2008-08-31 12:01:25 UTC (rev 4792)
+++ DBIx-Class-Fixtures/1.001/trunk/lib/DBIx/Class/Fixtures.pm 2008-09-02 21:28:55 UTC (rev 4793)
@@ -470,7 +470,6 @@
$config->{belongs_to} = { fetch => 1 } unless (exists $config->{belongs_to});
} elsif ($params->{all}) {
$config = { might_have => { fetch => 0 }, has_many => { fetch => 0 }, belongs_to => { fetch => 0 }, sets => [map {{ class => $_, quantity => 'all' }} $schema->sources] };
- print Dumper($config);
} else {
return DBIx::Class::Exception->throw('must pass config or set all');
}
@@ -765,6 +764,7 @@
connection_details => ['dbi:mysql:dbname=app_dev', 'me', 'password'], # database to clear, deploy and then populate
post_ddl => '/home/me/app/sql/post_ddl.sql', # DDL to deploy after populating records, ie. FK constraints
cascade => 1, # use CASCADE option when dropping tables
+ no_populate => 0, # optional, set to 1 to run ddl but not populate
});
In this case the database app_dev will be cleared of all tables, then the specified DDL deployed to it,
@@ -818,6 +818,9 @@
}
my $schema = $self->_generate_schema({ ddl => $ddl_file, connection_details => delete $params->{connection_details}, %{$params} });
+
+ return 1 if $params->{no_populate};
+
$self->msg("\nimporting fixtures");
my $tmp_fixture_dir = dir($fixture_dir, "-~populate~-" . $<);
@@ -850,17 +853,7 @@
$fixup_visitor = new Data::Visitor::Callback(%callbacks);
}
- my $db = $schema->storage->dbh->{Driver}->{Name};
- my $dbi_class = "DBIx::Class::Fixtures::DBI::$db";
-
- eval "require $dbi_class";
- if ($@) {
- $dbi_class = "DBIx::Class::Fixtures::DBI";
- eval "require $dbi_class";
- die $@ if $@;
- }
-
- $dbi_class->do_insert($schema, sub {
+ $schema->storage->with_deferred_fk_checks(sub {
foreach my $source (sort $schema->sources) {
$self->msg("- adding " . $source);
my $rs = $schema->resultset($source);
@@ -885,8 +878,6 @@
$self->msg("- fixtures imported");
$self->msg("- cleaning up");
$tmp_fixture_dir->rmtree;
- eval { $schema->storage->dbh->do('SET foreign_key_checks=1') };
-
return 1;
}
More information about the Bast-commits
mailing list