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
44 lines
No EOL
1.1 KiB
SQL
44 lines
No EOL
1.1 KiB
SQL
-- LegacyWorlds Beta 6
|
|
-- PostgreSQL database scripts
|
|
--
|
|
-- System "constants"
|
|
--
|
|
-- Copyright(C) 2004-2010, DeepClone Development
|
|
-- --------------------------------------------------------
|
|
|
|
--
|
|
-- Constant categories
|
|
--
|
|
CREATE TABLE sys.constant_categories(
|
|
id SERIAL NOT NULL PRIMARY KEY ,
|
|
name VARCHAR(64) NOT NULL
|
|
);
|
|
|
|
CREATE UNIQUE INDEX idx_constantcategories_name
|
|
ON sys.constant_categories (name);
|
|
|
|
|
|
--
|
|
-- Constant definitions and values
|
|
--
|
|
CREATE TABLE sys.constant_definitions(
|
|
name VARCHAR(64) NOT NULL PRIMARY KEY,
|
|
category_id INT NOT NULL ,
|
|
description TEXT NOT NULL ,
|
|
min_value REAL ,
|
|
max_value REAL ,
|
|
c_value REAL NOT NULL ,
|
|
CHECK(
|
|
( min_value IS NULL OR (
|
|
min_value IS NOT NULL AND c_value >= min_value ) )
|
|
AND ( max_value IS NULL OR (
|
|
max_value IS NOT NULL AND max_value >= c_value ) )
|
|
)
|
|
);
|
|
|
|
CREATE INDEX idx_constantdefinitions_category
|
|
ON sys.constant_definitions (category_id);
|
|
|
|
ALTER TABLE sys.constant_definitions
|
|
ADD CONSTRAINT fk_constraintdefinitions_category
|
|
FOREIGN KEY (category_id) REFERENCES sys.constant_categories; |