Changeset 1315 for trunk/LATMOS-Accounts/bin
- Timestamp:
- 04/07/15 16:42:39 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-sql-upgrade.in
r1311 r1315 6 6 use Getopt::Long; 7 7 use Pod::Usage; 8 use Text::CSV_XS;9 8 10 9 my $DATADIR = '@DATADIR@'; … … 23 22 'c|config=s' => \my $config, 24 23 'b|base=s' => \my $base, 25 'a|attributes=s' => \my $attributes_file,26 24 'no-commit' => \my $nocommit, 27 25 'v|verbose' => \my $verbose, … … 29 27 ) or pod2usage(); 30 28 31 $attributes_file ||= "$DATADIR/attributes.csv";32 33 29 =head1 OPTIONS 34 30 … … 42 38 43 39 Query this specific base instead of the default one. 44 45 =item -a|--attribute cvs_file46 47 The attribute file description to use48 40 49 41 =back … … 398 390 }, 399 391 q{ 400 401 392 CREATE TABLE service_attributes_list 402 393 ( … … 567 558 } 568 559 569 print "Loading attribute from: $attributes_file\n"; 570 571 open my $fh, "<:encoding(utf8)", $attributes_file or die "$attributes_file: $!"; 572 573 my $csv = Text::CSV_XS->new(); 574 575 while (my $row = $csv->getline($fh)) { 576 my ($otype, $attribute, $comment) = @$row; 577 if ($labase->is_registered_attribute($otype, $attribute)) { 578 } else { 579 $labase->register_attribute($otype, $attribute, $comment) 580 or die "Error, aborting\n"; 581 print "Attr. $attribute for object type $otype registred\n"; 582 } 560 foreach my $otype ($labase->list_supported_objects) { 561 foreach my $attribute ($labase->list_canonical_fields($otype)) { 562 my $attr = $labase->attribute($otype, $attribute); 563 $attr->{inline} and next; 564 $attr->{managed} and next; 565 566 if ($labase->is_registered_attribute($otype, $attribute)) { 567 } else { 568 $labase->register_attribute($otype, $attribute, $attr->{comment}) 569 or die "Error, aborting\n"; 570 print "Attr. $attribute for object type $otype registred\n"; 571 } 572 } 583 573 } 584 574 585 $csv->eof or do {586 $csv->error_diag();587 die "Cannot load attribute\n"588 };589 590 575 foreach (@objects) { 591 576 if (!$labase->get_object($_->{otype}, $_->{name})) {
Note: See TracChangeset
for help on using the changeset viewer.