Resource database structures

* Added structures for resource definitions, natural resources
definitions, resource providers, empire resources and empire mining
settings (both empire-wide and planet-specific).

* Added a few common utility functions to the SQL test suite. These
functions allow test initialisation to be a little shorter.

* Added "MINE" production type and an associated building definition.
The production will not be added to the XML dump or to the output of the
planets summary page, as this is extremely temporary.
This commit is contained in:
Emmanuel BENOîT 2011-12-19 11:57:08 +01:00
parent 631f49fb86
commit 4e1bb91780
20 changed files with 2223 additions and 2 deletions
legacyworlds-server-data/db-structure/tests/utils

View file

@ -0,0 +1,65 @@
/*
* Utility functions used by unit tests
*
* I18N string creation and access
*/
/*
* Function that returns an invalid string identifier.
*/
CREATE FUNCTION _get_bad_string( ) RETURNS INT AS $$
SELECT MAX( id ) + 1 FROM defs.strings;
$$ LANGUAGE SQL;
/*
* Function that returns a language's identifier
*/
CREATE FUNCTION _get_language( TEXT ) RETURNS INT AS $$
SELECT id FROM defs.languages WHERE language = $1;
$$ LANGUAGE SQL;
/*
* Function that returns a string's identifier
*/
CREATE FUNCTION _get_string( TEXT ) RETURNS INT AS $$
SELECT id FROM defs.strings WHERE name = $1;
$$ LANGUAGE SQL;
/*
* Function that creates some quantity of test strings
*/
CREATE FUNCTION _create_test_strings( _quantity INT )
RETURNS VOID
AS $$
DECLARE
i INT;
BEGIN
PERFORM _create_test_strings( _quantity , 'test' );
END;
$$ LANGUAGE PLPGSQL;
/*
* Function that creates some quantity of test strings using a specific prefix
*/
CREATE FUNCTION _create_test_strings( _quantity INT , _prefix TEXT )
RETURNS VOID
AS $$
DECLARE
i INT;
BEGIN
PERFORM defs.uoc_language( 't' , 'Test' );
i := 0;
WHILE i < _quantity
LOOP
i := i + 1;
PERFORM defs.uoc_translation( 't' , _prefix || i::TEXT ,
'Test string #' || i::TEXT );
END LOOP;
END;
$$ LANGUAGE PLPGSQL;