From 3232c5b7b8b109b695027229724b7216472c09e2 Mon Sep 17 00:00:00 2001 From: John Brestelli Date: Tue, 19 May 2026 11:24:55 -0400 Subject: [PATCH] Add undoEdaStudy.pl script to remove a single EDA study by extDbRlsSpec Delegates to InstallEdaStudyFromArtifacts::uninstallDataFromExternalDatabase(), which drops artifact tables/views and cleans up eda.entitytypegraph, eda.studyexternaldatabaserelease, and eda.study rows. Co-Authored-By: Claude Sonnet 4.6 --- Load/bin/undoEdaStudy.pl | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Load/bin/undoEdaStudy.pl diff --git a/Load/bin/undoEdaStudy.pl b/Load/bin/undoEdaStudy.pl new file mode 100644 index 000000000..ede37bdca --- /dev/null +++ b/Load/bin/undoEdaStudy.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use lib "$ENV{GUS_HOME}/lib/perl"; + +use Getopt::Long; +use GUS::Supported::GusConfig; +use ApiCommonData::Load::InstallEdaStudyFromArtifacts; + +my (@extDbRlsSpec, $gusConfigFile, $help); + +&GetOptions( + "extDbRlsSpec=s" => \@extDbRlsSpec, + "gusConfigFile=s" => \$gusConfigFile, + "help|h" => \$help, +); + +&usage() if $help || scalar @extDbRlsSpec == 0 || !$gusConfigFile; + +die "gus.config file '$gusConfigFile' does not exist\n" unless -e $gusConfigFile; + +my $gusconfig = GUS::Supported::GusConfig->new($gusConfigFile); + +my ($host, $port, $dbname); +my $dsn = $gusconfig->getDbiDsn(); +my ($dbi, $platform, $dbnameFull) = split(':', $dsn); + +foreach my $pair (split(";", $dbnameFull)) { + my ($key, $value) = split("=", $pair); + if (lc $key eq 'port') { $port = $value } + if (lc $key eq 'host') { $host = $value } + if (lc $key eq 'dbname') { $dbname = $value } +} +$port //= 5432; + +my $login = $gusconfig->getDatabaseLogin(); +my $password = $gusconfig->getDatabasePassword(); + +my $installer = ApiCommonData::Load::InstallEdaStudyFromArtifacts->new({ + DB_HOST => $host, + DB_PORT => $port, + DB_NAME => $dbname, + DB_PLATFORM => 'Postgres', + DB_USER => $login, + DB_PASS => $password, + DB_SCHEMA => 'EDA', + DATA_FILES => 'NA', + INPUT_DIR => 'NA', + EXTERNAL_DATABASE_RLS_SPECS => \@extDbRlsSpec, +}); + +$installer->uninstallDataFromExternalDatabase(); + + +sub usage { + print STDERR "Usage: undoEdaStudy.pl --extDbRlsSpec [--extDbRlsSpec ...] --gusConfigFile \n"; + print STDERR "\n"; + print STDERR " --extDbRlsSpec External database release spec (format: 'DbName|Version'). May be specified multiple times.\n"; + print STDERR " --gusConfigFile Path to gus.config (required)\n"; + exit 1; +}