From: Rogan Hamby Date: Thu, 21 Jun 2018 17:09:36 +0000 (-0400) Subject: Merge branch 'master' of git.esilibrary.com:migration-tools X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=511e4c4bccec3d90a5b89ae293aee903d40d6405;hp=ff15dd2f606804702b1fcb6f9c7d2e06c1ca6760 Merge branch 'master' of git.esilibrary.com:migration-tools --- diff --git a/mig-bin/mig-env b/mig-bin/mig-env index bcfe148..ed066b1 100755 --- a/mig-bin/mig-env +++ b/mig-bin/mig-env @@ -13,6 +13,8 @@ B B [migration_schema] +B [orig_migration_schema] [new_migration_schema] + B B @@ -81,6 +83,12 @@ This command will show the contents of the corresponding ~/.mig/.env script, or, if no schema is specified, then it will list pertinent variables in the current environment if they exist. +=item B [orig schema] [new schema] + +This command will create a "shallow" clone of the orig schema, in that it will +share database credentials as well as git and data directories, but will have a +separate schema name. + =item B This command will list migration schemas found in ~/.mig @@ -123,6 +131,12 @@ switch($ARGV[0]) { pod2usage(-verbose => 1) if ! $ARGV[1]; mig_env_create(); } + case "clone" { + pod2usage(-verbose => 1) if ! $ARGV[2]; + $migration_schema = $ARGV[2] || ''; + $filename = "$HOME/.mig/$migration_schema.env"; + mig_env_clone(); + } case "use" { pod2usage(-verbose => 1) if ! $ARGV[1]; if (-e $filename) { @@ -243,3 +257,12 @@ sub mig_env_create { close FILE; } +sub mig_env_clone { + my $orig_migration_schema = $ARGV[1] || ''; + my $orig_filename = "$HOME/.mig/$orig_migration_schema.env"; + `cp $orig_filename $filename`; + `sed -i 's/export PGOPTIONS=.*/export PGOPTIONS='"'"'-c search_path=$migration_schema,public,evergreen'"'"'/' $filename`; + `sed -i 's/export MIGENVPROMPT=.*/export MIGENVPROMPT=$migration_schema/' $filename`; + `sed -i 's/export MIGSCHEMA=.*/export MIGSCHEMA=$migration_schema/' $filename`; +} + diff --git a/sql/base/base.sql b/sql/base/base.sql index e7096d4..3340482 100644 --- a/sql/base/base.sql +++ b/sql/base/base.sql @@ -2696,6 +2696,22 @@ CREATE OR REPLACE FUNCTION migration_tools.duplicate_templates (INTEGER, INTEGER END; $$ LANGUAGE PLPGSQL STRICT VOLATILE; +CREATE OR REPLACE FUNCTION migration_tools.reset_event (BIGINT) RETURNS VOID AS $$ + UPDATE + action_trigger.event + SET + start_time = NULL + ,update_time = NULL + ,complete_time = NULL + ,update_process = NULL + ,state = 'pending' + ,template_output = NULL + ,error_output = NULL + ,async_output = NULL + WHERE + id = $1; +$$ LANGUAGE SQL; + CREATE OR REPLACE FUNCTION migration_tools.get_marc_leader (TEXT) RETURNS TEXT AS $$ my ($marcxml) = @_;