From 9ee8b3f2973af26040c1c03e1824f6680b5497a6 Mon Sep 17 00:00:00 2001 From: Todd Lyons Date: Tue, 22 Oct 2013 07:19:34 -0700 Subject: [PATCH] Change approve script to use schema function --- scripts/{set_system_status.pl => approve_system.pl} | 13 ++++++------- scripts/delete_unlisted_branches.pl | 7 ++++++- 2 files changed, 12 insertions(+), 8 deletions(-) rename scripts/{set_system_status.pl => approve_system.pl} (81%) diff --git a/scripts/set_system_status.pl b/scripts/approve_system.pl similarity index 81% rename from scripts/set_system_status.pl rename to scripts/approve_system.pl index 7912135..7a36db7 100755 --- a/scripts/set_system_status.pl +++ b/scripts/approve_system.pl @@ -5,7 +5,7 @@ use warnings; use DBI; use Data::Dumper; -die "Must pass sysname and status\n" unless scalar @ARGV == 2; +die "Must pass current sysname and new sysname\n" unless scalar @ARGV == 2; use vars qw($dbhost $dbname $dbuser $dbpass $dbport ); @@ -22,12 +22,11 @@ my $db = DBI->connect($dsn,$dbuser,$dbpass); die $DBI::errstr unless $db; -my $sth_up = $db->prepare(q[ - UPDATE buildsystems AS b - SET status = ? - WHERE name = ? - ]); -$sth_up->execute($ARGV[1],$ARGV[0]); +#my $sth_up = $db->prepare(q[ +# SELECT approve(?, ?) +# ]); +#$sth_up->execute(@ARGV); +$db->do('SELECT approve(?, ?)', undef, @ARGV); my $sth = $db->prepare(q[ SELECT name, status, operating_system, os_version, sys_owner, owner_email diff --git a/scripts/delete_unlisted_branches.pl b/scripts/delete_unlisted_branches.pl index 03df796..fd37fd2 100755 --- a/scripts/delete_unlisted_branches.pl +++ b/scripts/delete_unlisted_branches.pl @@ -47,7 +47,11 @@ my $del_dash_sth = $db->prepare(q[ WHERE sysname = ? AND branch = ? ]); - +my $del_snap_sth = $db->prepare(q[ + DELETE FROM latest_snapshot + WHERE sysname = ? + AND branch = ? + ]); while (my $row = $sth->fetchrow_hashref) { my $sysname = $row->{sysname}; @@ -58,6 +62,7 @@ while (my $row = $sth->fetchrow_hashref) print "** Delete branch $branch\n"; $del_sth->execute($sysname,$branch); $del_dash_sth->execute($sysname,$branch); + $del_snap_sth->execute($sysname,$branch); } } $db->disconnect(); -- 2.30.2