Restructure handling of the test scratch-dir, move all activity
[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;
c213fd3d 6use dbixcsl_test_dir qw/$tdir/;
f812ef60 7
8eval { require DBD::SQLite };
9my $class = $@ ? 'SQLite2' : 'SQLite';
10
c213fd3d 11my $fn = "$tdir/dbictest_clashing_tables.db";
f812ef60 12
13unlink($fn);
14our $dsn = "dbi:$class:dbname=$fn";
15my $dbh = DBI->connect($dsn);
be9f4d42 16$dbh->do('PRAGMA SYNCHRONOUS = OFF');
f812ef60 17
18$dbh->do($_) for (
19 q|CREATE TABLE foo (
20 fooid INTEGER PRIMARY KEY,
21 footext TEXT DEFAULT 'footext',
22 foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
23 )|,
24 q|CREATE TABLE bar (
25 barid INTEGER PRIMARY KEY,
26 fooref INTEGER REFERENCES foo(fooid)
27 )|,
28# this will cause a singularized moniker clash
29 q|CREATE TABLE bars (
30 barid INTEGER PRIMARY KEY,
31 fooref INTEGER REFERENCES foo(fooid)
32 )|,
33 q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|,
34 q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|,
35 q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|,
36 q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|,
37 q|INSERT INTO bar VALUES (1,4)|,
38 q|INSERT INTO bar VALUES (2,3)|,
39 q|INSERT INTO bar VALUES (3,2)|,
40 q|INSERT INTO bar VALUES (4,1)|,
41);
42
43END { unlink($fn); }
44
451;