Something went wrong. Try again.
Perl game server for TLE Community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445#!/usr/bin/env perl
# Generates the deploy/upgrade SQL that bin/migrate_db.pl and# bin/setup/init_lacuna.pl apply, from the current Result classes, under# var/ddl/. Run this after bumping $Lacuna::DB::VERSION in lib/Lacuna/DB.pm,# then commit whatever lands under var/ddl/ alongside the Result class change.## force_overwrite is on: safe to re-run while iterating on a not-yet-committed# schema change, but don't re-run it for a version that's already committed# and possibly deployed -- bump the version and prepare a new upgrade step# instead.## Usage:# perl bin/prepare_db_migration.pl # (re)generate the current version's install DDL# perl bin/prepare_db_migration.pl <from> <to> # also generate an upgrade diff between two versions
use 5.010;use strict;use lib '/home/lacuna/server/lib';use DBIx::Class::DeploymentHandler;use Lacuna;
my ($from_version, $to_version) = @ARGV;die "Usage: $0 [<from_version> <to_version>]\n" if (defined $from_version) != (defined $to_version);
my $dh = DBIx::Class::DeploymentHandler->new({ schema => Lacuna->db, script_directory => '/home/lacuna/server/var/ddl', databases => 'MySQL', force_overwrite => 1, # Deploy/install DDL drops each table first, so bin/setup/init_lacuna.pl # can redeploy from scratch against a dev database that still has tables # left over from a previous run. sql_translator_args => { add_drop_table => 1 },});
$dh->prepare_install;say 'Wrote install DDL for version ' . $dh->schema_version . ' to var/ddl/.';
if (defined $from_version) { $dh->prepare_upgrade({ from_version => $from_version, to_version => $to_version }); say "Wrote upgrade DDL for $from_version -> $to_version to var/ddl/.";}