[Bast-commits] r9327 - in
DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class:
. Schema
edenc at dev.catalyst.perl.org
edenc at dev.catalyst.perl.org
Fri May 7 16:16:03 GMT 2010
Author: edenc
Date: 2010-05-07 17:16:03 +0100 (Fri, 07 May 2010)
New Revision: 9327
Modified:
DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Admin.pm
DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Schema/Versioned.pm
Log:
dbicadmin can now install non-versioned schemas
Modified: DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Admin.pm
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Admin.pm 2010-05-07 16:15:47 UTC (rev 9326)
+++ DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Admin.pm 2010-05-07 16:16:03 UTC (rev 9327)
@@ -195,7 +195,7 @@
=head2 config
-Instead of loading from a file the configuration can be provided directly as a hash ref. Please note
+Instead of loading from a file the configuration can be provided directly as a hash ref. Please note
config_stanza will still be required.
=cut
@@ -296,8 +296,8 @@
=back
-L<create> will generate sql for the supplied schema_class in sql_dir. The flavour of sql to
-generate can be controlled by suppling a sqlt_type which should be a L<SQL::Translator> name.
+L<create> will generate sql for the supplied schema_class in sql_dir. The flavour of sql to
+generate can be controlled by suppling a sqlt_type which should be a L<SQL::Translator> name.
Arguments for L<SQL::Translator> can be supplied in the sqlt_args hashref.
@@ -352,9 +352,9 @@
=back
-install is here to help when you want to move to L<DBIx::Class::Schema::Versioned> and have an existing
-database. install will take a version and add the version tracking tables and 'install' the version. No
-further ddl modification takes place. Setting the force attribute to a true value will allow overriding of
+install is here to help when you want to move to L<DBIx::Class::Schema::Versioned> and have an existing
+database. install will take a version and add the version tracking tables and 'install' the version. No
+further ddl modification takes place. Setting the force attribute to a true value will allow overriding of
already versioned databases.
=cut
@@ -391,7 +391,7 @@
=back
-deploy will create the schema at the connected database. C<$args> are passed straight to
+deploy will create the schema at the connected database. C<$args> are passed straight to
L<DBIx::Class::Schema/deploy>.
=cut
@@ -399,13 +399,7 @@
sub deploy {
my ($self, $args) = @_;
my $schema = $self->schema();
- if (!$schema->get_db_version() ) {
- # schema is unversioned
- $schema->deploy( $args, $self->sql_dir)
- or $schema->throw_exception ("Could not deploy schema.\n"); # FIXME deploy() does not return 1/0 on success/fail
- } else {
- $schema->throw_exception("A versioned schema has already been deployed, try upgrade instead.\n");
- }
+ $schema->deploy( $args, $self->sql_dir );
}
=head2 insert
@@ -502,7 +496,7 @@
=back
-select takes the name of a resultset from the schema_class, a where hashref and a attrs to pass to ->search.
+select takes the name of a resultset from the schema_class, a where hashref and a attrs to pass to ->search.
The found data is returned in a array ref where the first row will be the columns list.
=cut
@@ -518,7 +512,7 @@
my @data;
my @columns = $resultset->result_source->columns();
- push @data, [@columns];#
+ push @data, [@columns];#
while (my $row = $resultset->next()) {
my @fields;
Modified: DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Schema/Versioned.pm
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Schema/Versioned.pm 2010-05-07 16:15:47 UTC (rev 9326)
+++ DBIx-Class/0.08/branches/dbicadmin-non-versioned/lib/DBIx/Class/Schema/Versioned.pm 2010-05-07 16:16:03 UTC (rev 9327)
@@ -225,7 +225,7 @@
# must be called on a fresh database
if ($self->get_db_version()) {
- carp 'Install not possible as versions table already exists in database';
+ $self->throw_exception("A versioned schema has already been deployed, try upgrade instead.\n");
}
# default to current version if none passed
@@ -681,13 +681,13 @@
# This is necessary since there are legitimate cases when upgrades can happen
# back to back within the same second. This breaks things since we relay on the
# ability to sort by the 'installed' value. The logical choice of an autoinc
- # is not possible, as it will break multiple legacy installations. Also it is
+ # is not possible, as it will break multiple legacy installations. Also it is
# not possible to format the string sanely, as the column is a varchar(20).
# The 'v' character is added to the front of the string, so that any version
# formatted by this new function will sort _after_ any existing 200... strings.
my @tm = gettimeofday();
my @dt = gmtime ($tm[0]);
- my $o = $vtable->create({
+ my $o = $vtable->create({
version => $version,
installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
$dt[5] + 1900,
More information about the Bast-commits
mailing list