Commit | Line | Data |
5c06aa08 |
1 | package make_dbictest_db_comments; |
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 table_comments ( |
20 | id INTEGER PRIMARY KEY, |
21 | table_name TEXT, |
22 | comment_text TEXT |
23 | )|, |
24 | q|CREATE TABLE column_comments ( |
25 | id INTEGER PRIMARY KEY, |
26 | table_name TEXT, |
27 | column_name TEXT, |
28 | comment_text TEXT |
29 | )|, |
30 | q|CREATE TABLE foo ( |
31 | fooid INTEGER PRIMARY KEY, |
32 | footext TEXT DEFAULT 'footext', |
33 | foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
34 | )|, |
35 | q|CREATE TABLE bar ( |
36 | barid INTEGER PRIMARY KEY, |
37 | fooref INTEGER REFERENCES foo(fooid) |
38 | )|, |
39 | q|INSERT INTO table_comments (id, table_name, comment_text) |
40 | VALUES (1, 'foo', 'a short comment') |
41 | |, |
42 | q|INSERT INTO table_comments (id, table_name, comment_text) |
43 | VALUES (2, 'bar', 'a | . ('very ' x 80) . q|long comment') |
44 | |, |
45 | q|INSERT INTO column_comments (id, table_name, column_name, comment_text) |
46 | VALUES (1, 'foo', 'fooid', 'a short comment') |
47 | |, |
48 | q|INSERT INTO column_comments (id, table_name, column_name, comment_text) |
49 | VALUES (2, 'foo', 'footext', 'a | . ('very ' x 80) . q|long comment') |
50 | |, |
51 | q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|, |
52 | q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|, |
53 | q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|, |
54 | q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|, |
55 | q|INSERT INTO bar VALUES (1,4)|, |
56 | q|INSERT INTO bar VALUES (2,3)|, |
57 | q|INSERT INTO bar VALUES (3,2)|, |
58 | q|INSERT INTO bar VALUES (4,1)|, |
59 | ); |
60 | |
6d358d58 |
61 | END { unlink($fn) unless $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}; } |
5c06aa08 |
62 | |
63 | 1 |