#!/usr/bin/env perl # One-time recovery/bootstrap tool: marks an existing database as already # being at a given schema version, without running any deploy DDL against it # -- it only creates the version-tracking table and records one row. Use # this to bring an untracked-but-populated database (one that predates # DeploymentHandler, or was just restored from a backup) under migration # tracking before bin/migrate_db.pl can run against it. # # bin/migrate_db.pl deliberately refuses to run install() by itself against # a database that has tables but no version-tracking table -- that's not a # fresh database, and guessing wrong would drop and recreate every table. # See Lacuna::DB::Migrate::stamp. # # Usage: perl bin/stamp_db_version.pl use 5.010; use strict; use lib '/home/lacuna/server/lib'; use Lacuna::DB::Migrate; my ($version) = @ARGV; die "Usage: $0 \n" unless defined $version && length $version; say "About to stamp this database as schema version $version, WITHOUT changing"; say "any table in it. Only do this if you've personally confirmed the database's"; say "current schema actually matches that version -- if it doesn't, later"; say "migrations will be skipped and the schema will silently drift from the code."; say ''; print "Type the version number again to confirm: "; my $confirm = ; chomp $confirm if defined $confirm; die "Confirmation didn't match, aborting.\n" unless defined $confirm && $confirm eq $version; my $result = Lacuna::DB::Migrate::stamp($version); say "Database stamped at version $result. It's now safe to run bin/migrate_db.pl.";