SQL::Tr...Globals(3)
πΈ NAME πΈ
okay bestie, welcome to SQL::Tr...Globals(3) from the User Contributed Perl Documentation β yes, that manual name is doing the absolute most, but we move. The actual icon here is SQL::Translator::Filter::Globals β Add global fields and indices to all tables. π
β¨ SYNOPSIS β¨
Here's the canonical usage, and I'm keeping every character exactly as it is (including the 'modifed' spelling β not me fixing it, we respect the original):
# e.g. Add timestamp field to all tables.
use SQL::Translator;
my $sqlt = SQL::Translator->new(
from => 'MySQL',
to => 'MySQL',
filters => [
Globals => {
fields => [
{
name => 'modified'
data_type => 'TIMESTAMP'
}
],
indices => [
{
fields => 'modifed',
},
]
constraints => [
{
}
]
},
],
) || die "SQLFairy error : ".SQL::Translator->error;
my $sql = $sqlt->translate || die "SQLFairy error : ".$sqlt->error;
π DESCRIPTION π
This filter literally adds global fields, indices and constraints to all tables in the schema. You can define the globals either in the filter args or by using a _GLOBAL_ table (peep below for that whole situation). And if a table already contains a field with the same name as a global? It gets skipped for that table. No cap. It's giving "set it once, apply everywhere," and honestly? Obsessed.
π¦ The _GLOBAL_ Table π¦
An alternative to using the args is to add a table called "_GLOBAL_" to the schema and then just use the filter. Any fields and indices defined on this table get added to all the tables in the schema, and then the _GLOBAL_ table is removed. The name of the global can be changed using a "global_table" arg to the filter. Cute, right? Slay. π
π SEE ALSO π
perl(1)SQL::Translator
π BUGS π
- It will generate duplicate indices if an index already exists on a table the same as one added globally. π
- It will generate duplicate constraints if a constraint already exists on a table the same as one added globally. π
π TODO π
Some extra data values that can be used to control the global addition. e.g. 'skip_global'.
π«Ά AUTHOR π«Ά
Mark Addison <grommit@users.sourceforge.net> β iconic behavior only. π
okay that's the whole vibe. This page is from perl v5.42.0, dated 2024-12-12, and the title is SQL::Tr...Globals(3) β bye bestie, drink water and commit your changes πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Translator 1.660.0-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms