Test fix.
[blog.pm-common-perl-mods.git] / Rose-DB-Object-I18N / t / lib / NewDB.pm
blobc76baba465a923d419fdcc0ef99fd3547f75528a
1 package NewDB;
3 use DBI;
5 sub new {
6 my $class = shift;
8 my $self = { db => "/tmp/rose-i18n.db" };
10 bless $self, $class;
12 return $self;
15 sub init {
16 my $self = shift;
18 my $db = $self->{ db };
20 unless ( -f $db ) {
21 warn 'Creating new db...';
23 my $dbh = DBI->connect( "dbi:SQLite:$db" ) or die $DBI::errstr;
25 $dbh->do( <<SQL );
26 CREATE TABLE `user` (
27 `id` INTEGER PRIMARY KEY NOT NULL,
28 `orig_lang` CHARACTER VARYING(2) NOT NULL,
29 `name` CHARACTER VARYING(255) NOT NULL,
30 UNIQUE (`name`)
32 SQL
34 $dbh->do( <<SQL );
35 CREATE TABLE `user_i18n` (
36 `i18nid` INTEGER PRIMARY KEY NOT NULL,
37 `user_id` INTEGER NOT NULL,
38 `lang` CHARACTER VARYING(2) NOT NULL,
39 `signature` CHARACTER VARYING(255),
40 `istran` TINYINT(1) NOT NULL DEFAULT 0
42 SQL
44 $dbh->disconnect();
48 sub cleanup {
49 my $self = shift;
51 unlink $self->{ db };
54 =head1 AUTHOR
56 vti
58 =head1 LICENSE
60 This library is free software, you can redistribute it and/or modify
61 it under the same terms as Perl itself.
63 =cut