Last active
November 24, 2021 05:18
-
-
Save racke/48024bf1195bea8a7d90 to your computer and use it in GitHub Desktop.
DH scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
skid