1 package DBIx::Class::DeploymentHandler::HandlesVersioning;
4 # ABSTRACT: Interface for version methods
6 requires 'next_version_set';
7 requires 'previous_version_set';
11 # vim: ts=2 sw=2 expandtab
17 Typically a VersionHandler will take a C<to_version> and yeild an iterator of
18 L<version sets|/VERSION SET>.
20 Typically a call to a VersionHandler's L</next_version_set> with a C<db_version>
21 of 1 and a C<to_version> of 5 will iterate over something like the following:
34 Really how the L<version sets|/VERSION SET> are arranged is up to the
35 VersionHandler being used.
37 In some cases users will not want versions to have inherent "previous
38 versions," which is why the version set is an C<ArrayRef>. In those cases the
39 user should opt to returning merely the version that the database is being
40 upgraded to in each step.
42 One idea that has been suggested to me has been to have a form of dependency
43 management of the database "versions." In this case the versions are actually
44 more like features that may or may not be applied. For example, one might
45 start with version 1 and have a feature (version) C<users>.
47 Each feature might require that the database be upgraded to another version
48 first. If one were to implement a system like this, here is how the
49 VersionHandler's L</next_version_set> might look.
51 to_version = "users", db_version = 1
57 So what just happened there is that C<users> depends on version 5, which depends
58 on version 3, which depends on version 1, which is already installed. To be
59 clear, the reason we use single versions instead of version pairs is because
60 there is no inherent order for this type of database upgraded.
64 For the typical case downgrades should be easy for users to perform and
65 understand. That means that with the first two examples given above we can use
66 the L</previous_version_set> iterator to yeild the following:
69 db_version = 5, to_version=1
81 Note that we do not swap the version number order. This allows us to remain
82 consistent in our version set abstraction, since a version set really just
83 describes a version change, and not necesarily a defined progression.
85 =method next_version_set
87 print 'versions to install: ';
88 while (my $vs = $dh->next_version_set) {
89 print join q(, ), @{$vs}
93 Return a L<version set|/VERSION SET> describing each version that needs to be
94 installed to upgrade to C<< $dh->to_version >>.
96 =method previous_version_set
98 print 'versions to uninstall: ';
99 while (my $vs = $dh->previous_version_set) {
100 print join q(, ), @{$vs}
104 Return a L<version set|/VERSION SET> describing each version that needs to be
105 "installed" to downgrade to C<< $dh->to_version >>.
109 A version set could be defined as:
111 subtype 'Version', as 'Str';
112 subtype 'VersionSet', as 'ArrayRef[Str]';
114 A version set should uniquely identify a migration.
116 =head1 KNOWN IMPLEMENTATIONS
122 L<DBIx::Class::DeploymentHandler::VersionHandler::Monotonic>
126 L<DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions>
130 L<DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions>