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