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