DBIx::C...Helpers(3)
π NAME π
DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers β bestie, it's CodeRef Transforms for common use-cases in DBICDH Migrations. That's the whole vibe. π
β¨ SYNOPSIS β¨
use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers
'schema_from_schema_loader';
schema_from_schema_loader({ naming => 'v4' }, sub {
my ($schema, $version_set) = @_;
...
});
π¦ DESCRIPTION π¦
Okay so, this package is literally a set of coderef transforms for the common use-cases you hit in migrations. The subroutines are just helpers for creating coderefs that will work for "PERL SCRIPTS" in DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator β but like, with some argument other than the current schema that you as a user might prefer. It's giving "I gotchu, here's the thing you actually wanted." π
πΈ EXPORTED SUBROUTINES πΈ
dbh($coderef)
dbh(sub {
my ($dbh, $version_set) = @_;
...
});
For those times when you almost exclusively need access to "the bare metal". π₯ It simply gives you the correct database handle and the expected version set. No cap, that's it.
schema_from_schema_loader($sl_opts, $coderef)
schema_from_schema_loader({ naming => 'v4' }, sub {
my ($schema, $version_set) = @_;
...
});
Any time you write a perl migration script that uses a DBIx::Class::Schema you should probably use this one, fr fr. Otherwise you'll run into problems if you remove a column from your schema yet still populate to it in an older population script. π Not the vibe.
Heads up bestie:$sl_optsrequires that you specify something for thenamingoption. Don't skip it. π
π CUSTOM SCRIPT HELPERS π
If you find that in your scripts you need to always pass the same arguments to your script helpers, you may want to define a custom set of script helpers. The author isn't sure there's a better way than just using Perl and other modules that are already installed when you install DBIx::Class::DeploymentHandler. π€·ββοΈ
The following is a pattern that will get you started; if anyone has ideas on how to make this even easier, let him know. π
package MyApp::DBICDH::ScriptHelpers;
use strict;
use warnings;
use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::ScriptHelpers
dbh => { -as => '_old_dbh' },
schema_from_schema_loader => { -as => '_old_sfsl' };
use Sub::Exporter::Progressive -setup => {
exports => [qw(dbh schema_from_schema_loader)],
};
sub dbh {
my $coderef = shift;
_old_dbh(sub {
my ($dbh) = @_;
$dbh->do(q(SET search_path TO 'myapp_db'));
$coderef->(@_);
});
}
sub schema_from_schema_loader {
my ($config, $coderef) = @_;
$config->{naming} ||= 'v7';
_old_sfsl(sub {
my ($schema) = @_;
$schema->storage->dbh->do(q(SET search_path TO 'myapp_db'));
$coderef->(@_);
});
}
The above will default the naming to "v7" when using schema_from_schema_loader. And in both cases it will set the schema for PostgreSQL. π
Warning though: of course if you do that you will not be able to switch to MySQL or something else, so the author recommends looking into his DBIx::Introspector to only do that for the database in question. π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2025 by Arthur Axel "fREW" Schmidt. β
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π¦
okay that's the whole page bestie, tysm for reading, you absolutely ate π β¨
this served up by perl v5.42.0, dated 2026-01-17 β mwah, go slay your migrations ππ
π¦ where this page comes from
- fedora 44: perl-DBIx-Class-DeploymentHandler 0.002235-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms