SQL::Tr...::Class(3)
π SQL::Tr...::Class(3) π
okay bestie, this page is straight from the User Contributed Perl Documentation shelf, and it's about SQL::Translator::Parser::DBIx::Class β the parser that turns your DBIx::Class schema into a SQL::Translator schema. it's giving database-deploy main character energy. β¨
πΈ NAME πΈ
SQL::Translator::Parser::DBIx::Class β create a SQL::Translator schema from a DBIx::Class::Schema instance. no cap, that's the whole vibe. π
π SYNOPSIS π
Two routes, bestie: the DBIx::Class way, or standalone. both iconic.
## Via DBIx::Class
use MyApp::Schema;
my $schema = MyApp::Schema->connect("dbi:SQLite:something.db");
$schema->create_ddl_dir();
## or
$schema->deploy();
## Standalone
use MyApp::Schema;
use SQL::Translator;
my $schema = MyApp::Schema->connect;
my $trans = SQL::Translator->new (
parser => 'SQL::Translator::Parser::DBIx::Class',
parser_args => {
dbic_schema => $schema,
add_fk_index => 0,
sources => [qw/
Artist
CD
/],
},
producer => 'SQLite',
) or die SQL::Translator->error;
my $out = $trans->translate() or die $trans->error;
π¦ DESCRIPTION π¦
This class requires SQL::Translator installed to work. full stop. π
SQL::Translator::Parser::DBIx::Class reads a DBIx::Class schema, interrogates the columns, and stuffs it all in an $sqlt_schema object. it's literally collecting the schema lore and packing it up. π
Its primary use is in deploying database layouts described as a set of DBIx::Class classes, to a database. to do this, see "deploy" in DBIx::Class::Schema. π
This can also be achieved by having DBIx::Class export the schema as a set of SQL files ready for import into your database, or passed to other machines that need to have your application installed but don't have SQL::Translator installed. to do this, see "create_ddl_dir" in DBIx::Class::Schema. π
β¨ PARSER OPTIONS β¨
π« dbic_schema π«
The DBIx::Class schema (either an instance or a class name) to be parsed. this argument is in fact optional β instead one can supply it later at translation time as an argument to "translate" in SQL::Translator. in other words, both of these invocations are valid and will produce conceptually identical output:
my $yaml = SQL::Translator->new(
parser => 'SQL::Translator::Parser::DBIx::Class',
parser_args => {
dbic_schema => $schema,
},
producer => 'SQL::Translator::Producer::YAML',
)->translate;
my $yaml = SQL::Translator->new(
parser => 'SQL::Translator::Parser::DBIx::Class',
producer => 'SQL::Translator::Producer::YAML',
)->translate(data => $schema);
π add_fk_index π
Create an index for each foreign key. enabled by default, because having indexed foreign key columns is normally the sensible thing to do. it's giving responsible database citizen. π«Ά
π sources π
Arguments: \@class_names
Limit the amount of parsed sources by supplying an explicit list of source names. periodt. π
π SEE ALSO π
SQL::TranslatorDBIx::Class::Schema
π«Ά FURTHER QUESTIONS? π«Ά
Check the list of additional DBIC resources. iykyk. π
π COPYRIGHT AND LICENSE π
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library. π¦
xoxo bestie, that's the whole page π β from perl v5.42.0, dated 2025-01-22.
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBIx-Class 0.082844-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms