Skip to content

Instantly share code, notes, and snippets.

@Znote
Created August 27, 2019 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Znote/2508c1d50fcca318f80b3ea4bc6f10a3 to your computer and use it in GitHub Desktop.
Save Znote/2508c1d50fcca318f80b3ea4bc6f10a3 to your computer and use it in GitHub Desktop.
[TFS 2.0] items table to support unique item reference
CREATE TABLE IF NOT EXISTS `items` (
`item_uid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`itemtype` smallint(6) NOT NULL,
`count` smallint(5) NOT NULL,
`attributes` blob NOT NULL,
PRIMARY KEY (`item_uid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
CREATE TABLE IF NOT EXISTS `items_timestamps` (
`item_uid` bigint(20) unsigned NOT NULL,
`created` bigint(20) unsigned NOT NULL DEFAULT '0',
`updated` bigint(20) unsigned NOT NULL DEFAULT '0',
`expired` bigint(20) unsigned NOT NULL DEFAULT '0'
FOREIGN KEY (`item_uid`) REFERENCES `items`(`item_uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
CREATE TABLE IF NOT EXISTS `player_depotitems` (
`player_id` int(11) NOT NULL,
`sid` int(11) NOT NULL COMMENT 'any given range eg 0-100 will be reserved for depot lockers and all > 100 will be then normal items inside depots',
`pid` int(11) NOT NULL DEFAULT '0',
`item_uid` bigint(20) unsigned NOT NULL,
UNIQUE KEY `player_id_2` (`player_id`, `sid`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`item_uid`) REFERENCES `items`(`item_uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
CREATE TABLE IF NOT EXISTS `player_inboxitems` (
`player_id` int(11) NOT NULL,
`sid` int(11) NOT NULL,
`pid` int(11) NOT NULL DEFAULT '0',
`item_uid` bigint(20) unsigned NOT NULL,
UNIQUE KEY `player_id_2` (`player_id`, `sid`),
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`item_uid`) REFERENCES `items`(`item_uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
CREATE TABLE IF NOT EXISTS `player_items` (
`player_id` int(11) NOT NULL DEFAULT '0',
`pid` int(11) NOT NULL DEFAULT '0',
`sid` int(11) NOT NULL DEFAULT '0',
`item_uid` bigint(20) unsigned NOT NULL,
FOREIGN KEY (`player_id`) REFERENCES `players`(`id`) ON DELETE CASCADE,
FOREIGN KEY (`item_uid`) REFERENCES `items`(`item_uid`) ON DELETE CASCADE,
KEY `sid` (`sid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment