This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb6/legacyworlds-server/legacyworlds-server-data/db-structure/parts/data/070-constants-data.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 DOUBLE PRECISION ,
max_value DOUBLE PRECISION ,
c_value DOUBLE PRECISION 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;