Changeset 404
- Timestamp:
- 02/04/08 22:09:56 (10 months ago)
- Location:
- veekun/trunk
- Files:
-
- 2 added
- 1 removed
- 4 modified
-
lib/Vee/Model/DBIC.pm (modified) (1 diff)
-
lib/Vee/Schema.pm (modified) (1 diff)
-
lib/Vee/Schema/Sessions.pm (modified) (1 diff)
-
lib/Vee/Schema/Shoutbox.pm (modified) (1 diff)
-
script/utils/schema-cleanup.pl (added)
-
t/controller_Shoutbox.t (deleted)
-
t/shoutbox.t (added)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Model/DBIC.pm
r186 r404 8 8 9 9 sub new { 10 # For testing purposes, allow use of a temporary SQLite db 11 if ($ENV{VEEKUN_USE_TEMP_DB}) { 12 # Use Catalyst's global config override and an in-memory db 13 $_[-1]->{connect_info} = ["dbi:SQLite:dbname=:memory:"]; 14 } 15 10 16 my $self = shift->NEXT::new(@_); 11 17 18 if ($ENV{VEEKUN_USE_TEMP_DB}) { 19 $self->schema->add_simple_column_types; 20 $self->schema->deploy({ producer => 'SQLite' }); 21 } 22 23 # TODO: What to do here? Temp db won't have any data! 12 24 Vee::Dex::initialize( $self ); 13 25 -
veekun/trunk/lib/Vee/Schema.pm
r31 r404 1 1 package Vee::Schema; 2 3 # Created by DBIx::Class::Schema::Loader v0.03003 @ 2006-07-09 12:56:134 2 5 3 use strict; 6 4 use warnings; 7 8 5 use base 'DBIx::Class::Schema'; 9 6 10 7 __PACKAGE__->load_classes; 11 8 9 =head1 METHODS 10 11 =head2 add_simple_column_types 12 13 Iterates over every column in every table in the schema. Primary key columns 14 named C<id> are given a C<data_type> of C<integer>; all other columns are set 15 C<is_nullable>. 16 17 This method is really a hack for deploying the schema to SQLite and testing with 18 dummy data; autoincrement will only work on single-column integral primary keys, 19 and defaults for every column would be a pain to mark just for tests. 20 21 =cut 22 23 sub add_simple_column_types { 24 my ($self) = @_; 25 26 for my $table_name ($self->sources) { 27 my $table = $self->source($table_name); 28 29 for my $column_name ($table->columns) { 30 my $column_info = $table->column_info($column_name); 31 32 # sessions table uses a string, as dictated by Session plugin 33 if ($table_name ne 'Sessions' and 34 $column_name eq 'id' and 35 join("\0", $table->primary_columns) eq 'id') 36 { 37 $column_info->{data_type} = 'integer'; 38 } else { 39 $column_info->{is_nullable} = 1; 40 } 41 } 42 } 43 } 44 12 45 1; -
veekun/trunk/lib/Vee/Schema/Sessions.pm
r350 r404 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('sessions'); 15 __PACKAGE__->add_columns(qw/ id userid expires data /); 15 # All these columns need to be NULLable for deployment, as Catalyst's session 16 # handling is dumb and insists on shoving useless undef values into this table. 17 __PACKAGE__->add_columns( 18 'id', 19 userid => { is_nullable => 1 }, 20 expires => { is_nullable => 1 }, 21 data => { is_nullable => 1 }, 22 ); 16 23 __PACKAGE__->set_primary_key('id'); 17 24 -
veekun/trunk/lib/Vee/Schema/Shoutbox.pm
r350 r404 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('shoutbox'); 15 __PACKAGE__->add_columns(qw/ id name userid ip time message /); 15 __PACKAGE__->add_columns( 16 qw/ id name /, 17 userid => { is_nullable => 1 }, 18 qw/ ip time message / 19 ); 16 20 __PACKAGE__->set_primary_key('id'); 17 21
