$a->valid( 'f' );
$a->valid( 't' ) if ($prefix eq 'std_');
+ $a->valid( 'f' ) if ($prefix eq 'std_' and $a->findvalue( "${prefix}dpvscore" ) < 3);
$a->within_city_limits( 'f' );
$a->country('USA');
use Getopt::Long;
my @files;
-my ($config, $output, @auto, @order) =
+my ($config, $output, @auto, @order, @wipe) =
('/openils/conf/bootstrap.conf');
GetOptions(
'config=s' => \$config,
'output=s' => \$output,
+ 'wipe=s' => \@wipe,
'autoprimary=s' => \@auto,
'order=s' => \@order,
);
$fieldcache{$hint} =
{ table => $class->Table,
+ sequence => $class->Sequence,
+ pkey => $class->Identity,
fields => \@cols,
};
}
for my $h (@order) {
my $fields = join(',', @{ $fieldcache{$h}{fields} });
+ $output->print( "DELETE FROM $fieldcache{$h}{table};\n" ) if (grep {$_ eq $h } @wipe);
$output->print( "COPY $fieldcache{$h}{table} ($fields) FROM STDIN;\n" );
for my $line (@{ $lineset{$h} }) {
}
$output->print('\.'."\n\n");
+
+ $output->print("SELECT setval('$fieldcache{$h}{sequence}'::TEXT, (SELECT MAX($fieldcache{$h}{pkey}) FROM $fieldcache{$h}{table}), TRUE);\n\n")
+ if (!grep { $_ eq $h} @auto);
}
$$fieldmap{$n}{hint} = $c;
$$fieldmap{$n}{virtual} = ($idl->{$c}{'oils_persist:virtual'} eq 'true') ? 1 : 0;
$$fieldmap{$n}{table} = $idl->{$c}{'oils_persist:tablename'};
+ $$fieldmap{$n}{sequence} = $idl->{$c}{fields}{'oils_persist:sequence'};
$$fieldmap{$n}{identity} = $idl->{$c}{fields}{'oils_persist:primary'};
for my $f ( keys %{ $idl->{$c}{fields}{field} } ) {
return $$fieldmap{$class_name}{identity};
}
+sub Sequence {
+ my $class_name = shift;
+ return $$fieldmap{$class_name}{sequence};
+}
+
sub Table {
my $class_name = shift;
return $$fieldmap{$class_name}{table};
ALTER TABLE actor.stat_cat_entry ADD CONSTRAINT actor_stat_cat_entry_stat_cat_fkey FOREIGN KEY (stat_cat) REFERENCES actor.stat_cat (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE actor.stat_cat_entry ADD CONSTRAINT actor_stat_cat_entry_owner_fkey FOREIGN KEY (owner) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sc_tu_fkey FOREIGN KEY (target_usr) REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
-
+ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sceum_tu_fkey FOREIGN KEY (target_usr) REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE actor.stat_cat_entry_usr_map ADD CONSTRAINT actor_sceum_sc_fkey FOREIGN KEY (stat_cat) REFERENCES actor.stat_cat (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE actor.org_unit ADD CONSTRAINT actor_org_unit_mailing_address_fkey FOREIGN KEY (mailing_address) REFERENCES actor.org_address (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE actor.org_unit ADD CONSTRAINT actor_org_unit_billing_address_fkey FOREIGN KEY (billing_address) REFERENCES actor.org_address (id) DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_oc_fkey FOREIGN KEY (owning_copy) REFERENCES asset.copy (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_sce_fkey FOREIGN KEY (stat_cat_entry) REFERENCES asset.stat_cat_entry (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE asset.stat_cat_entry_copy_map ADD CONSTRAINT a_sc_sc_fkey FOREIGN KEY (stat_cat) REFERENCES asset.stat_cat (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE money.billable_xact ADD CONSTRAINT money_billable_xact_usr_fkey FOREIGN KEY (usr) REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED;