3533688bf1278fdbc8e6c80ca4f5ed1ba0904aea
[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 Class::C3;
8
9 =head1 VERSION
10
11 Version 1.000
12
13 =cut
14
15 our $VERSION = '1.000';
16
17 =head1 NAME
18
19 DBIx::Class::Fixtures::Versioned
20
21 =head1 DESCRIPTION
22
23 Just ignore it for now, but it will vaguely tie in to DBIx::Class::Schema::Versioned's functionality eventually.
24
25 =cut
26
27 sub populate {
28   my $self = shift;
29   my ($params) = @_;
30
31   $self->schema_class("DBIx::Class::Fixtures::SchemaVersioned");
32   unless ($params->{version}) {
33     return DBIx::Class::Exception->throw('You must pass a version to populate');
34   }
35
36   return $self->next::method(@_);
37 }
38
39 sub _generate_schema {
40   my $self = shift;
41   my ($params) = @_;
42
43   # manually set the schema version
44   $DBIx::Class::Fixtures::SchemaVersioned::VERSION = $params->{version};
45
46   my $schema = $self->next::method(@_);
47   $schema->schema_version($params->{version});
48
49   # set the db version to the schema version
50   $schema->upgrade(); # set version number
51
52   return $schema;
53 }
54
55 1;