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