--- /dev/null
+package DBIx::Class::DeploymentHandler::Deprecated;
+
+use Moose;
+use Moose::Util 'apply_all_roles';
+
+extends 'DBIx::Class::DeploymentHandler::Dad';
+with 'DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedSqltDeployMethod',
+ 'DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedVersionStorage';
+
+sub BUILD {
+ my $self = shift;
+
+ if ($self->schema->can('ordered_versions')) {
+ apply_all_roles(
+ $self,
+ 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions'
+ );
+ } else {
+ apply_all_roles(
+ $self,
+ 'DBIx::Class::DeploymentHandler::WithExplicitVersions'
+ );
+ }
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedSqltDeployMethod;
+use Moose::Role;
+
+use DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated;
+
+has deploy_method => (
+ does => 'DBIx::Class::DeploymentHandler::HandlesDeploy',
+ is => 'ro',
+ lazy_build => 1,
+ handles => 'DBIx::Class::DeploymentHandler::HandlesDeploy',
+);
+
+sub _build_deploy_method {
+ my $self = shift;
+ DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator::Deprecated->new({
+ schema => $self->schema,
+ databases => $self->databases,
+ upgrade_directory => $self->upgrade_directory,
+ sqltargs => $self->sqltargs,
+ });
+}
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::Deprecated::WithDeprecatedVersionStorage;
+use Moose::Role;
+
+use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated;
+
+has version_storage => (
+ does => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
+ is => 'ro',
+ lazy_build => 1,
+ handles => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
+);
+
+sub _build_version_storage {
+ DBIx::Class::DeploymentHandler::VersionStorage::Deprecated
+ ->new({ schema => $_[0]->schema });
+}
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::VersionStorage::Standard;
+use Moose;
+use Method::Signatures::Simple;
+
+has schema => (
+ isa => 'DBIx::Class::Schema',
+ is => 'ro',
+ required => 1,
+);
+
+has version_rs => (
+ isa => 'DBIx::Class::ResultSet',
+ is => 'ro',
+ lazy_build => 1,
+ handles => [qw( database_version version_storage_is_installed )],
+);
+
+with 'DBIx::Class::DeploymentHandler::HandlesVersionStorage';
+
+sub _build_version_rs {
+ $_[0]->schema->register_class(
+ dbix_class_schema_versions =>
+ 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult'
+ );
+ $_[0]->schema->resultset('dbix_class_schema_versions')
+}
+
+sub add_database_version {
+ # deprecated doesn't support ddl or upgrade_ddl
+ $_[0]->version_rs->create({ version => $_[1]->{version} })
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::Component;
+
+use strict;
+use warnings;
+
+use Carp 'carp';
+use DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult;
+
+sub attach_version_storage {
+ $_[0]->register_class(
+ dbix_class_schema_versions => 'DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult'
+ );
+}
+
+sub connection {
+ my $self = shift;
+ $self->next::method(@_);
+
+ $self->attach_version_storage;
+
+ my $args = $_[3] || {};
+
+ unless ( $args->{ignore_version} || $ENV{DBIC_NO_VERSION_CHECK}) {
+ my $versions = $self->resultset('dbix_class_schema_versions');
+
+ if (!$versions->version_storage_is_installed) {
+ carp "Your DB is currently unversioned. Please call upgrade on your schema to sync the DB.\n";
+ } elsif ($versions->database_version ne $self->schema_version) {
+ carp 'Versions out of sync. This is ' . $self->schema_version .
+ ', your database contains version ' . $versions->database_version . ", please call upgrade on your Schema.\n";
+ }
+ }
+
+ return $self;
+}
+
+1;
--- /dev/null
+package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResult;
+
+use strict;
+use warnings;
+
+use parent 'DBIx::Class::Core';
+
+__PACKAGE__->table('dbix_class_deploymenthandler_versions');
+
+__PACKAGE__->add_columns (
+ version => {
+ data_type => 'VARCHAR',
+ is_nullable => 0,
+ size => '10'
+ },
+ installed => {
+ data_type => 'VARCHAR',
+ is_nullable => 0,
+ size => '20'
+ },
+);
+
+__PACKAGE__->set_primary_key('version');
+
+__PACKAGE__->resultset_class('DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet');
+
+1;
+
--- /dev/null
+package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet;
+
+use strict;
+use warnings;
+
+use parent 'DBIx::Class::ResultSet';
+
+use Try::Tiny;
+use Time::HiRes 'gettimeofday';
+
+sub version_storage_is_installed {
+ my $self = shift;
+ try { $self->next; 1 } catch { undef }
+}
+
+sub database_version {
+ my $self = shift;
+ $self->search(undef, {
+ order_by => { -desc => 'installed' },
+ rows => 1
+ })->get_column('version')->next;
+}
+
+# this is why it's deprecated guys... Serially.
+sub create {
+ my $self = shift;
+
+ my @tm = gettimeofday();
+ my @dt = gmtime ($tm[0]);
+
+ $self->next::method({
+ version => $version,
+ installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
+ $dt[5] + 1900,
+ $dt[4] + 1,
+ $dt[3],
+ $dt[2],
+ $dt[1],
+ $dt[0],
+ $tm[1] / 1000, # convert to millisecs, format as up/down rounded int above
+ ),
+ });
+}
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+#!perl
+
+use Test::More;
+
+use_ok 'DBIx::Class::DeploymentHandler::Deprecated';
+
+done_testing;
+__END__
+
+vim: ts=2 sw=2 expandtab