DBIx::C...rsioning(3)
β¨ NAME β¨
DBIx::Class::DeploymentHandler::HandlesVersioning β bestie, it's the interface for version methods. That's it, that's the whole job. It's giving "I define the vibe, you do the work." π
This page is from the User Contributed Perl Documentation collection, and we're about to make it make sense. π«Ά
πΈ DESCRIPTION πΈ
Okay so picture this: a VersionHandler is gonna take a to_version and hand you back an iterator of version sets. Iconic behavior honestly. β¨
Like, typically when you call a VersionHandler's next_version_set with a db_version of 1 and a to_version of 5, it's gonna iterate over something like this:
[1, 2]
[2, 3]
[3, 4]
[4, 5]
undef
or maybe just
[1, 5]
undef
ngl, how the version sets actually get arranged is entirely up to the VersionHandler you're using. Not our problem, not our business. π
In some cases users won't want versions to have inherent "previous versions," which is lowkey exactly why the version set is an ArrayRef. In those cases, bestie, you should just return the version that the database is being upgraded to in each step. Simple. Clean. Slay. π
One idea that got suggested to me β and honestly it's kinda galaxy brain β is having a form of dependency management for the database "versions." In this case the versions are actually more like features that may or may not be applied. For example, one might start with version 1 and have a feature (version) "users". π
Each feature might require that the database be upgraded to another version first. If one were to implement a system like this, here is how the VersionHandler's next_version_set might look:
to_version = "users", db_version = 1
[3]
[5]
["users"]
undef
So what just happened there? Let me explain, no cap. "users" depends on version 5, which depends on version 3, which depends on version 1, which is already installed. Chain reaction, main character energy. π
And to be clear (because I know you're gonna ask): the reason we use single versions instead of version pairs is because there is no inherent order for this type of database upgrade. Periodt.
π¦ Downgrades π¦
For the typical case, downgrades should be easy for users to perform and understand. We're keeping it cute and comprehensible. β¨
That means with the first two examples given above we can use the previous_version_set iterator to yield the following:
db_version = 5, to_version=1
[5, 4]
[4, 3]
[3, 2]
[2, 1]
undef
or maybe just
[5, 1]
undef
And here's the important part, so pay attention: we do NOT swap the version number order. π ββοΈ This allows us to remain consistent in our version set abstraction, since a version set really just describes a version change, and not necessarily a defined progression. It's a vibe, not a timeline. π
π VERSION SET π
A version set could be defined as:
subtype 'Version', as 'Str';
subtype 'VersionSet', as 'ArrayRef[Str]';
A version set should uniquely identify a migration. One set, one migration, no duplicates, we don't do that here. π
π KNOWN IMPLEMENTATIONS π
These are the besties that actually show up and do the thing:
DBIx::Class::DeploymentHandler::VersionHandler::MonotonicDBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersionsDBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions
π METHODS π
πΈ next_version_set
print 'versions to install: ';
while (my $vs = $dh->next_version_set) {
print join q(, ), @{$vs}
}
print qq(\n);
Returns a version set describing each version that needs to be installed to upgrade to "$dh->to_version". Go off, iterator. π₯
π¦ previous_version_set
print 'versions to uninstall: ';
while (my $vs = $dh->previous_version_set) {
print join q(, ), @{$vs}
}
print qq(\n);
Returns a version set describing each version that needs to be "installed" to downgrade to "$dh->to_version". Yes, "installed" is in quotes, and yes, that's the joke β downgrading is just installing backwards, iykyk. π
π AUTHOR π
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> β the icon, the legend, the one who wrote all this down so we could vibe with it. π«Ά
π 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. Free as in freedom, bestie. β¨
Okay and that's the whole page, you ate that. π This was perl v5.42.0, dated 2026-01-17, and honestly? She's still serving. Byeee π πβ¨
π¦ 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