Commit | Line | Data |
c0a0986f |
1 | package make_dbictest_db_plural_tables; |
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 | |
fb60e46b |
11 | my $fn = "$tdir/dbictest_plural_tables.db"; |
c0a0986f |
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 foos ( |
20 | fooid INTEGER PRIMARY KEY, |
21 | footext TEXT DEFAULT 'footext', |
22 | foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
23 | )|, |
24 | q|CREATE TABLE bars ( |
25 | barid INTEGER PRIMARY KEY, |
fb60e46b |
26 | fooref INTEGER REFERENCES foos(fooid) |
c0a0986f |
27 | )|, |
28 | q|INSERT INTO foos (fooid, footext) VALUES (1,'Foo text for number 1')|, |
29 | q|INSERT INTO foos (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|, |
30 | q|INSERT INTO foos (fooid, footext) VALUES (3,'Foo text for number 3')|, |
31 | q|INSERT INTO foos (fooid, footext) VALUES (4,'Foo text for number 4')|, |
32 | q|INSERT INTO bars VALUES (1,4)|, |
33 | q|INSERT INTO bars VALUES (2,3)|, |
34 | q|INSERT INTO bars VALUES (3,2)|, |
35 | q|INSERT INTO bars VALUES (4,1)|, |
36 | ); |
37 | |
6d358d58 |
38 | END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; } |
c0a0986f |
39 | |
40 | 1; |