[Jifty-commit] jifty branch, setupwizard-refactor, updated. a7ab5e963c3b5b1453a5242c0c39617c684c4389
Jifty commits
jifty-commit at lists.jifty.org
Wed Jul 7 13:21:47 EDT 2010
The branch, setupwizard-refactor has been updated
via a7ab5e963c3b5b1453a5242c0c39617c684c4389 (commit)
from 20519e4a3d9b2a15314f7fbece4453a8de640d99 (commit)
Summary of changes:
lib/Jifty/Schema.pm | 167 ---------------------------------------------------
1 files changed, 0 insertions(+), 167 deletions(-)
- Log -----------------------------------------------------------------
commit a7ab5e963c3b5b1453a5242c0c39617c684c4389
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed Jul 7 13:20:28 2010 -0400
Remove a large hunk of never-used schema upgrade logic
It's left over from a9c4f40 in 2007, which is the beginning of
extracting schema logic from Jifty::Script::Schema into Jifty::Schema.
As far as I can tell, it appears it was never finished and this code
never used. Jifty passes all tests with it removed.
diff --git a/lib/Jifty/Schema.pm b/lib/Jifty/Schema.pm
index 8cd15bd..6baad86 100644
--- a/lib/Jifty/Schema.pm
+++ b/lib/Jifty/Schema.pm
@@ -89,173 +89,6 @@ sub serialize_current_schema {
}
-
-=head2 upgrade_schema
-
-Looks at the current schemas as defined by the source and the database and updates the database by adding, dropping, and renaming columns.
-
-=cut
-
-sub upgrade_schema {
- my $self = shift;
-
-
- # load the database schema version
-
- # hashref
- my $old_tables = $self->current_db_schema;
-
- # hashref
- my $new_tables = $self->new_db_schema;
-
- my $add_tables = {};
- my $remove_tables ={};
- my $add_columns = {};
- my $remove_columns = {};
-
- # diff the current schema version and the database schema version
- foreach my $table ( keys %$old_tables ) {
- unless ( $new_tables->{$table} ) {
- $remove_tables->{$table} = $old_tables->{$table};
- next;
- }
-
- foreach my $column ( @{ $old_tables->{$table}->columns } ) {
-
- # if the column isn't in the new table as well, then mark it for deletion
- unless ( $new_tables->{$table}->column($column) ) {
- push @{ $remove_columns->{$table} }, $column;
- }
-
- # XXX TODO: compare the column definitions and alter them if necessary
-
- }
- }
-
- foreach my $table ( keys %$new_tables ) {
- unless ( $old_tables->{$table} ) {
- $add_tables->{$table} = $new_tables->{$table};
- next;
- }
-
- foreach my $column ( @{ $new_tables->{$table}->columns } ) {
-
- # if the column isn't in the old table as well, then mark it for addition
- unless ( $old_tables->{$table}->column($column) ) {
- push @{ $add_columns->{$table} }, $column;
- }
-
- # XXX TODO: compare the column definitions and alter them if necessary
-
- }
- }
-
- # Run all "Rename" rules
- $self->run_upgrade_rules('before_all_renames');
- my $table_renames = Jifty->upgrade->table_renames;
- my $column_renames = Jifty->upgrade->column_renames;
- $self->run_upgrade_rules('after_column_renames');
-
- $self->_add_tables($add_tables);
- $self->_add_columns($add_columns);
- $self->_drop_tables($remove_tables);
- $self->_drop_columns($remove_columns);
-
-
-}
-
-
-sub _add_tables {
- my $self = shift;
- my $add_tables = shift;
-
-
- # add all new tables
- $self->run_upgrade_rules('before_table_adds');
- foreach my $table ( values %$add_tables ) {
- $self->run_upgrade_rules( 'before_add_table_' . $table );
- $add_tables->{$table}->create_table_in_db();
- $self->run_upgrade_rules( 'after_add_table_' . $table );
- }
- $self->run_upgrade_rules('after_table_adds');
-}
-
-
-sub _add_columns {
- my $self = shift;
- my $add_columns = shift;
-
- $self->run_upgrade_rules('before_column_adds');
- foreach my $table ( values %$add_columns ) {
- $self->run_upgrade_rules( 'before_add_columns_to_table_' . $table );
- my @cols = @{ $add_columns->{$table} };
- foreach my $col (@cols) {
- $self->run_upgrade_rules( 'before_add_column_' . $col->name . '_to_table_' . $table );
- $add_columns->{$table}->add_column_in_db($col);
- $self->run_upgrade_rules( 'after_add_column_' . $col->name . '_to_table_' . $table );
- }
- $self->run_upgrade_rules( 'after_add_columns_to_table_' . $table );
- }
- $self->run_upgrade_rules('after_add_columns');
-
-}
-
-
-
-
-sub _drop_tables {
- my $self =shift;
- my $remove_tables = shift;
-
-
- $self->run_upgrade_rules('before_drop_tables');
-
- foreach my $table ( values %$remove_tables ) {
- $self->run_upgrade_rules( 'before_drop_table_' . $table );
- $remove_tables->{$table}->drop_table_in_db();
- $self->run_upgrade_rules( 'after_drop_table_' . $table );
- }
- $self->run_upgrade_rules('after_drop_tables');
-
-}
-
-sub _drop_columns {
- my $self = shift;
- my $remove_columns = shift;
-
- $self->run_upgrade_rules('before_drop_columns');
-
- foreach my $table ( values %$remove_columns ) {
- $self->run_upgrade_rules( 'before_drop_columns_from_' . $table );
- my @cols = @{ $remove_columns->{$table} };
- foreach my $col (@cols) {
- $self->run_upgrade_rules( 'before_drop_column' . $col->name . '_from_' . $table );
- $remove_columns->{$table}->drop_column_in_db($col);
- $self->run_upgrade_rules( 'after_drop_column_' . $col->name . '_from_' . $table );
- }
- $self->run_upgrade_rules( 'after_drop_columns_from_' . $table );
- }
- $self->run_upgrade_rules('after_drop_columns');
-
-}
-
-
-=head2 run_upgrade_rules rule_name
-
-This method runs all upgrade rules for the rule named C<rule_name>.
-
-=cut
-
-sub run_upgrade_rules {
- my $self = shift;
- my $rule_name = shift;
-
- my $upgrade_object = Jifty->app_class('Upgrade');
- $upgrade_object->call_trigger($rule_name);
-}
-
-
-
sub _check_reserved {
my $self = shift;
my $model = shift;
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list