1 package make_dbictest_db_with_unique;
7 eval { require DBD::SQLite };
8 my $class = $@ ? 'SQLite2' : 'SQLite';
10 my $fn = './t/dbictest_with_unique.db';
13 our $dsn = "dbi:$class:dbname=$fn";
14 my $dbh = DBI->connect($dsn);
18 fooid INTEGER PRIMARY KEY,
22 barid INTEGER PRIMARY KEY,
23 foo_id INTEGER NOT NULL REFERENCES foos (fooid)
26 bazid INTEGER PRIMARY KEY,
27 baz_num INTEGER NOT NULL UNIQUE,
28 stations_visited_id INTEGER REFERENCES stations_visited (id)
30 q|CREATE TABLE quuxs (
31 quuxid INTEGER PRIMARY KEY,
32 baz_id INTEGER NOT NULL UNIQUE,
33 FOREIGN KEY (baz_id) REFERENCES bazs (baz_num)
35 q|CREATE TABLE stations_visited (
36 id INTEGER PRIMARY KEY,
37 quuxs_id INTEGER REFERENCES quuxs (quuxid)
39 q|CREATE TABLE RouteChange (
40 id INTEGER PRIMARY KEY,
41 QuuxsId INTEGER REFERENCES quuxs (quuxid),
44 q|CREATE TABLE email (
45 id INTEGER PRIMARY KEY,
46 to_id INTEGER REFERENCES foos (fooid),
47 from_id INTEGER REFERENCES foos (fooid)
49 q|INSERT INTO foos VALUES (1,'Foos text for number 1')|,
50 q|INSERT INTO foos VALUES (2,'Foos record associated with the Bar with barid 3')|,
51 q|INSERT INTO foos VALUES (3,'Foos text for number 3')|,
52 q|INSERT INTO foos VALUES (4,'Foos text for number 4')|,
53 q|INSERT INTO bar VALUES (1,4)|,
54 q|INSERT INTO bar VALUES (2,3)|,
55 q|INSERT INTO bar VALUES (3,2)|,
56 q|INSERT INTO bar VALUES (4,1)|,
57 q|INSERT INTO bazs VALUES (1,20,1)|,
58 q|INSERT INTO bazs VALUES (2,19,1)|,
59 q|INSERT INTO quuxs VALUES (1,20)|,
60 q|INSERT INTO quuxs VALUES (2,19)|,
61 q|INSERT INTO stations_visited VALUES (1,1)|,
62 q|INSERT INTO RouteChange VALUES (1,1,3)|,