Skip to content

Instantly share code, notes, and snippets.

@racke
Last active November 24, 2021 05:18
Show Gist options
  • Save racke/48024bf1195bea8a7d90 to your computer and use it in GitHub Desktop.
Save racke/48024bf1195bea8a7d90 to your computer and use it in GitHub Desktop.
DH scripts
#!/usr/bin/env perl
use warnings;
use strict;
use Dancer qw/:script/;
use Dancer::Plugin::DBIC;
use DBIx::Class::DeploymentHandler;
my $schema = schema;
my $dh = DBIx::Class::DeploymentHandler->new(
{
schema => $schema,
databases => 'MySQL',
sql_translator_args => { add_drop_table => 0 }
}
);
$dh->prepare_deploy;
$dh->prepare_upgrade(
{
from_version => $dh->database_version,
to_version => $dh->schema_version
}
);
#!/usr/bin/env perl
use warnings;
use strict;
use Dancer qw/:script/;
use Dancer::Plugin::DBIC;
use DBIx::Class::DeploymentHandler;
use CalevoMobile::Schema;
# we need to be less strict using DH since the database contains things
# such as zero dates which break upgrades in strict mode
my $connect_info = schema->storage->connect_info;
delete $connect_info->[0]->{on_connect_do};
my $schema = CalevoMobile::Schema->connect(@$connect_info);
my $dh = DBIx::Class::DeploymentHandler->new(
{
schema => $schema,
databases => 'MySQL',
sql_translator_args => { add_drop_table => 0 }
}
);
$dh->upgrade(
{
from_version => $dh->database_version,
to_version => $dh->schema_version
}
);
@Pvpahh
Copy link

Pvpahh commented Nov 24, 2021

skid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment