.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SQL::Translator::Filter::Globals 3pm" .TH SQL::Translator::Filter::Globals 3pm 2024-01-20 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME SQL::Translator::Filter::Globals \- Add global fields and indices to all tables. .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& # e.g. Add timestamp field to all tables. \& use SQL::Translator; \& \& my $sqlt = SQL::Translator\->new( \& from => \*(AqMySQL\*(Aq, \& to => \*(AqMySQL\*(Aq, \& filters => [ \& Globals => { \& fields => [ \& { \& name => \*(Aqmodified\*(Aq \& data_type => \*(AqTIMESTAMP\*(Aq \& } \& ], \& indices => [ \& { \& fields => \*(Aqmodifed\*(Aq, \& }, \& ] \& constraints => [ \& { \& } \& ] \& }, \& ], \& ) || die "SQLFairy error : ".SQL::Translator\->error; \& my $sql = $sqlt\->translate || die "SQLFairy error : ".$sqlt\->error; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Adds global fields, indices and constraints to all tables in the schema. The globals to add can either be defined in the filter args or using a _GLOBAL_ table (see below). .PP If a table already contains a field with the same name as a global then it is skipped for that table. .SS "The _GLOBAL_ Table" .IX Subsection "The _GLOBAL_ Table" An alternative to using the args is to add a table called \f(CW\*(C`_GLOBAL_\*(C'\fR to the schema and then just use the filter. Any fields and indices defined on this table will be added to all the tables in the schema and the _GLOBAL_ table removed. .PP The name of the global can be changed using a \f(CW\*(C`global_table\*(C'\fR arg to the filter. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\f(CWperl(1)\fR, SQL::Translator .SH BUGS .IX Header "BUGS" Will generate duplicate indices if an index already exists on a table the same as one added globally. .PP Will generate duplicate constraints if a constraint already exists on a table the same as one added globally. .SH TODO .IX Header "TODO" Some extra data values that can be used to control the global addition. e.g. \&'skip_global'. .SH AUTHOR .IX Header "AUTHOR" Mark Addison