Player-defined priority storage

Added the events.custom_priorities that ought to store player-defined
priorities for event types which support it.
This commit is contained in:
Emmanuel BENOîT 2012-06-29 17:19:23 +02:00
parent 0c67d1e799
commit 8f2fd29c71

View file

@ -27,6 +27,12 @@ CREATE TABLE events.event_definitions(
evdef_adjustable BOOLEAN NOT NULL
);
/* Unique index allowing the custom priorities table to reference only
* adjustable event types.
*/
CREATE UNIQUE INDEX idx_evdef_adjustables
ON events.event_definitions( evdef_id , evdef_adjustable );
GRANT SELECT ON events.event_definitions TO :dbuser;
@ -161,6 +167,45 @@ ALTER TABLE events.field_definitions
GRANT SELECT ON events.field_definitions TO :dbuser;
/*
* Custom event priorities
* -----------------------
*
* This table stores player-defined event priority overrides. Only events
* with custom priorities may be present in this table.
*/
DROP TABLE IF EXISTS events.custom_priorities CASCADE;
CREATE TABLE events.custom_priorities(
/* Identifier of the event type */
evdef_id VARCHAR(48) NOT NULL ,
/* Used in reference to the event types - forces this table to
* reference only events that *can* be customised.
*/
evdef_adjustable BOOLEAN NOT NULL DEFAULT TRUE
CHECK( evdef_adjustable ) ,
/* Account identifier */
address_id INT NOT NULL ,
/* Custom priority */
evcp_priority INT NOT NULL
CHECK( evcp_priority BETWEEN 0 AND 4 ) ,
/* Use the event identifier and "adjustable" set value as the primary
* key. The advantage is that we get an index on both fields.
*/
PRIMARY KEY( evdef_id , evdef_adjustable )
);
ALTER TABLE events.custom_priorities
ADD CONSTRAINT fk_evcp_evdef
FOREIGN KEY ( evdef_id , evdef_adjustable )
REFERENCES events.event_definitions ( evdef_id , evdef_adjustable );
GRANT SELECT ON events.custom_priorities TO :dbuser;
/*
* Event identifier sequence
* -------------------------