1SQL::Translator::FilterU:s:eGrloCboanltsr(i3b)uted PerlSDQoLc:u:mTernatnastliaotnor::Filter::Globals(3)
2
3
4
6 SQL::Translator::Filter::Globals - Add global fields and indices to all
7 tables.
8
10 # e.g. Add timestamp field to all tables.
11 use SQL::Translator;
12
13 my $sqlt = SQL::Translator->new(
14 from => 'MySQL',
15 to => 'MySQL',
16 filters => [
17 Globals => {
18 fields => [
19 {
20 name => 'modified'
21 data_type => 'TIMESTAMP'
22 }
23 ],
24 indices => [
25 {
26 fields => 'modifed',
27 },
28 ]
29 constraints => [
30 {
31 }
32 ]
33 },
34 ],
35 ) || die "SQLFairy error : ".SQL::Translator->error;
36 my $sql = $sqlt->translate || die "SQLFairy error : ".$sqlt->error;
37
39 Adds global fields, indices and constraints to all tables in the
40 schema. The globals to add can either be defined in the filter args or
41 using a _GLOBAL_ table (see below).
42
43 If a table already contains a field with the same name as a global then
44 it is skipped for that table.
45
46 The _GLOBAL_ Table
47 An alternative to using the args is to add a table called "_GLOBAL_" to
48 the schema and then just use the filter. Any fields and indices defined
49 on this table will be added to all the tables in the schema and the
50 _GLOBAL_ table removed.
51
52 The name of the global can be changed using a "global_table" arg to the
53 filter.
54
56 perl(1), SQL::Translator
57
59 Will generate duplicate indices if an index already exists on a table
60 the same as one added globally.
61
62 Will generate duplicate constraints if a constraint already exists on a
63 table the same as one added globally.
64
66 Some extra data values that can be used to control the global addition.
67 e.g. 'skip_global'.
68
70 Mark Addison <grommit@users.sourceforge.net>
71
72
73
74perl v5.32.1 2021-01-27SQL::Translator::Filter::Globals(3)