Skip to content

Commit

Permalink
bug 823296 add rapid_beta_version to add_new_product()
Browse files Browse the repository at this point in the history
  • Loading branch information
selenamarie committed Jan 14, 2013
1 parent e03d68f commit 8463909
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
61 changes: 61 additions & 0 deletions sql/upgrade/35.0/add_new_product.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
DROP FUNCTION public.add_new_product(text, major_version, text, text, numeric);

CREATE OR REPLACE FUNCTION public.add_new_product(prodname text, initversion major_version, prodid text DEFAULT NULL::text, ftpname text DEFAULT NULL::text, release_throttle numeric DEFAULT 1.0, rapid_beta_version numeric DEFAULT 999.0 )
RETURNS boolean
LANGUAGE plpgsql
AS $function$
declare current_sort int;
rel_name text;
begin

IF prodname IS NULL OR initversion IS NULL THEN
RAISE EXCEPTION 'a product name and initial version are required';
END IF;

-- check if product already exists
PERFORM 1 FROM products
WHERE product_name = prodname;

IF FOUND THEN
RAISE INFO 'product % is already in the database';
RETURN FALSE;
END IF;

-- add the product
SELECT max(sort) INTO current_sort
FROM products;

INSERT INTO products ( product_name, sort, rapid_release_version,
release_name, rapid_beta_version )
VALUES ( prodname, current_sort + 1, initversion,
COALESCE(ftpname, prodname));

-- add the release channels

INSERT INTO product_release_channels ( product_name, release_channel )
SELECT prodname, release_channel
FROM release_channels;

-- if throttling, change throttle for release versions

IF release_throttle < 1.0 THEN

UPDATE product_release_channels
SET throttle = release_throttle
WHERE product_name = prodname
AND release_channel = 'release';

END IF;

-- add the productid map

IF prodid IS NOT NULL THEN
INSERT INTO product_productid_map ( product_name,
productid, version_began )
VALUES ( prodname, prodid, initversion );
END IF;

RETURN TRUE;

END;$function$

8 changes: 7 additions & 1 deletion sql/upgrade/35.0/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -e
CURDIR=$(dirname $0)
DBNAME=$1
: ${DBNAME:="breakpad"}
VERSION=34.0
VERSION=35.0

#echo '*********************************************************'
#echo 'support functions'
Expand All @@ -22,6 +22,12 @@ echo 'bug 791218'
psql -f ${CURDIR}/add_metrofirefox.sql $DBNAME
psql -f ${CURDIR}/update_product_versions.sql $DBNAME


echo '*********************************************************'
echo 'add rapid_beta_version to add_new_products()'
echo 'bug 823296'
psql -f ${CURDIR}/add_new_product.sql $DBNAME

#change version in DB
psql -c "SELECT update_socorro_db_version( '$VERSION' )" $DBNAME

Expand Down

0 comments on commit 8463909

Please sign in to comment.