Restructure handling of the test scratch-dir, move all activity
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / backcompat / 0.04006 / lib / make_dbictest_db.pm
1 package make_dbictest_db;
2
3 use strict;
4 use warnings;
5 use DBI;
6 use dbixcsl_test_dir qw/$tdir/;
7
8 eval { require DBD::SQLite };
9 my $class = $@ ? 'SQLite2' : 'SQLite';
10
11 my $fn = "$tdir/dbictest.db";
12
13 unlink($fn);
14 our $dsn = "dbi:$class:dbname=$fn";
15 my $dbh = DBI->connect($dsn);
16 $dbh->do ('PRAGMA SYNCHRONOUS = OFF');
17
18 $dbh->do($_) for (
19     q|CREATE TABLE foo (
20         fooid INTEGER PRIMARY KEY,
21         footext TEXT
22       )|,
23     q|CREATE TABLE bar (
24         barid INTEGER PRIMARY KEY,
25         fooref INTEGER REFERENCES foo(fooid)
26       )|,
27     q|INSERT INTO foo VALUES (1,'Foo text for number 1')|,
28     q|INSERT INTO foo VALUES (2,'Foo record associated with the Bar with barid 3')|,
29     q|INSERT INTO foo VALUES (3,'Foo text for number 3')|,
30     q|INSERT INTO foo VALUES (4,'Foo text for number 4')|,
31     q|INSERT INTO bar VALUES (1,4)|,
32     q|INSERT INTO bar VALUES (2,3)|,
33     q|INSERT INTO bar VALUES (3,2)|,
34     q|INSERT INTO bar VALUES (4,1)|,
35 );
36
37 END { unlink($fn); }
38
39 1;