forked from mozilla-services/socorro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mozilla-services#649 from jberkus/master
13.0 DB migration scripts.
- Loading branch information
Showing
5 changed files
with
148 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#.# Database Updates | ||
==================== | ||
|
||
This batch makes the following database changes: | ||
|
||
bug 764468 | ||
replace existing processor ganglia views with a new | ||
view based on server_status | ||
|
||
bug 763552 | ||
make add_new_releases() better for ftpscraper | ||
|
||
... | ||
|
||
The above changes should take only a few minutes to deploy. | ||
This upgrade does not require a downtime. This upgrade will | ||
break ganglia monitoring which is already displaying incorrect | ||
results. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
\set ON_ERROR_STOP 1 | ||
|
||
DROP FUNCTION IF EXISTS add_new_release ( citext, citext, citext, | ||
numeric, citext, integer, text, boolean ); | ||
|
||
CREATE OR REPLACE FUNCTION add_new_release ( | ||
product citext, | ||
version citext, | ||
release_channel citext, | ||
build_id numeric, | ||
platform citext, | ||
beta_number integer default NULL, | ||
repository text default 'release', | ||
update_products boolean default false, | ||
ignore_duplicates boolean default false | ||
) | ||
RETURNS boolean | ||
LANGUAGE plpgsql | ||
AS $f$ | ||
BEGIN | ||
-- adds a new release to the releases_raw table | ||
-- to be picked up by update_products later | ||
-- does some light format validation | ||
|
||
-- check for NULLs, blanks | ||
IF NOT ( nonzero_string(product) AND nonzero_string(version) | ||
AND nonzero_string(release_channel) and nonzero_string(platform) | ||
AND build_id IS NOT NULL ) THEN | ||
RAISE EXCEPTION 'product, version, release_channel, platform and build ID are all required'; | ||
END IF; | ||
|
||
--validations | ||
-- validate product | ||
PERFORM validate_lookup('products','product_name',product,'product'); | ||
--validate channel | ||
PERFORM validate_lookup('release_channels','release_channel',release_channel,'release channel'); | ||
--validate build | ||
IF NOT ( build_date(build_id) BETWEEN '2005-01-01' | ||
AND (current_date + INTERVAL '1 month') ) THEN | ||
RAISE EXCEPTION 'invalid buildid'; | ||
END IF; | ||
|
||
--add row | ||
--duplicate check will occur in the EXECEPTION section | ||
INSERT INTO releases_raw ( | ||
product_name, version, platform, build_id, | ||
build_type, beta_number, repository ) | ||
VALUES ( product, version, platform, build_id, | ||
release_channel, beta_number, repository ); | ||
|
||
--call update_products, if desired | ||
IF update_products THEN | ||
PERFORM update_product_versions(); | ||
END IF; | ||
|
||
--return | ||
RETURN TRUE; | ||
|
||
--exception clause, mainly catches duplicate rows. | ||
EXCEPTION | ||
WHEN UNIQUE_VIOLATION THEN | ||
IF ignore_duplicates THEN | ||
RETURN FALSE; | ||
ELSE | ||
RAISE EXCEPTION 'the release you have entered is already present in he database'; | ||
END;$f$; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
\set ON_ERROR_STOP 1 | ||
|
||
DROP VIEW IF EXISTS jobs_in_queue; | ||
|
||
DROP VIEW IF EXISTS processor_count; | ||
|
||
CREATE OR REPLACE VIEW current_server_status AS | ||
SELECT | ||
date_recently_completed, | ||
date_oldest_job_queued, | ||
extract('epoch' from (date_created - date_oldest_job_queued)) as oldest_job_age, | ||
avg_process_sec, | ||
avg_wait_sec, | ||
waiting_job_count, | ||
processors_count, | ||
date_created | ||
FROM server_status | ||
ORDER BY date_created DESC LIMIT 1; | ||
|
||
ALTER VIEW current_server_status OWNER TO breakpad_rw; | ||
|
||
GRANT SELECT on current_server_status TO monitoring; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
#please see README | ||
|
||
set -e | ||
|
||
CURDIR=$(dirname $0) | ||
DBNAME=$1 | ||
: ${DBNAME:="breakpad"} | ||
VERSION=13.0 | ||
|
||
echo '*********************************************************' | ||
echo 'replace processor monitoring view for ganglia' | ||
echo 'bug 764468' | ||
psql -f ${CURDIR}/processor_monitoring.sql $DBNAME | ||
|
||
echo '*********************************************************' | ||
echo 'modify add_new_release to better support ftpscraper' | ||
echo 'bug 763552' | ||
psql -f ${CURDIR}/add_release.sql $DBNAME | ||
|
||
#change version in DB | ||
psql -c "SELECT update_socorro_db_version( '$VERSION' )" $DBNAME | ||
|
||
echo "$VERSION upgrade done" | ||
|
||
exit 0 |