Emmanuel BENOîT
e50775ec76
* 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
82 lines
1.8 KiB
SQL
82 lines
1.8 KiB
SQL
-- LegacyWorlds Beta 6
|
|
-- PostgreSQL database scripts
|
|
--
|
|
-- Construction queues
|
|
--
|
|
-- Copyright(C) 2004-2010, DeepClone Development
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
--
|
|
-- Buildings queues
|
|
--
|
|
|
|
CREATE TABLE verse.bld_queues(
|
|
planet_id INT NOT NULL PRIMARY KEY ,
|
|
money REAL NOT NULL CHECK( money >= 0 ),
|
|
work REAL NOT NULL CHECK( work >= 0 )
|
|
);
|
|
|
|
ALTER TABLE verse.bld_queues
|
|
ADD CONSTRAINT fk_bldqueues_planet
|
|
FOREIGN KEY (planet_id) REFERENCES verse.planets;
|
|
|
|
|
|
--
|
|
-- Buildings queue items
|
|
--
|
|
|
|
CREATE TABLE verse.bld_items(
|
|
queue_id INT NOT NULL ,
|
|
queue_order INT NOT NULL CHECK( queue_order >= 0 ) ,
|
|
building_id INT NOT NULL ,
|
|
destroy BOOLEAN NOT NULL ,
|
|
amount INT NOT NULL CHECK( amount > 0 ) ,
|
|
PRIMARY KEY( queue_id , queue_order )
|
|
);
|
|
|
|
CREATE INDEX idx_blditems_building
|
|
ON verse.bld_items (building_id);
|
|
|
|
ALTER TABLE verse.bld_items
|
|
ADD CONSTRAINT fk_blditems_queue
|
|
FOREIGN KEY (queue_id) REFERENCES verse.bld_queues ,
|
|
ADD CONSTRAINT fk_blditems_building
|
|
FOREIGN KEY (building_id) REFERENCES tech.buildings;
|
|
|
|
|
|
--
|
|
-- Military queues
|
|
--
|
|
|
|
CREATE TABLE verse.mil_queues(
|
|
planet_id INT NOT NULL PRIMARY KEY ,
|
|
money REAL NOT NULL CHECK( money >= 0 ),
|
|
work REAL NOT NULL CHECK( work >= 0 )
|
|
);
|
|
|
|
ALTER TABLE verse.mil_queues
|
|
ADD CONSTRAINT fk_milqueues_planet
|
|
FOREIGN KEY (planet_id) REFERENCES verse.planets;
|
|
|
|
|
|
--
|
|
-- Military queue items
|
|
--
|
|
|
|
CREATE TABLE verse.mil_items(
|
|
queue_id INT NOT NULL ,
|
|
queue_order INT NOT NULL CHECK( queue_order >= 0 ) ,
|
|
ship_id INT NOT NULL ,
|
|
amount INT NOT NULL CHECK( amount > 0 ) ,
|
|
PRIMARY KEY( queue_id , queue_order )
|
|
);
|
|
|
|
CREATE INDEX idx_militems_ship
|
|
ON verse.mil_items (ship_id);
|
|
|
|
ALTER TABLE verse.mil_items
|
|
ADD CONSTRAINT fk_militems_queue
|
|
FOREIGN KEY (queue_id) REFERENCES verse.mil_queues ,
|
|
ADD CONSTRAINT fk_militems_ship
|
|
FOREIGN KEY (ship_id) REFERENCES tech.ships;
|