add self to credits
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / make_dbictest_db_multi_unique.pm
CommitLineData
6d358d58 1package make_dbictest_db_multi_unique;
2
3use strict;
4use warnings;
5use DBI;
6use dbixcsl_test_dir qw/$tdir/;
7
8eval { require DBD::SQLite };
9my $class = $@ ? 'SQLite2' : 'SQLite';
10
11my $fn = "$tdir/dbictest_multi_unique.db";
12
13unlink($fn);
14our $dsn = "dbi:$class:dbname=$fn";
15my $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 DEFAULT 'footext',
22 foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP
23 )|,
24 q|CREATE TABLE bar (
25 barid INTEGER PRIMARY KEY,
26 uniq1 INT UNIQUE,
27 uniq2 INT UNIQUE,
28 fooref INTEGER REFERENCES foo(fooid)
29 )|,
30 q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|,
31 q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|,
32 q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|,
33 q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|,
34 q|INSERT INTO bar VALUES (1,1,1,4)|,
35 q|INSERT INTO bar VALUES (2,2,2,3)|,
36 q|INSERT INTO bar VALUES (3,3,3,2)|,
37 q|INSERT INTO bar VALUES (4,4,4,1)|,
38);
39
40END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; }
41
421;