Commit | Line | Data |
4d9d84d5 |
1 | use strict; |
2 | use warnings; |
3 | use DBICTest::Schema; |
4 | |
5 | my $db_file = "t/var/DBIxClass.db"; |
6 | |
7 | unlink($db_file) if -e $db_file; |
8 | unlink($db_file . "-journal") if -e $db_file . "-journal"; |
9 | mkdir("t/var") unless -d "t/var"; |
10 | |
11 | my $dsn = "dbi:SQLite:${db_file}"; |
12 | |
13 | my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn); |
14 | |
15 | my $dbh = DBI->connect($dsn); |
16 | |
17 | my $sql = <<EOSQL; |
18 | CREATE TABLE artist (artistid INTEGER NOT NULL PRIMARY KEY, name VARCHAR); |
19 | |
20 | CREATE TABLE cd (cdid INTEGER NOT NULL PRIMARY KEY, artist INTEGER NOT NULL, |
21 | title VARCHAR, year VARCHAR); |
22 | |
23 | CREATE TABLE liner_notes (liner_id INTEGER NOT NULL PRIMARY KEY, notes VARCHAR); |
24 | |
25 | CREATE TABLE track (trackid INTEGER NOT NULL PRIMARY KEY, cd INTEGER NOT NULL, |
26 | position INTEGER NOT NULL, title VARCHAR); |
27 | |
28 | CREATE TABLE tags (tagid INTEGER NOT NULL PRIMARY KEY, cd INTEGER NOT NULL, |
29 | tag VARCHAR); |
30 | |
31 | CREATE TABLE twokeys (artist INTEGER NOT NULL, cd INTEGER NOT NULL, |
32 | PRIMARY KEY (artist, cd) ); |
33 | |
34 | CREATE TABLE fourkeys (foo INTEGER NOT NULL, bar INTEGER NOT NULL, |
35 | hello INTEGER NOT NULL, goodbye INTEGER NOT NULL, |
36 | PRIMARY KEY (foo, bar, hello, goodbye) ); |
37 | |
38 | CREATE TABLE onekey (id INTEGER NOT NULL PRIMARY KEY, |
39 | artist INTEGER NOT NULL, cd INTEGER NOT NULL ); |
40 | |
41 | CREATE TABLE self_ref (id INTEGER NOT NULL PRIMARY KEY, |
42 | name VARCHAR ); |
43 | |
44 | CREATE TABLE self_ref_alias (self_ref INTEGER NOT NULL, alias INTEGER NOT NULL, |
45 | PRIMARY KEY( self_ref, alias ) ); |
46 | |
5efe4c79 |
47 | CREATE TABLE artist_undirected_map (id1 INTEGER NOT NULL, id2 INTEGER NOT NULL, PRIMARY KEY(id1, id2)); |
48 | |
4d9d84d5 |
49 | CREATE TABLE producer (producerid INTEGER NOT NULL PRIMARY KEY, name VARCHAR); |
50 | |
51 | CREATE TABLE cd_to_producer (cd INTEGER NOT NULL, producer INTEGER NOT NULL); |
52 | |
53 | INSERT INTO artist (artistid, name) VALUES (1, 'Caterwauler McCrae'); |
54 | |
55 | INSERT INTO artist (artistid, name) VALUES (2, 'Random Boy Band'); |
56 | |
57 | INSERT INTO artist (artistid, name) VALUES (3, 'We Are Goth'); |
58 | |
59 | INSERT INTO cd (cdid, artist, title, year) |
60 | VALUES (1, 1, "Spoonful of bees", 1999); |
61 | |
62 | INSERT INTO cd (cdid, artist, title, year) |
63 | VALUES (2, 1, "Forkful of bees", 2001); |
64 | |
65 | INSERT INTO cd (cdid, artist, title, year) |
66 | VALUES (3, 1, "Caterwaulin' Blues", 1997); |
67 | |
68 | INSERT INTO cd (cdid, artist, title, year) |
69 | VALUES (4, 2, "Generic Manufactured Singles", 2001); |
70 | |
71 | INSERT INTO cd (cdid, artist, title, year) |
72 | VALUES (5, 3, "Come Be Depressed With Us", 1998); |
73 | |
74 | INSERT INTO liner_notes (liner_id, notes) |
75 | VALUES (2, "Buy Whiskey!"); |
76 | |
77 | INSERT INTO liner_notes (liner_id, notes) |
78 | VALUES (4, "Buy Merch!"); |
79 | |
80 | INSERT INTO liner_notes (liner_id, notes) |
81 | VALUES (5, "Kill Yourself!"); |
82 | |
83 | INSERT INTO tags (tagid, cd, tag) VALUES (1, 1, "Blue"); |
84 | |
85 | INSERT INTO tags (tagid, cd, tag) VALUES (2, 2, "Blue"); |
86 | |
87 | INSERT INTO tags (tagid, cd, tag) VALUES (3, 3, "Blue"); |
88 | |
89 | INSERT INTO tags (tagid, cd, tag) VALUES (4, 5, "Blue"); |
90 | |
91 | INSERT INTO tags (tagid, cd, tag) VALUES (5, 2, "Cheesy"); |
92 | |
93 | INSERT INTO tags (tagid, cd, tag) VALUES (6, 4, "Cheesy"); |
94 | |
95 | INSERT INTO tags (tagid, cd, tag) VALUES (7, 5, "Cheesy"); |
96 | |
97 | INSERT INTO tags (tagid, cd, tag) VALUES (8, 2, "Shiny"); |
98 | |
99 | INSERT INTO tags (tagid, cd, tag) VALUES (9, 4, "Shiny"); |
100 | |
101 | INSERT INTO twokeys (artist, cd) VALUES (1, 1); |
102 | |
103 | INSERT INTO twokeys (artist, cd) VALUES (1, 2); |
104 | |
105 | INSERT INTO twokeys (artist, cd) VALUES (2, 2); |
106 | |
107 | INSERT INTO fourkeys (foo, bar, hello, goodbye) VALUES (1, 2, 3, 4); |
108 | |
109 | INSERT INTO fourkeys (foo, bar, hello, goodbye) VALUES (5, 4, 3, 6); |
110 | |
111 | INSERT INTO onekey (id, artist, cd) VALUES (1, 1, 1); |
112 | |
113 | INSERT INTO onekey (id, artist, cd) VALUES (2, 1, 2); |
114 | |
115 | INSERT INTO onekey (id, artist, cd) VALUES (3, 2, 2); |
116 | |
117 | INSERT INTO self_ref (id, name) VALUES (1, 'First'); |
118 | |
119 | INSERT INTO self_ref (id, name) VALUES (2, 'Second'); |
120 | |
121 | INSERT INTO self_ref_alias (self_ref, alias) VALUES (1, 2); |
122 | |
5efe4c79 |
123 | INSERT INTO artist_undirected_map (id1, id2) VALUES (1, 2); |
124 | |
4d9d84d5 |
125 | INSERT INTO producer (producerid, name) VALUES (1, 'Matt S Trout'); |
126 | |
127 | INSERT INTO cd_to_producer (cd, producer) VALUES (1, 1); |
128 | |
129 | EOSQL |
130 | |
131 | $dbh->do($_) for split(/\n\n/, $sql); |
132 | |
133 | $schema->storage->dbh->do("PRAGMA synchronous = OFF"); |
134 | |
135 | 1; |