Speed up sqlite-based tests (disable synchronous disk writes)
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / make_dbictest_db_clashing_monikers.pm
CommitLineData
f812ef60 1package make_dbictest_db_clashing_monikers;
2
3use strict;
4use warnings;
5use DBI;
6
7eval { require DBD::SQLite };
8my $class = $@ ? 'SQLite2' : 'SQLite';
9
10my $fn = './t/dbictest_clashing_tables.db';
11
12unlink($fn);
13our $dsn = "dbi:$class:dbname=$fn";
14my $dbh = DBI->connect($dsn);
be9f4d42 15$dbh->do('PRAGMA SYNCHRONOUS = OFF');
f812ef60 16
17$dbh->do($_) for (
18 q|CREATE TABLE foo (
19 fooid INTEGER PRIMARY KEY,
20 footext TEXT DEFAULT 'footext',
21 foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
22 )|,
23 q|CREATE TABLE bar (
24 barid INTEGER PRIMARY KEY,
25 fooref INTEGER REFERENCES foo(fooid)
26 )|,
27# this will cause a singularized moniker clash
28 q|CREATE TABLE bars (
29 barid INTEGER PRIMARY KEY,
30 fooref INTEGER REFERENCES foo(fooid)
31 )|,
32 q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|,
33 q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|,
34 q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|,
35 q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|,
36 q|INSERT INTO bar VALUES (1,4)|,
37 q|INSERT INTO bar VALUES (2,3)|,
38 q|INSERT INTO bar VALUES (3,2)|,
39 q|INSERT INTO bar VALUES (4,1)|,
40);
41
42END { unlink($fn); }
43
441;