File: Schema.pm

package info (click to toggle)
libdbix-class-tree-perl 0.03003-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 244 kB
  • sloc: perl: 1,554; sql: 8; makefile: 8
file content (35 lines) | stat: -rw-r--r-- 786 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package TreeTest::Schema;
use strict;
use warnings;

use base qw( DBIx::Class::Schema );

__PACKAGE__->load_classes();

sub connect {
    my $self = shift;

    my $db_file = 't/var/test.db';

    unlink($db_file) if -e $db_file;
    unlink($db_file . '-journal') if -e $db_file . '-journal';
    mkdir("t/var") unless -d "t/var";

    my $dsn = "dbi:SQLite:$db_file";
    my $schema = $self->next::method( $dsn );

    $schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]);

        my $dbh = $schema->storage->dbh;
        open SQL, "t/lib/sqlite.sql";
            my $sql;
            { local $/ = undef; $sql = <SQL>; }
        close SQL;
        $dbh->do($_) for split(/\n\n/, $sql);

    $schema->storage->dbh->do("PRAGMA synchronous = OFF");

    return $schema;
}

1;