Commit | Line | Data |
9a9a7832 |
1 | package DBIx::Class::Fixtures::Versioned; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use base qw/DBIx::Class::Fixtures/; |
6116de11 |
7 | use DBIx::Class::Fixtures::SchemaVersioned; |
9a9a7832 |
8 | use Class::C3; |
9 | |
9a9a7832 |
10 | =head1 NAME |
11 | |
9f96b203 |
12 | DBIx::Class::Fixtures::Versioned |
9a9a7832 |
13 | |
14 | =head1 DESCRIPTION |
15 | |
9f96b203 |
16 | Just ignore it for now, but it will vaguely tie in to DBIx::Class::Schema::Versioned's functionality eventually. |
9a9a7832 |
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}) { |
9f96b203 |
26 | return DBIx::Class::Exception->throw('You must pass a version to populate'); |
9a9a7832 |
27 | } |
9a9a7832 |
28 | return $self->next::method(@_); |
29 | } |
30 | |
31 | sub _generate_schema { |
32 | my $self = shift; |
33 | my ($params) = @_; |
34 | |
9a9a7832 |
35 | # manually set the schema version |
9f96b203 |
36 | $DBIx::Class::Fixtures::SchemaVersioned::VERSION = $params->{version}; |
9a9a7832 |
37 | |
38 | my $schema = $self->next::method(@_); |
39 | |
40 | # set the db version to the schema version |
9f96b203 |
41 | $schema->upgrade(); # set version number |
9a9a7832 |
42 | return $schema; |
43 | } |
44 | |
45 | 1; |