5 my $db_file = "t/var/DBIxClass.db";
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";
11 my $dsn = "dbi:SQLite:${db_file}";
13 my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn);
15 my $dbh = DBI->connect($dsn);
18 CREATE TABLE artist (artistid INTEGER NOT NULL PRIMARY KEY, name VARCHAR);
20 CREATE TABLE cd (cdid INTEGER NOT NULL PRIMARY KEY, artist INTEGER NOT NULL,
21 title VARCHAR, year VARCHAR);
23 CREATE TABLE liner_notes (liner_id INTEGER NOT NULL PRIMARY KEY, notes VARCHAR);
25 CREATE TABLE track (trackid INTEGER NOT NULL PRIMARY KEY, cd INTEGER NOT NULL,
26 position INTEGER NOT NULL, title VARCHAR);
28 CREATE TABLE tags (tagid INTEGER NOT NULL PRIMARY KEY, cd INTEGER NOT NULL,
31 CREATE TABLE twokeys (artist INTEGER NOT NULL, cd INTEGER NOT NULL,
32 PRIMARY KEY (artist, cd) );
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) );
38 CREATE TABLE onekey (id INTEGER NOT NULL PRIMARY KEY,
39 artist INTEGER NOT NULL, cd INTEGER NOT NULL );
41 CREATE TABLE self_ref (id INTEGER NOT NULL PRIMARY KEY,
44 CREATE TABLE self_ref_alias (self_ref INTEGER NOT NULL, alias INTEGER NOT NULL,
45 PRIMARY KEY( self_ref, alias ) );
47 CREATE TABLE artist_undirected_map (id1 INTEGER NOT NULL, id2 INTEGER NOT NULL, PRIMARY KEY(id1, id2));
49 CREATE TABLE producer (producerid INTEGER NOT NULL PRIMARY KEY, name VARCHAR);
51 CREATE TABLE cd_to_producer (cd INTEGER NOT NULL, producer INTEGER NOT NULL);
53 INSERT INTO artist (artistid, name) VALUES (1, 'Caterwauler McCrae');
55 INSERT INTO artist (artistid, name) VALUES (2, 'Random Boy Band');
57 INSERT INTO artist (artistid, name) VALUES (3, 'We Are Goth');
59 INSERT INTO cd (cdid, artist, title, year)
60 VALUES (1, 1, "Spoonful of bees", 1999);
62 INSERT INTO cd (cdid, artist, title, year)
63 VALUES (2, 1, "Forkful of bees", 2001);
65 INSERT INTO cd (cdid, artist, title, year)
66 VALUES (3, 1, "Caterwaulin' Blues", 1997);
68 INSERT INTO cd (cdid, artist, title, year)
69 VALUES (4, 2, "Generic Manufactured Singles", 2001);
71 INSERT INTO cd (cdid, artist, title, year)
72 VALUES (5, 3, "Come Be Depressed With Us", 1998);
74 INSERT INTO liner_notes (liner_id, notes)
75 VALUES (2, "Buy Whiskey!");
77 INSERT INTO liner_notes (liner_id, notes)
78 VALUES (4, "Buy Merch!");
80 INSERT INTO liner_notes (liner_id, notes)
81 VALUES (5, "Kill Yourself!");
83 INSERT INTO tags (tagid, cd, tag) VALUES (1, 1, "Blue");
85 INSERT INTO tags (tagid, cd, tag) VALUES (2, 2, "Blue");
87 INSERT INTO tags (tagid, cd, tag) VALUES (3, 3, "Blue");
89 INSERT INTO tags (tagid, cd, tag) VALUES (4, 5, "Blue");
91 INSERT INTO tags (tagid, cd, tag) VALUES (5, 2, "Cheesy");
93 INSERT INTO tags (tagid, cd, tag) VALUES (6, 4, "Cheesy");
95 INSERT INTO tags (tagid, cd, tag) VALUES (7, 5, "Cheesy");
97 INSERT INTO tags (tagid, cd, tag) VALUES (8, 2, "Shiny");
99 INSERT INTO tags (tagid, cd, tag) VALUES (9, 4, "Shiny");
101 INSERT INTO twokeys (artist, cd) VALUES (1, 1);
103 INSERT INTO twokeys (artist, cd) VALUES (1, 2);
105 INSERT INTO twokeys (artist, cd) VALUES (2, 2);
107 INSERT INTO fourkeys (foo, bar, hello, goodbye) VALUES (1, 2, 3, 4);
109 INSERT INTO fourkeys (foo, bar, hello, goodbye) VALUES (5, 4, 3, 6);
111 INSERT INTO onekey (id, artist, cd) VALUES (1, 1, 1);
113 INSERT INTO onekey (id, artist, cd) VALUES (2, 1, 2);
115 INSERT INTO onekey (id, artist, cd) VALUES (3, 2, 2);
117 INSERT INTO self_ref (id, name) VALUES (1, 'First');
119 INSERT INTO self_ref (id, name) VALUES (2, 'Second');
121 INSERT INTO self_ref_alias (self_ref, alias) VALUES (1, 2);
123 INSERT INTO artist_undirected_map (id1, id2) VALUES (1, 2);
125 INSERT INTO producer (producerid, name) VALUES (1, 'Matt S Trout');
127 INSERT INTO cd_to_producer (cd, producer) VALUES (1, 1);
131 $dbh->do($_) for split(/\n\n/, $sql);
133 $schema->storage->dbh->do("PRAGMA synchronous = OFF");