39 lines
2.0 KiB
SQL
39 lines
2.0 KiB
SQL
-- Candidate Cube backend only. Never applied at startup. Requires the existing
|
|
-- unsuffixed player/item/economy InnoDB schema and matching online coordinator.
|
|
-- Installing these tables alone MUST NOT enable gameplay or create fences.
|
|
CREATE TABLE IF NOT EXISTS port_cube_version (
|
|
id INT UNSIGNED PRIMARY KEY, version INT UNSIGNED NOT NULL
|
|
) ENGINE=InnoDB;
|
|
CREATE TABLE IF NOT EXISTS port_cube_requests (
|
|
token CHAR(32) CHARACTER SET ascii COLLATE ascii_bin PRIMARY KEY,
|
|
account INT UNSIGNED NOT NULL, pid INT UNSIGNED NOT NULL,
|
|
body MEDIUMBLOB NOT NULL, rolls VARBINARY(100) NOT NULL,
|
|
state ENUM('PREPARED','DONE') NOT NULL,
|
|
result VARCHAR(64) CHARACTER SET ascii NOT NULL,
|
|
successes INT UNSIGNED NOT NULL DEFAULT 0,
|
|
fee BIGINT UNSIGNED NOT NULL DEFAULT 0, awards MEDIUMBLOB NOT NULL,
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
INDEX player_history(pid,created_at)
|
|
) ENGINE=InnoDB;
|
|
-- Only the future cache-drain/owner coordinator may install FROZEN. Time alone
|
|
-- may never release it: ambiguous commits require journal lookup and resync.
|
|
CREATE TABLE IF NOT EXISTS port_cube_fences (
|
|
pid INT UNSIGNED PRIMARY KEY, account INT UNSIGNED NOT NULL,
|
|
epoch BIGINT UNSIGNED NOT NULL,
|
|
owner CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
request CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL UNIQUE,
|
|
phase ENUM('DRAINING','FROZEN','ABORTED','RESYNC','RELEASED') NOT NULL,
|
|
body MEDIUMBLOB NOT NULL, image MEDIUMBLOB NOT NULL,
|
|
drain_state TINYINT UNSIGNED NOT NULL DEFAULT 0
|
|
) ENGINE=InnoDB;
|
|
-- Covers consumed IDs too: lookup by the current item owner cannot protect an
|
|
-- ID after its row has been deleted by the transaction.
|
|
CREATE TABLE IF NOT EXISTS port_cube_item_fences (
|
|
id INT UNSIGNED PRIMARY KEY, pid INT UNSIGNED NOT NULL,
|
|
epoch BIGINT UNSIGNED NOT NULL,
|
|
request CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
INDEX player_fence(pid,epoch)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO port_cube_version(id,version) VALUES(1,2)
|
|
ON DUPLICATE KEY UPDATE version=version;
|