| | 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 | |