MySQL::Diff::Table(3pm) User Contributed Perl Documentation MySQL::Diff::Table(3pm)NAME
MySQL::Diff::Table - Table Definition Class
SYNOPSIS
use MySQL::Diff::Table
my $db = MySQL::Diff::Database->new(%options);
my $def = $db->def();
my $name = $db->name();
my $field = $db->field();
my $fields = $db->fields(); # %$fields
my $primary_key = $db->primary_key();
my $indices = $db->indices(); # %$indices
my $options = $db->options();
my $isfield = $db->isa_field($field);
my $isprimary = $db->isa_primary($field);
my $isindex = $db->isa_index($field);
my $isunique = $db->is_unique($field);
my $isfulltext = $db->is_fulltext($field);
DESCRIPTION
Parses a table definition into component parts.
METHODS
Constructor
new( %options )
Instantiate the objects, providing the command line options for database access and process requirements.
Public Methods
Fuller documentation will appear here in time :)
o def
Returns the table definition as a string.
o name
Returns the name of the current table.
o field
Returns the current field definition of the given field.
o fields
Returns an array reference to a list of fields.
o primary_key
Returns a hash reference to fields used as primary key fields.
o indices
Returns a hash reference to fields used as index fields.
o options
Returns the additional options added to the table definition.
o isa_field
Returns 1 if given field is used in the current table definition, otherwise returns 0.
o isa_primary
Returns 1 if given field is defined as a primary key, otherwise returns 0.
o isa_index
Returns 1 if given field is used as an index field, otherwise returns 0.
o is_unique
Returns 1 if given field is used as unique index field, otherwise returns 0.
o is_fulltext
Returns 1 if given field is used as fulltext index field, otherwise returns 0.
COPYRIGHT AND LICENSE
Copyright (c) 2000-2011 Adam Spiers. All rights reserved. This program is free software; you can redistribute it and/or modify it under the
same terms as Perl itself.
SEE ALSO
mysqldiff, MySQL::Diff, MySQL::Diff::Database, MySQL::Diff::Utils
AUTHOR
Adam Spiers <mysqldiff@adamspiers.org>
perl v5.14.2 2012-04-06 MySQL::Diff::Table(3pm)
Check Out this Related Man Page
SQL::Translator::Diff(3pm) User Contributed Perl Documentation SQL::Translator::Diff(3pm)NAME
SQL::Translator::Diff - determine differences between two schemas
DESCRIPTION
Takes two input SQL::Translator::Schemas (or SQL files) and produces ALTER statments to make them the same
SNYOPSIS
Simplest usage:
use SQL::Translator::Diff;
my $sql = SQL::Translator::Diff::schema_diff($source_schema, 'MySQL', $target_schema, 'MySQL', $options_hash)
OO usage:
use SQL::Translator::Diff;
my $diff = SQL::Translator::Diff->new({
output_db => 'MySQL',
source_schema => $source_schema,
target_schema => $target_schema,
%$options_hash,
})->compute_differences->produce_diff_sql;
OPTIONS
ignore_index_names
Match indexes based on types and fields, ignoring name.
ignore_constraint_names
Match constrains based on types, fields and tables, ignoring name.
output_db
Which producer to use to produce the output.
case_insensitive
Ignore case of table, field, index and constraint names when comparing
no_batch_alters
Produce each alter as a distinct "ALTER TABLE" statement even if the producer supports the ability to do all alters for a table as one
statement.
ignore_missing_methods
If the diff would need a method that is missing from the producer, just emit a comment showing the method is missing, rather than
dieing with an error
PRODUCER FUNCTIONS
The following producer functions should be implemented for completeness. If any of them are needed for a given diff, but not found, an
error will be thrown.
o "alter_create_constraint($con)"
o "alter_drop_constraint($con)"
o "alter_create_index($idx)"
o "alter_drop_index($idx)"
o "add_field($fld)"
o "alter_field($old_fld, $new_fld)"
o "rename_field($old_fld, $new_fld)"
o "drop_field($fld)"
o "alter_table($table)"
o "drop_table($table)"
o "rename_table($old_table, $new_table)" (optional)
o "batch_alter_table($table, $hash)" (optional)
If the producer supports "batch_alter_table", it will be called with the table to alter and a hash, the keys of which will be the
method names listed above; values will be arrays of fields or constraints to operate on. In the case of the field functions that take
two arguments this will appear as a hash.
I.e. the hash might look something like the following:
{
alter_create_constraint => [ $constraint1, $constraint2 ],
add_field => [ $field ],
alter_field => [ [$old_field, $new_field] ]
}
o "preprocess_schema($class, $schema)" (optional)
"preprocess_schema" is called by the Diff code to allow the producer to normalize any data it needs to first. For example, the MySQL
producer uses this method to ensure that FK contraint names are unique.
Basicaly any changes that need to be made to produce the SQL file for the schema should be done here, so that a diff between a parsed
SQL file and (say) a parsed DBIx::Class::Schema object will be sane.
(As an aside, DBIx::Class, for instance, uses the presence of a "preprocess_schema" function on the producer to know that it can diff
between the previous SQL file and its own internal representation. Without this method on th producer it will diff the two SQL files
which is slower, but known to work better on old-style producers.)
AUTHOR
Original Author(s) unknown.
Refactor/re-write and more comprehensive tests by Ash Berlin "ash@cpan.org".
Redevelopment sponsored by Takkle Inc.
perl v5.14.2 2012-05-01 SQL::Translator::Diff(3pm)