/[Frey]/trunk/lib/Strix/Schema.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Strix/Schema.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 55 by dpavlin, Sat Jul 5 19:00:10 2008 UTC revision 624 by dpavlin, Sat Nov 29 17:47:34 2008 UTC
# Line 1  Line 1 
1  package Strix::Schema;  package Strix::Schema;
2    
 use Fey::DBIManager;  
 use Fey::DBIManager::Source;  
 use Fey::Loader;  
3  use Fey::ORM::Schema;  use Fey::ORM::Schema;
4    use Frey::Schema;
5    
6  use Storable;  sub debug { 0 } # FIXME fake
7  use Data::Dump qw/dump/;  with 'Frey::Config';
8  use URI::Escape;  my $dsn = __PACKAGE__->config( __PACKAGE__ )->{dsn}; # FIXME yaaaack
9    
10  my $dsn = 'dbi:Pg:dbname=new';  my ( $schema, $source ) = Frey::Schema->schema_source( $dsn );
 $dsn = 'dbi:SQLite:dbname=./var/strix.sqlite';  
   
 my $schema_file = 'var/schema.' . uri_escape( $dsn );  
   
 warn "Database $dsn schema cache $schema_file\n";  
   
 my $source = Fey::DBIManager::Source->new( dsn => $dsn );  
   
 my $schema;  
 if ( 0 ) { # FIXME  
 #if ( -e $schema_file ) {  
         $schema = retrieve $schema_file or die "can't read schema from $schema_file: $!";  
 } else {  
         $schema = Fey::Loader->new( dbh => $source->dbh() )->make_schema();  
         store $schema, $schema_file or warn "can't store schema into $schema_file: $!";  
 }  
11    
12  has_schema $schema;  has_schema $schema;
13    
14    #warn Strix::Schema->SQLFactoryClass();
15    
16  __PACKAGE__->DBIManager()->add_source($source);  __PACKAGE__->DBIManager()->add_source($source);
17    
18  warn "loaded.";  $source->dbh->do( qq{ set client_encoding = 'utf-8' } ) if $dsn =~ /Pg/;
19    
20  1;  1;

Legend:
Removed from v.55  
changed lines
  Added in v.624

  ViewVC Help
Powered by ViewVC 1.1.26