Removed BasicRels and reorganized where the various init/setup code resides.
[dbsrgits/DBIx-Class-Historic.git] / t / lib / DBICTest / Schema.pm
CommitLineData
bab77431 1package # hide from PAUSE
c6d74d3e 2 DBICTest::Schema;
a02675cd 3
4use base qw/DBIx::Class::Schema/;
5
5ce32fc1 6no warnings qw/qw/;
7
a02675cd 8__PACKAGE__->load_classes(qw/
5ce32fc1 9 Artist
4e298a80 10 Employee
5ce32fc1 11 CD
9c2c91ea 12 Link
13 Bookmark
5ce32fc1 14 #dummy
15 Track
16 Tag
17 /,
18 { 'DBICTest::Schema' => [qw/
19 LinerNotes
20 OneKey
21 #dummy
22 TwoKeys
9fcda149 23 Serialized
5ce32fc1 24 /]},
25 (
26 'FourKeys',
27 '#dummy',
28 'SelfRef',
5efe4c79 29 'ArtistUndirectedMap',
bab77431 30 'ArtistSourceName',
7411204b 31 'Producer',
32 'CD_to_Producer',
5ce32fc1 33 ),
637ca936 34 qw/SelfRefAlias TreeLike TwoKeyTreeLike/
5ce32fc1 35);
a02675cd 36
4b8dcc58 37sub deploy {
38 my $self = shift;
39
40 if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
41 return $schema->next::method(@_);
42 } else {
43 open IN, "t/lib/sqlite.sql";
44 my $sql;
45 { local $/ = undef; $sql = <IN>; }
46 close IN;
47 $self->storage->dbh->do($_) for split(/;\n/, $sql);
48 }
49}
50
51sub auto_populate {
52 my $self = shift;
53
54 $self->storage->dbh->do("PRAGMA synchronous = OFF");
55
56 $self->populate('Artist', [
57 [ qw/artistid name/ ],
58 [ 1, 'Caterwauler McCrae' ],
59 [ 2, 'Random Boy Band' ],
60 [ 3, 'We Are Goth' ],
61 ]);
62
63 $self->populate('CD', [
64 [ qw/cdid artist title year/ ],
65 [ 1, 1, "Spoonful of bees", 1999 ],
66 [ 2, 1, "Forkful of bees", 2001 ],
67 [ 3, 1, "Caterwaulin' Blues", 1997 ],
68 [ 4, 2, "Generic Manufactured Singles", 2001 ],
69 [ 5, 3, "Come Be Depressed With Us", 1998 ],
70 ]);
71
72 $self->populate('LinerNotes', [
73 [ qw/liner_id notes/ ],
74 [ 2, "Buy Whiskey!" ],
75 [ 4, "Buy Merch!" ],
76 [ 5, "Kill Yourself!" ],
77 ]);
78
79 $self->populate('Tag', [
80 [ qw/tagid cd tag/ ],
81 [ 1, 1, "Blue" ],
82 [ 2, 2, "Blue" ],
83 [ 3, 3, "Blue" ],
84 [ 4, 5, "Blue" ],
85 [ 5, 2, "Cheesy" ],
86 [ 6, 4, "Cheesy" ],
87 [ 7, 5, "Cheesy" ],
88 [ 8, 2, "Shiny" ],
89 [ 9, 4, "Shiny" ],
90 ]);
91
92 $self->populate('TwoKeys', [
93 [ qw/artist cd/ ],
94 [ 1, 1 ],
95 [ 1, 2 ],
96 [ 2, 2 ],
97 ]);
98
99 $self->populate('FourKeys', [
100 [ qw/foo bar hello goodbye/ ],
101 [ 1, 2, 3, 4 ],
102 [ 5, 4, 3, 6 ],
103 ]);
104
105 $self->populate('OneKey', [
106 [ qw/id artist cd/ ],
107 [ 1, 1, 1 ],
108 [ 2, 1, 2 ],
109 [ 3, 2, 2 ],
110 ]);
111
112 $self->populate('SelfRef', [
113 [ qw/id name/ ],
114 [ 1, 'First' ],
115 [ 2, 'Second' ],
116 ]);
117
118 $self->populate('SelfRefAlias', [
119 [ qw/self_ref alias/ ],
120 [ 1, 2 ]
121 ]);
122
123 $self->populate('ArtistUndirectedMap', [
124 [ qw/id1 id2/ ],
125 [ 1, 2 ]
126 ]);
127
128 $self->populate('Producer', [
129 [ qw/producerid name/ ],
130 [ 1, 'Matt S Trout' ],
131 [ 2, 'Bob The Builder' ],
132 [ 3, 'Fred The Phenotype' ],
133 ]);
134
135 $self->populate('CD_to_Producer', [
136 [ qw/cd producer/ ],
137 [ 1, 1 ],
138 [ 1, 2 ],
139 [ 1, 3 ],
140 ]);
141
142 $self->populate('TreeLike', [
143 [ qw/id parent name/ ],
144 [ 1, 0, 'foo' ],
145 [ 2, 1, 'bar' ],
146 [ 3, 2, 'baz' ],
147 [ 4, 3, 'quux' ],
148 ]);
149
150 $self->populate('Track', [
151 [ qw/trackid cd position title/ ],
152 [ 4, 2, 1, "Stung with Success"],
153 [ 5, 2, 2, "Stripy"],
154 [ 6, 2, 3, "Sticky Honey"],
155 [ 7, 3, 1, "Yowlin"],
156 [ 8, 3, 2, "Howlin"],
157 [ 9, 3, 3, "Fowlin"],
158 [ 10, 4, 1, "Boring Name"],
159 [ 11, 4, 2, "Boring Song"],
160 [ 12, 4, 3, "No More Ideas"],
161 [ 13, 5, 1, "Sad"],
162 [ 14, 5, 2, "Under The Weather"],
163 [ 15, 5, 3, "Suicidal"],
164 [ 16, 1, 1, "The Bees Knees"],
165 [ 17, 1, 2, "Apiary"],
166 [ 18, 1, 3, "Beehind You"],
167 ]);
168
169 $self->populate('Link', [
170 [ qw/id title/ ],
171 [ 1, 'aaa' ]
172 ]);
173
174 $self->populate('Bookmark', [
175 [ qw/id link/ ],
176 [ 1, 1 ]
177 ]);
178}
179
a02675cd 1801;