Alzabo
view release on metacpan or search on metacpan
);
if ( $opts{help} )
{
print <<'EOF';
perl Build.PL [--automated] [--pg] [--mysql]
This script accepts several options:
--automated Run without prompts
--pg Include prereqs for PostgreSQL support
--mysql Include prereqs for MySQL support
--root Root dir for storing Alzabos schemas
--help What you are reading
EOF
);
return $root_dir if $opts{automated};
print <<'EOF';
Please select a root directory for Alzabo (schema files will be stored
under this root.
EOF
return Module::Build->prompt( ' Alzabo root?', $root_dir );
}
sub find_possible_root
{
my @dirs;
if ( $^O =~ /win/i )
{
# A bit too thorough?
foreach ('C'..'Z')
{
my $name = $names{$t};
print <<'EOF';
The information from the following questions are used solely for
testing the pieces of Alzabo that require a real database for proper
testing.
EOF
my $do = Module::Build->prompt( " Do tests with $name RDBMS?", 'yes' );
next unless $do =~ /^y/i;
print <<"EOF";
Please provide a username that can be used to connect to the $name
RDBMS? This user must have the ability to create a new
database/schema.
EOF
my $user = Module::Build->prompt( ' Username?' );
my $password;
if ($user)
{
$password = Module::Build->prompt( " Password for $user?" );
}
print <<"EOF";
What host is the $name RDBMS located on. Press enter to skip this if
the database server is located on the localhost or can be determined
in another way (for example, Oracle can use TNS to find the database).
EOF
my $host = Module::Build->prompt( ' Host?' );
print <<"EOF";
What port is the $name RDBMS located on. Press enter to skip this.
EOF
my $port = Module::Build->prompt( ' Port?' );
print <<'EOF';
Please provide a database name that can be used for testing. A
database/schema with this name will be created and dropped during the
testing process.
EOF
my $db_name = Module::Build->prompt( ' Database name?', "test_alzabo_$t" );
push @config,
{ rdbms => $t,
user => $user,
password => $password,
host => $host,
port => $port,
schema_name => $db_name,
};
}
Makefile.PL view on Meta::CPAN
use strict;
unless (eval "use Module::Build 0.20; 1" ) {
print "This module requires Module::Build to install itself.\n";
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build from CPAN?', 'y');
if ($yn =~ /^y/i) {
require Cwd;
require File::Spec;
require CPAN;
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
my $makefile = File::Spec->rel2abs($0);
Install information is in the INSTALL file.
REQUIREMENTS
Alzabo passes all its test with Perl 5.6.1+. 5.6.0 is known to be
buggy and not recommended.
Alzabo currently supports MySQL (3.23.x or 4.0.x release is
recommended) and Postgres (7.2.x or newer is recommended).
Alzabo also requires a number of modules, and will prompt you to
install them if necessary. Of course, if you install Alzabo via the
CPAN or CPANPLUS shells this will be handled for you.
SUPPORT
The Alzabo docs are conveniently located online at
http://www.alzabo.org/docs/.
There is also a mailing list. You can sign up at
http://lists.sourceforge.net/lists/listinfo/alzabo-general.
- reconsider MethodMaker's pre/post hooks and try to re-implement in a
more flexible/sane manner.
- Abort during Build.PL if supplied username/pw cannot connect to DB
(and try to test privs too). Suggested by Robert Creager.
- Output Dia XML.
- Make a tool to convert schemas from one RDBMS to another. This will
probably require user prompting because some things are unresolvable
without a loss of information.
- Add an Alzabo::Database class between the schema and table. This
will allow multiple databases in a schema (on multiple platforms
ideally) and allow you to do joins between these databases. This
probably raises all sorts of horrid transactional issues
I haven't yet thought of.
- Attempt to guess relationships when reverse engineering a schema
without foreign key information.
eg/convert.pl view on Meta::CPAN
#!/usr/bin/perl -w
use strict;
use Alzabo::Create;
use ExtUtils::MakeMaker qw(prompt);
use Getopt::Long;
my $V = $Alzabo::VERSION;
use vars qw($name);
unless (@ARGV)
{
@ARGV = Alzabo::Config::available_schemas();
print "No arguments given. Converting all schemas\n\n";
eg/convert.pl view on Meta::CPAN
my $column = $c->name;
my $owner = $c->definition->owner->name;
my $owner_table = $c->definition->owner->table->name;
push @eval, "\$d = \$$name\->table('$owner_table')->column('$owner')->definition;";
push @eval, "\$$name\->table('$table')->column('$column')->set_definition( \$d );\n";
}
sub save_schema
{
my $s_name = shift;
my $file = prompt( "File to which schema should be written?", "${s_name}_schema.pl" );
local *S;
open S, ">$file" or die "Cannot open file '$file': $!\n";
unless ( print S (join "\n", @eval) ) { die "Cannot write to file '$file': $!\n"; }
close S or die "Cannot close file '$file': $!\n";
print <<"EOF";
The schema has been saved to $file.
To use this file, you will first have to install the version of Alzabo
( run in 0.996 second using v1.01-cache-2.11-cpan-0b5f733616e )