1SQL::Translator::Diff(3U)ser Contributed Perl DocumentatiSoQnL::Translator::Diff(3)
2
3
4

NAME

6       SQL::Translator::Diff - determine differences between two schemas
7

DESCRIPTION

9       Takes two input SQL::Translator::Schemas (or SQL files) and produces
10       ALTER statements to make them the same
11

SNYOPSIS

13       Simplest usage:
14
15        use SQL::Translator::Diff;
16        my $sql = SQL::Translator::Diff::schema_diff($source_schema, 'MySQL', $target_schema, 'MySQL', $options_hash)
17
18       OO usage:
19
20        use SQL::Translator::Diff;
21        my $diff = SQL::Translator::Diff->new({
22          output_db     => 'MySQL',
23          source_schema => $source_schema,
24          target_schema => $target_schema,
25          %$options_hash,
26        })->compute_differences->produce_diff_sql;
27

OPTIONS

29       ignore_index_names
30           Match indexes based on types and fields, ignoring name.
31
32       ignore_constraint_names
33           Match constrains based on types, fields and tables, ignoring name.
34
35       output_db
36           Which producer to use to produce the output.
37
38       case_insensitive
39           Ignore case of table, field, index and constraint names when
40           comparing
41
42       no_batch_alters
43           Produce each alter as a distinct "ALTER TABLE" statement even if
44           the producer supports the ability to do all alters for a table as
45           one statement.
46
47       ignore_missing_methods
48           If the diff would need a method that is missing from the producer,
49           just emit a comment showing the method is missing, rather than
50           dieing with an error
51
52       producer_args
53           Hash of extra arguments passed to "new" in SQL::Translator and the
54           below "PRODUCER FUNCTIONS".
55

PRODUCER FUNCTIONS

57       The following producer functions should be implemented for
58       completeness. If any of them are needed for a given diff, but not
59       found, an error will be thrown.
60
61       ·   "alter_create_constraint($con, $args)"
62
63       ·   "alter_drop_constraint($con, $args)"
64
65       ·   "alter_create_index($idx, $args)"
66
67       ·   "alter_drop_index($idx, $args)"
68
69       ·   "add_field($fld, $args)"
70
71       ·   "alter_field($old_fld, $new_fld, $args)"
72
73       ·   "rename_field($old_fld, $new_fld, $args)"
74
75       ·   "drop_field($fld, $args)"
76
77       ·   "alter_table($table, $args)"
78
79       ·   "drop_table($table, $args)"
80
81       ·   "rename_table($old_table, $new_table, $args)" (optional)
82
83       ·   "batch_alter_table($table, $hash, $args)" (optional)
84
85           If the producer supports "batch_alter_table", it will be called
86           with the table to alter and a hash, the keys of which will be the
87           method names listed above; values will be arrays of fields or
88           constraints to operate on. In the case of the field functions that
89           take two arguments this will appear as an array reference.
90
91           I.e. the hash might look something like the following:
92
93            {
94              alter_create_constraint => [ $constraint1, $constraint2 ],
95              add_field   => [ $field ],
96              alter_field => [ [$old_field, $new_field] ]
97            }
98
99       ·   "preprocess_schema($schema)" (optional)
100
101           "preprocess_schema" is called by the Diff code to allow the
102           producer to normalize any data it needs to first. For example, the
103           MySQL producer uses this method to ensure that FK constraint names
104           are unique.
105
106           Basicaly any changes that need to be made to produce the SQL file
107           for the schema should be done here, so that a diff between a parsed
108           SQL file and (say) a parsed DBIx::Class::Schema object will be
109           sane.
110
111           (As an aside, DBIx::Class, for instance, uses the presence of a
112           "preprocess_schema" function on the producer to know that it can
113           diff between the previous SQL file and its own internal
114           representation. Without this method on th producer it will diff the
115           two SQL files which is slower, but known to work better on old-
116           style producers.)
117

AUTHOR

119       Original Author(s) unknown.
120
121       Refactor/re-write and more comprehensive tests by Ash Berlin
122       "ash@cpan.org".
123
124       Redevelopment sponsored by Takkle Inc.
125
126
127
128perl v5.32.0                      2020-09-14          SQL::Translator::Diff(3)
Impressum