diff --git a/legacyworlds-server-data/db-structure/database.sql b/legacyworlds-server-data/db-structure/database.sql index 7b8f951..50b7913 100644 --- a/legacyworlds-server-data/db-structure/database.sql +++ b/legacyworlds-server-data/db-structure/database.sql @@ -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; \ No newline at end of file +/* Delete loader script */ +\! rm loader.tmp \ No newline at end of file diff --git a/legacyworlds-server-data/db-structure/parts/010-data.sql b/legacyworlds-server-data/db-structure/parts/010-data.sql deleted file mode 100644 index f5e52b7..0000000 --- a/legacyworlds-server-data/db-structure/parts/010-data.sql +++ /dev/null @@ -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 \ No newline at end of file diff --git a/legacyworlds-server-data/db-structure/parts/000-schemas.sql b/legacyworlds-server-data/db-structure/parts/010-schemas.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/000-schemas.sql rename to legacyworlds-server-data/db-structure/parts/010-schemas.sql diff --git a/legacyworlds-server-data/db-structure/parts/020-extensions.sql b/legacyworlds-server-data/db-structure/parts/020-extensions.sql new file mode 100644 index 0000000..0889c1d --- /dev/null +++ b/legacyworlds-server-data/db-structure/parts/020-extensions.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; diff --git a/legacyworlds-server-data/db-structure/parts/020-functions.sql b/legacyworlds-server-data/db-structure/parts/020-functions.sql deleted file mode 100644 index 027e727..0000000 --- a/legacyworlds-server-data/db-structure/parts/020-functions.sql +++ /dev/null @@ -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 - diff --git a/legacyworlds-server-data/db-structure/parts/data/000-typedefs.sql b/legacyworlds-server-data/db-structure/parts/030-data/000-typedefs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/000-typedefs.sql rename to legacyworlds-server-data/db-structure/parts/030-data/000-typedefs.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/010-i18n-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/010-i18n.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/010-i18n-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/010-i18n.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/020-prefs-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/020-prefs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/020-prefs-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/020-prefs.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/030-users-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/030-users.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/030-users-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/030-users.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/035-session-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/035-session.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/035-session-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/035-session.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/040-admin-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/040-admin.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/040-admin-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/040-admin.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/050-accounts-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/050-accounts.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/050-accounts-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/050-accounts.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/055-bugs-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/055-bugs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/055-bugs-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/055-bugs.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/060-naming-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/060-naming.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/060-naming-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/060-naming.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/070-constants-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/070-constants.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/070-constants-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/070-constants.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/075-resources-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/075-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/075-resources-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/075-resources.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/080-techs-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/080-techs-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/080-techs.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/090-buildables-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/090-buildables.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/090-buildables-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/090-buildables.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/100-universe-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/100-universe.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/100-universe-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/100-universe.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/110-empires-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/110-empires.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/110-empires-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/110-empires.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/120-construction-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/120-construction.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/120-construction-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/120-construction.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/130-fleets-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/130-fleets.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/130-fleets-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/130-fleets.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/140-status-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/140-status.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/140-status-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/140-status.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/150-logs-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/150-logs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/150-logs-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/150-logs.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/160-battle-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/160-battle.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/160-battle-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/160-battle.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/170-events-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/170-events.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/170-events-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/170-events.sql diff --git a/legacyworlds-server-data/db-structure/parts/data/180-messages-data.sql b/legacyworlds-server-data/db-structure/parts/030-data/180-messages.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/data/180-messages-data.sql rename to legacyworlds-server-data/db-structure/parts/030-data/180-messages.sql diff --git a/legacyworlds-server-data/db-structure/parts/030-updates.sql b/legacyworlds-server-data/db-structure/parts/030-updates.sql deleted file mode 100644 index 12efd35..0000000 --- a/legacyworlds-server-data/db-structure/parts/030-updates.sql +++ /dev/null @@ -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 diff --git a/legacyworlds-server-data/db-structure/parts/functions/000-defs-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/000-defs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/000-defs-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/000-defs.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/002-sys-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/002-sys.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/002-sys-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/002-sys.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/005-logs-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/005-logs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/005-logs-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/005-logs.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/010-constants-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/010-constants.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/010-constants-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/010-constants.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/020-naming-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/020-naming.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/020-naming-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/020-naming.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/025-resources-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/025-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/025-resources-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/025-resources.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/030-tech-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/030-tech.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/030-tech-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/030-tech.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/035-users-view.sql b/legacyworlds-server-data/db-structure/parts/040-functions/035-users.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/035-users-view.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/035-users.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/040-empire-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/040-empire.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/040-empire-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/040-empire.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/050-computation-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/050-computation.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/050-computation-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/050-computation.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/053-generator-basics.sql b/legacyworlds-server-data/db-structure/parts/040-functions/053-generator-basics.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/053-generator-basics.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/053-generator-basics.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/055-generator-resources.sql b/legacyworlds-server-data/db-structure/parts/040-functions/055-generator-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/055-generator-resources.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/055-generator-resources.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/060-universe-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/060-universe.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/060-universe-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/060-universe.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/070-users-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/070-users.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/070-users-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/070-users.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/075-session-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/075-session.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/075-session-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/075-session.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/080-buildings-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/080-buildings.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/080-buildings-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/080-buildings.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/100-status-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/100-status.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/100-status-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/100-status.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/110-prefs-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/110-prefs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/110-prefs-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/110-prefs.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/120-map-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/120-map.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/120-map-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/120-map.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/140-planets-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/140-planets.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/140-planets-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/140-planets.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/145-resource-providers-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/145-resource-providers.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/145-resource-providers-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/145-resource-providers.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/150-battle-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/150-battle.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/150-battle-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/150-battle.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/160-battle-views.sql b/legacyworlds-server-data/db-structure/parts/040-functions/160-battle-views.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/160-battle-views.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/160-battle-views.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/163-alliance-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/163-alliance.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/163-alliance-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/163-alliance.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/165-fleets-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/165-fleets.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/165-fleets-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/165-fleets.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/167-planet-list.sql b/legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/167-planet-list.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/167-planet-list.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/170-event-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/170-event-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/170-events.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/180-messages-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/180-messages.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/180-messages-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/180-messages.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/190-admin-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/190-admin.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/190-admin-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/190-admin.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/200-bugs-functions.sql b/legacyworlds-server-data/db-structure/parts/040-functions/200-bugs.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/200-bugs-functions.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/200-bugs.sql diff --git a/legacyworlds-server-data/db-structure/parts/functions/210-admin-overview.sql b/legacyworlds-server-data/db-structure/parts/040-functions/210-admin-overview.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/functions/210-admin-overview.sql rename to legacyworlds-server-data/db-structure/parts/040-functions/210-admin-overview.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/000-updates-ctrl.sql b/legacyworlds-server-data/db-structure/parts/050-updates/000-updates-ctrl.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/000-updates-ctrl.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/000-updates-ctrl.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/010-empire-money.sql b/legacyworlds-server-data/db-structure/parts/050-updates/010-empire-money.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/010-empire-money.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/010-empire-money.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/020-empire-research.sql b/legacyworlds-server-data/db-structure/parts/050-updates/020-empire-research.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/020-empire-research.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/020-empire-research.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/025-empire-debt.sql b/legacyworlds-server-data/db-structure/parts/050-updates/025-empire-debt.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/025-empire-debt.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/025-empire-debt.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/030-fleet-arrivals.sql b/legacyworlds-server-data/db-structure/parts/050-updates/030-fleet-arrivals.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/030-fleet-arrivals.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/030-fleet-arrivals.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/040-fleet-movements.sql b/legacyworlds-server-data/db-structure/parts/050-updates/040-fleet-movements.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/040-fleet-movements.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/040-fleet-movements.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/050-fleet-status.sql b/legacyworlds-server-data/db-structure/parts/050-updates/050-fleet-status.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/050-fleet-status.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/050-fleet-status.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/060-planet-battle.sql b/legacyworlds-server-data/db-structure/parts/050-updates/060-planet-battle.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/060-planet-battle.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/060-planet-battle.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/070-planet-abandon.sql b/legacyworlds-server-data/db-structure/parts/050-updates/070-planet-abandon.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/070-planet-abandon.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/070-planet-abandon.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/080-planet-construction.sql b/legacyworlds-server-data/db-structure/parts/050-updates/080-planet-construction.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/080-planet-construction.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/080-planet-construction.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/090-planet-military.sql b/legacyworlds-server-data/db-structure/parts/050-updates/090-planet-military.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/090-planet-military.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/090-planet-military.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/100-planet-population.sql b/legacyworlds-server-data/db-structure/parts/050-updates/100-planet-population.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/100-planet-population.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/100-planet-population.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/105-planet-resource-regeneration.sql b/legacyworlds-server-data/db-structure/parts/050-updates/105-planet-resource-regeneration.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/105-planet-resource-regeneration.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/105-planet-resource-regeneration.sql diff --git a/legacyworlds-server-data/db-structure/parts/updates/110-planet-money.sql b/legacyworlds-server-data/db-structure/parts/050-updates/110-planet-money.sql similarity index 100% rename from legacyworlds-server-data/db-structure/parts/updates/110-planet-money.sql rename to legacyworlds-server-data/db-structure/parts/050-updates/110-planet-money.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/07500-resources.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/075-resources/010-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/07500-resources.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/075-resources/010-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/07501-natural-resources.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/075-resources/020-natural-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/07501-natural-resources.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/075-resources/020-natural-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/10003-resource-providers.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/100-universe/010-resource-providers.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/10003-resource-providers.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/100-universe/010-resource-providers.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/11001-empire-resources.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/010-empire-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/11001-empire-resources.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/010-empire-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/11002-empire-mining-settings.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/020-empire-mining-settings.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/11002-empire-mining-settings.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/020-empire-mining-settings.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/data/11003-empire-planet-mining-settings.sql b/legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/030-empire-planet-mining-settings.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/data/11003-empire-planet-mining-settings.sql rename to legacyworlds-server-data/db-structure/tests/admin/030-data/110-empires/030-empire-planet-mining-settings.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/010-uoc-resource-internal.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/010-uoc-resource-internal.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/010-uoc-resource-internal.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/010-uoc-resource-internal.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/020-uoc-resource.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/020-uoc-resource.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/020-uoc-resource.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/020-uoc-resource.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/030-uoc-natres-internal.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/030-uoc-natres-internal.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/030-uoc-natres-internal.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/030-uoc-natres-internal.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/040-uoc-natural-resource.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/040-uoc-natural-resource.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/025-resources/040-uoc-natural-resource.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/025-resources/040-uoc-natural-resource.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/050-computation/010-get-random-part.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/050-computation/010-get-random-part.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/050-computation/010-get-random-part.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/050-computation/010-get-random-part.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/053-generator-basics/010-list-random-planets-in.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/053-generator-basics/010-list-random-planets-in.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/053-generator-basics/010-list-random-planets-in.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/053-generator-basics/010-list-random-planets-in.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/010-collect-resprov-statistics.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/010-collect-resprov-statistics.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/010-collect-resprov-statistics.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/010-collect-resprov-statistics.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/020-compute-rpp-delta.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/020-compute-rpp-delta.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/020-compute-rpp-delta.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/020-compute-rpp-delta.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/030-create-resource-provider.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/030-create-resource-provider.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/030-create-resource-provider.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/030-create-resource-provider.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/040-create-resource-providers-with-type.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/040-create-resource-providers-with-type.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/040-create-resource-providers-with-type.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/040-create-resource-providers-with-type.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/050-create-resource-providers.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/050-create-resource-providers.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/055-generator-resources/050-create-resource-providers.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/055-generator-resources/050-create-resource-providers.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/functions/145-resource-providers/010-compute-provider-regeneration.sql b/legacyworlds-server-data/db-structure/tests/admin/040-functions/145-resource-providers/010-compute-provider-regeneration.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/functions/145-resource-providers/010-compute-provider-regeneration.sql rename to legacyworlds-server-data/db-structure/tests/admin/040-functions/145-resource-providers/010-compute-provider-regeneration.sql diff --git a/legacyworlds-server-data/db-structure/tests/admin/updates/10500-process-planet-res-regen-updates.sql b/legacyworlds-server-data/db-structure/tests/admin/050-updates/105-planet-resource-regeneration/010-process-planet-res-regen-updates.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/admin/updates/10500-process-planet-res-regen-updates.sql rename to legacyworlds-server-data/db-structure/tests/admin/050-updates/105-planet-resource-regeneration/010-process-planet-res-regen-updates.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/07500-defs-resources.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/075-resources/010-defs-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/07500-defs-resources.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/075-resources/010-defs-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/07501-defs-natural-resources.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/075-resources/020-defs-natural-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/07501-defs-natural-resources.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/075-resources/020-defs-natural-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/10003-verse-resource-providers.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/100-universe/010-verse-resource-providers.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/10003-verse-resource-providers.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/100-universe/010-verse-resource-providers.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/11001-empire-resources.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/010-empire-resources.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/11001-empire-resources.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/010-empire-resources.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/11002-empire-mining-settings.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/020-empire-mining-settings.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/11002-empire-mining-settings.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/020-empire-mining-settings.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/data/11003-empire-planet-mining-settings.sql b/legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/030-empire-planet-mining-settings.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/data/11003-empire-planet-mining-settings.sql rename to legacyworlds-server-data/db-structure/tests/user/030-data/110-empires/030-empire-planet-mining-settings.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/02500-uoc-resource-internal.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/010-uoc-resource-internal.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/02500-uoc-resource-internal.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/010-uoc-resource-internal.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/02501-uoc-resource.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/020-uoc-resource.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/02501-uoc-resource.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/020-uoc-resource.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/02502-uoc-natres-internal.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/030-uoc-natres-internal.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/02502-uoc-natres-internal.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/030-uoc-natres-internal.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/02503-uoc-natural-resource.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/040-uoc-natural-resource.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/02503-uoc-natural-resource.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/025-resources/040-uoc-natural-resource.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/050-computation/010-get-random-part.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/050-computation/010-get-random-part.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/050-computation/010-get-random-part.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/050-computation/010-get-random-part.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/053-generator-basics/010-list-random-planets-in.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/053-generator-basics/010-list-random-planets-in.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/053-generator-basics/010-list-random-planets-in.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/053-generator-basics/010-list-random-planets-in.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/010-collect-resprov-statistics.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/010-collect-resprov-statistics.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/010-collect-resprov-statistics.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/010-collect-resprov-statistics.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/020-compute-rpp-delta.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/020-compute-rpp-delta.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/020-compute-rpp-delta.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/020-compute-rpp-delta.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/030-create-resource-provider.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/030-create-resource-provider.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/030-create-resource-provider.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/030-create-resource-provider.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/040-create-resource-providers-with-type.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/040-create-resource-providers-with-type.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/040-create-resource-providers-with-type.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/040-create-resource-providers-with-type.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/050-create-resource-providers.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/050-create-resource-providers.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/055-generator-resources.sql/050-create-resource-providers.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/055-generator-resources/050-create-resource-providers.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/functions/14500-compute-provider-regeneration.sql b/legacyworlds-server-data/db-structure/tests/user/040-functions/145-resource-providers/010-compute-provider-regeneration.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/functions/14500-compute-provider-regeneration.sql rename to legacyworlds-server-data/db-structure/tests/user/040-functions/145-resource-providers/010-compute-provider-regeneration.sql diff --git a/legacyworlds-server-data/db-structure/tests/user/priv/updates/10500-process-planet-res-regen-updates.sql b/legacyworlds-server-data/db-structure/tests/user/050-updates/105-planet-resource-regeneration/010-process-planet-res-regen-updates.sql similarity index 100% rename from legacyworlds-server-data/db-structure/tests/user/priv/updates/10500-process-planet-res-regen-updates.sql rename to legacyworlds-server-data/db-structure/tests/user/050-updates/105-planet-resource-regeneration/010-process-planet-res-regen-updates.sql diff --git a/legacyworlds/doc/database.txt b/legacyworlds/doc/database.txt index b2765e1..4d035a4 100644 --- a/legacyworlds/doc/database.txt +++ b/legacyworlds/doc/database.txt @@ -35,32 +35,52 @@ The root directory includes a "database.sql" script, which can be launched in psql to create the database and associated user. The parts/ sub-directory contains the various elements of the database's -definition. It contains a few scripts, which will initialise the schemas and -load other scripts from the sub-directories. +definition. - * parts/data/ contains all data structure definitions (types, tables, - indexes, constraints and some of the views). - * parts/functions/ contains all general function definitions; this includes - both functions that are called internally and functions which are called - by the server. It also includes view definitions that depend on functions. - * parts/updates/ contains all functions that implement the game's updates. +All SQL files contained in this directory, as well as all sub-directories and +their contents, are prefixed with some number which serves as an indication of +the order in which the scripts are to be loaded. Numbering in a directory +should start with 010 and increase by 10 for each file in the sequence. +However, when adding new code, it is possible to add new files with +intermediary values. - The tests/ sub-directory contains the SQL source code for the pgTAP testing - framework as well as the tests themselves. See below for more information. +The parts/ sub-directory contains the following elements: + * schema and extension loaders, + * the xxx-data/ sub-directory which contains most data structure definitions + (types, tables, indexes, constraints and some of the views). + * the xxx-functions/ sub-directory which contains all general function + definitions; this includes both functions that are called internally and + functions which are called by the server. It also includes view definitions + that depend on functions or are used only by functions, as well as type + definitions used to pass values between functions or as return values. + * the xxx-updates/ sub-directory which contains all functions that implement + the game's updates. + +The tests/ sub-directory contains the SQL source code for the pgTAP testing +framework as well as the tests themselves. See below for more information. Unit tests ---------- - There may be up to two sub-directories in the tests/ directory. The user/ - sub-directory would contain unit tests that must be executed as the standard - user, while the admin/ directory would contain tests that required - administrative permissions on the database. +There are three sub-directories in the tests/ directory. The admin/ directory +contains tests that require administrative permissions on the database +(therefore most functionality checks can be found there), while the user/ +sub-directory contains unit tests that must be executed as the standard +user (for example privileges checks). Finally, the utils/ sub-directory +contains scripts used by tests from the admin/ directory to create test +data. - In order to run the database unit tests, the following steps must be taken: +In both directories, files are organised in a manner that is parallel to the +contents of the database creation scripts. For each actual SQL file, a +sub-directory with the same name (minus the ".sql" extension) can be created, +each sub-directory containing the test suites for the definitions and +functions from the corresponding file. - 1) pg_prove must be installed. This can be achieved by running the following - command as root: +In order to run the database unit tests, the following steps must be taken: + +1) pg_prove must be installed. This can be achieved by running the following + command as root: cpan TAP::Parser::SourceHandler::pgTAP @@ -76,7 +96,8 @@ load other scripts from the sub-directories. At this point, it becomes possible to launch the test suites by issuing a command similar to: - pg_prove -d $DATABASE -U $USER `find $DIR/ -type f -name '*.sql'` + pg_prove -d $DATABASE -U $USER \ + `find $DIR/ -type f -name '*.sql' | sort` where $DATABASE is the name of the database, $USER the name of the user that will execute the tests and $DIR being either admin or user. @@ -87,5 +108,6 @@ Build system The build system will attempt to create the database using the scripts. It will stop at the first unsuccessful command. On success, it will proceed to loading -pgTAP, then run all available unit tests. A failure will cause the build to be -aborted. \ No newline at end of file +pgTAP, then run all available unit tests: first it will execute tests from the +admin/ sub-directory, then tests from the user/ sub-directory. A failure will +cause the build to be aborted. \ No newline at end of file