first prototype of external storage and tests
[dbsrgits/DBIx-Class-Fixtures.git] / t / lib / ExtraTest / Schema.pm
1 package ExtraTest::Schema::Result::Photo;
2
3 use strict;
4 use warnings;
5
6 use base 'DBIx::Class::Core';
7
8 __PACKAGE__->load_components(qw/InflateColumn::FS/);
9 __PACKAGE__->table('photo');
10
11 __PACKAGE__->add_columns(
12   photo_id => {
13         data_type => 'integer',
14         is_auto_increment => 1,
15   },
16   photographer => {
17     data_type => 'varchar',
18     size => 40,
19   },
20   file => {
21         data_type => 'varchar',
22         size => 255,
23     is_fs_column => 1,
24     fs_column_path =>'./t/var/files',
25   });
26
27 __PACKAGE__->set_primary_key('photo_id');
28
29 package ExtraTest::Schema;
30
31 use strict;
32 use warnings;
33
34 use base 'DBIx::Class::Schema';
35
36 __PACKAGE__->register_class(
37   Photo => 'ExtraTest::Schema::Result::Photo');
38
39 sub load_sql {
40   local $/ = undef;
41   my $sql = <DATA>;
42 }
43
44 sub init_schema {
45   my $sql = (my $schema = shift)
46     ->load_sql;
47
48   ($schema->storage->dbh->do($_) ||
49    die "Error on SQL: $_\n")
50     for split(/;\n/, $sql);
51 }
52
53 1;
54
55 __DATA__
56 CREATE TABLE photo (
57   photo_id INTEGER PRIMARY KEY NOT NULL,
58   photographer varchar(40) NOT NULL,
59   file varchar(255) NOT NULL
60 )
61