1#!/usr/bin/perl -w 2 3use strict; 4 5use Alzabo::Create::Schema; 6 7unless (@ARGV) 8{ 9 print <<'EOF'; 10 11This script requires at least one argument, a schema name. If it is 12given multiple arguments it will treat them all as script names 13EOF 14 15 exit 0; 16} 17 18foreach (@ARGV) 19{ 20 my $s = Alzabo::Create::Schema->load_from_file( name => $_ ); 21 reverse_cardinality($s); 22} 23 24sub reverse_cardinality 25{ 26 my $s = shift; 27 28 foreach my $t ($s->tables) 29 { 30 foreach my $fk ($t->all_foreign_keys) 31 { 32 my @c = $fk->cardinality; 33 34 $fk->set_cardinality(@c[1,0]); 35 } 36 } 37 38 $s->save_to_file; 39} 40 41