Changeset 1843 for trunk


Ignore:
Timestamp:
10/18/16 16:06:10 (8 years ago)
Author:
nanardon
Message:

Automatically register attributes a db start

Location:
trunk/LATMOS-Accounts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/bin/la-sql-upgrade.in

    r1799 r1843  
    10571057} 
    10581058 
    1059 foreach my $otype ($labase->list_supported_objects) { 
    1060     foreach my $attribute ($labase->list_canonical_fields($otype, 'r')) { 
    1061         my $attr = $labase->attribute($otype, $attribute); 
    1062         $attr->{inline} and next; 
    1063         $attr->{managed} and next; 
    1064  
    1065         if ($labase->is_registered_attribute($otype, $attribute)) { 
    1066         } else { 
    1067             $labase->register_attribute($otype, $attribute, $attr->{comment}) 
    1068                 or die "Error, aborting\n"; 
    1069             print "Attr. $attribute for object type $otype registred\n"; 
    1070         } 
    1071     } 
    1072 } 
    1073  
    10741059foreach (@objects) { 
    10751060    if (!$labase->get_object($_->{otype}, $_->{name})) { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm

    r1838 r1843  
    9797        $self->{_db}->do(q{set DATESTYLE to 'DMY'}); 
    9898        $self->log(LA_DEBUG, 'New connection to DB'); 
     99 
     100        foreach my $otype ($self->list_supported_objects) { 
     101            foreach my $attribute ($self->list_canonical_fields($otype, 'r')) { 
     102                my $attr = $self->attribute($otype, $attribute); 
     103                $attr->{inline} and next; 
     104                $attr->{managed} and next; 
     105 
     106                if ($self->is_registered_attribute($otype, $attribute)) { 
     107                } else { 
     108                    if($self->register_attribute($otype, $attribute, $attr->{comment})) { 
     109                        $self->log(LA_NOTICE, "Attr. $attribute for object type $otype registred"); 
     110                    } else { 
     111                        $self->log(LA_ERR, "Can't register attribute $attribute"); 
     112                        $self->{_db}->rollback; 
     113                        return; 
     114                    } 
     115                } 
     116            } 
     117        } 
     118 
    99119        $self->{_db}->commit; 
    100120        return $self->{_db}; 
Note: See TracChangeset for help on using the changeset viewer.