incremented version
[dbsrgits/DBIx-Class-Fixtures.git] / lib / DBIx / Class / Fixtures / Versioned.pm
1 package DBIx::Class::Fixtures::Versioned;
2
3 use strict;
4 use warnings;
5
6 use base qw/DBIx::Class::Fixtures/;
7 use DBIx::Class::Fixtures::SchemaVersioned;
8 use Class::C3;
9
10 =head1 NAME
11
12 DBIx::Class::Fixtures::Versioned
13
14 =head1 DESCRIPTION
15
16 Just ignore it for now, but it will vaguely tie in to DBIx::Class::Schema::Versioned's functionality eventually.
17
18 =cut
19
20 sub populate {
21   my $self = shift;
22   my ($params) = @_;
23
24   $self->schema_class("DBIx::Class::Fixtures::SchemaVersioned");
25   unless ($params->{version}) {
26     return DBIx::Class::Exception->throw('You must pass a version to populate');
27   }
28   return $self->next::method(@_);
29 }
30
31 sub _generate_schema {
32   my $self = shift;
33   my ($params) = @_;
34
35   # manually set the schema version
36   $DBIx::Class::Fixtures::SchemaVersioned::VERSION = $params->{version};
37
38   my $schema = $self->next::method(@_);
39
40   # set the db version to the schema version
41   $schema->upgrade(); # set version number
42   return $schema;
43 }
44
45 1;