Database definition & tests organisation
* The main loader script has been updated to generate the list of files it needs to load automatically. As a consequence, files that contained manually-maintained lists of scripts have been removed, and definition directories have been renamed accordingly. * PostgreSQL extension loading and configuration has been moved to a separate script to be loaded automatically in the main transaction. * Data and function definition scripts that had the -data or -functions suffix have been renamed (the suffix is unnecessary). * Unit tests have been reorganised to follow the definition's structure. * Documentation has been improved
This commit is contained in:
parent
b054a379a9
commit
e50775ec76
112 changed files with 78 additions and 144 deletions
|
@ -1,12 +1,12 @@
|
|||
-- LegacyWorlds Beta 6
|
||||
-- PostgreSQL database scripts
|
||||
--
|
||||
-- Main database script
|
||||
-- Main database loader script
|
||||
--
|
||||
-- Initialises the various roles and the database itself,
|
||||
-- then processes scripts from the "parts" directory.
|
||||
--
|
||||
-- Copyright(C) 2004-2010, DeepClone Development
|
||||
-- Copyright(C) 2004-2012, DeepClone Development
|
||||
-- --------------------------------------------------------
|
||||
|
||||
-- Read configuration from file
|
||||
|
@ -18,6 +18,12 @@
|
|||
\set dbupass ''''`grep ^password= db-config.txt | sed -e s/.*=// -e "s/'/''/g"`''''
|
||||
|
||||
|
||||
/* List all files in the "parts" directory and create a loader script from
|
||||
* that.
|
||||
*/
|
||||
\! find parts -type f -name '*.sql' | sort | sed -e 's/^/\\i /' > loader.tmp
|
||||
|
||||
|
||||
-- Connect to the main system database
|
||||
\c postgres :pgadmin
|
||||
|
||||
|
@ -36,34 +42,10 @@ GRANT CONNECT ON DATABASE :dbname TO :dbuser;
|
|||
-- Connect to the LW database with the PostgreSQL admin user
|
||||
\c :dbname :pgadmin
|
||||
|
||||
-- Register the dblink extension
|
||||
CREATE EXTENSION dblink;
|
||||
|
||||
-- Create foreign data wrapper and server used to write logs from within
|
||||
-- transanctions
|
||||
CREATE FOREIGN DATA WRAPPER pgsql
|
||||
VALIDATOR postgresql_fdw_validator;
|
||||
CREATE SERVER srv_logging
|
||||
FOREIGN DATA WRAPPER pgsql
|
||||
OPTIONS ( hostaddr '127.0.0.1' , dbname :dbname_string );
|
||||
CREATE USER MAPPING FOR :dbuser
|
||||
SERVER srv_logging
|
||||
OPTIONS ( user :dbuser_string , password :dbupass );
|
||||
GRANT USAGE ON FOREIGN SERVER srv_logging TO :dbuser;
|
||||
|
||||
|
||||
/* Load everything from the loader script */
|
||||
BEGIN;
|
||||
\i loader.tmp
|
||||
COMMIT;
|
||||
|
||||
-- Create database schemas
|
||||
\i parts/000-schemas.sql
|
||||
|
||||
-- Process structure definition scripts
|
||||
\i parts/010-data.sql
|
||||
|
||||
-- Process functions and views definition scripts
|
||||
\i parts/020-functions.sql
|
||||
|
||||
-- Process game update functions
|
||||
\i parts/030-updates.sql
|
||||
|
||||
COMMIT;
|
||||
/* Delete loader script */
|
||||
\! rm loader.tmp
|
|
@ -1,30 +0,0 @@
|
|||
-- LegacyWorlds Beta 6
|
||||
-- PostgreSQL database scripts
|
||||
--
|
||||
-- Structures creation
|
||||
--
|
||||
-- Copyright(C) 2004-2010, DeepClone Development
|
||||
-- --------------------------------------------------------
|
||||
|
||||
\i parts/data/000-typedefs.sql
|
||||
\i parts/data/010-i18n-data.sql
|
||||
\i parts/data/020-prefs-data.sql
|
||||
\i parts/data/030-users-data.sql
|
||||
\i parts/data/035-session-data.sql
|
||||
\i parts/data/040-admin-data.sql
|
||||
\i parts/data/050-accounts-data.sql
|
||||
\i parts/data/055-bugs-data.sql
|
||||
\i parts/data/060-naming-data.sql
|
||||
\i parts/data/070-constants-data.sql
|
||||
\i parts/data/075-resources-data.sql
|
||||
\i parts/data/080-techs-data.sql
|
||||
\i parts/data/090-buildables-data.sql
|
||||
\i parts/data/100-universe-data.sql
|
||||
\i parts/data/110-empires-data.sql
|
||||
\i parts/data/120-construction-data.sql
|
||||
\i parts/data/130-fleets-data.sql
|
||||
\i parts/data/140-status-data.sql
|
||||
\i parts/data/150-logs-data.sql
|
||||
\i parts/data/160-battle-data.sql
|
||||
\i parts/data/170-events-data.sql
|
||||
\i parts/data/180-messages-data.sql
|
|
@ -0,0 +1,23 @@
|
|||
-- LegacyWorlds Beta 6
|
||||
-- PostgreSQL database scripts
|
||||
--
|
||||
-- Load and configure required PostgreSQL extensions
|
||||
--
|
||||
-- Copyright(C) 2004-2012, DeepClone Development
|
||||
-- --------------------------------------------------------
|
||||
|
||||
/* Register the dblink extension */
|
||||
CREATE EXTENSION dblink;
|
||||
|
||||
/* Create foreign data wrapper and server used to write logs from within
|
||||
* transanctions
|
||||
*/
|
||||
CREATE FOREIGN DATA WRAPPER pgsql
|
||||
VALIDATOR postgresql_fdw_validator;
|
||||
CREATE SERVER srv_logging
|
||||
FOREIGN DATA WRAPPER pgsql
|
||||
OPTIONS ( hostaddr '127.0.0.1' , dbname :dbname_string );
|
||||
CREATE USER MAPPING FOR :dbuser
|
||||
SERVER srv_logging
|
||||
OPTIONS ( user :dbuser_string , password :dbupass );
|
||||
GRANT USAGE ON FOREIGN SERVER srv_logging TO :dbuser;
|
|
@ -1,40 +0,0 @@
|
|||
-- LegacyWorlds Beta 6
|
||||
-- PostgreSQL database scripts
|
||||
--
|
||||
-- Functions and views
|
||||
--
|
||||
-- Copyright(C) 2004-2010, DeepClone Development
|
||||
-- --------------------------------------------------------
|
||||
|
||||
\i parts/functions/000-defs-functions.sql
|
||||
\i parts/functions/002-sys-functions.sql
|
||||
\i parts/functions/005-logs-functions.sql
|
||||
\i parts/functions/010-constants-functions.sql
|
||||
\i parts/functions/020-naming-functions.sql
|
||||
\i parts/functions/025-resources-functions.sql
|
||||
\i parts/functions/030-tech-functions.sql
|
||||
\i parts/functions/035-users-view.sql
|
||||
\i parts/functions/040-empire-functions.sql
|
||||
\i parts/functions/050-computation-functions.sql
|
||||
\i parts/functions/053-generator-basics.sql
|
||||
\i parts/functions/055-generator-resources.sql
|
||||
\i parts/functions/060-universe-functions.sql
|
||||
\i parts/functions/070-users-functions.sql
|
||||
\i parts/functions/075-session-functions.sql
|
||||
\i parts/functions/080-buildings-functions.sql
|
||||
\i parts/functions/100-status-functions.sql
|
||||
\i parts/functions/110-prefs-functions.sql
|
||||
\i parts/functions/120-map-functions.sql
|
||||
\i parts/functions/140-planets-functions.sql
|
||||
\i parts/functions/145-resource-providers-functions.sql
|
||||
\i parts/functions/150-battle-functions.sql
|
||||
\i parts/functions/160-battle-views.sql
|
||||
\i parts/functions/163-alliance-functions.sql
|
||||
\i parts/functions/165-fleets-functions.sql
|
||||
\i parts/functions/167-planet-list.sql
|
||||
\i parts/functions/170-event-functions.sql
|
||||
\i parts/functions/180-messages-functions.sql
|
||||
\i parts/functions/190-admin-functions.sql
|
||||
\i parts/functions/200-bugs-functions.sql
|
||||
\i parts/functions/210-admin-overview.sql
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
-- LegacyWorlds Beta 6
|
||||
-- PostgreSQL database scripts
|
||||
--
|
||||
-- Game updates
|
||||
--
|
||||
-- Copyright(C) 2004-2010, DeepClone Development
|
||||
-- --------------------------------------------------------
|
||||
|
||||
|
||||
\i parts/updates/000-updates-ctrl.sql
|
||||
\i parts/updates/010-empire-money.sql
|
||||
\i parts/updates/020-empire-research.sql
|
||||
\i parts/updates/025-empire-debt.sql
|
||||
\i parts/updates/030-fleet-arrivals.sql
|
||||
\i parts/updates/040-fleet-movements.sql
|
||||
\i parts/updates/050-fleet-status.sql
|
||||
\i parts/updates/060-planet-battle.sql
|
||||
\i parts/updates/070-planet-abandon.sql
|
||||
\i parts/updates/080-planet-construction.sql
|
||||
\i parts/updates/090-planet-military.sql
|
||||
\i parts/updates/100-planet-population.sql
|
||||
\i parts/updates/105-planet-resource-regeneration.sql
|
||||
\i parts/updates/110-planet-money.sql
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue