Revert "PRIMARY KEY consistency"

This reverts commit c7319028b6.
This commit is contained in:
Timo Smit 2017-01-15 11:51:19 +01:00
parent c7319028b6
commit 9d4aaa7a62

View file

@ -1,10 +1,9 @@
CREATE TABLE IF NOT EXISTS `level` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`name` TEXT NOT NULL,
PRIMARY KEY (`id`)
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS `level_role` (
CREATE TABLE `level_role` (
`level_id` INTEGER NOT NULL,
`role` TEXT NOT NULL,
PRIMARY KEY (`level_id`, `role`),
@ -12,34 +11,31 @@ CREATE TABLE IF NOT EXISTS `level_role` (
);
CREATE TABLE IF NOT EXISTS `player` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`guid` TEXT NOT NULL UNIQUE,
`ip` TEXT NOT NULL,
`level` INTEGER NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `player_level` FOREIGN KEY (`level`) REFERENCES `level` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE TABLE IF NOT EXISTS `alias` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`player_id` INTEGER NOT NULL,
`alias` TEXT NOT NULL,
`cleanalias` TEXT NOT NULL,
`lastused` INTEGER NOT NULL,
`used` INTEGER NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `alias_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
CREATE INDEX IF NOT EXISTS `alias_player_idx` ON `alias` (`player_id`);
CREATE TABLE IF NOT EXISTS `player_level` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`player_id` INTEGER NOT NULL,
`invoker_id` INTEGER NOT NULL,
`level` INTEGER NOT NULL,
`datetime` INTEGER NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `level_player` FOREIGN KEY (`player_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `level_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
@ -48,12 +44,11 @@ CREATE INDEX IF NOT EXISTS `level_player_idx` ON `player_level` (`player_id`);
CREATE INDEX IF NOT EXISTS `level_invoker_idx` ON `player_level` (`invoker_id`);
CREATE TABLE IF NOT EXISTS `history` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`victim_id` INTEGER NOT NULL,
`invoker_id` INTEGER NOT NULL,
`datetime` INTEGER NOT NULL,
`reason` TEXT NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `history_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `history_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
@ -62,14 +57,13 @@ CREATE INDEX IF NOT EXISTS `history_victim_idx` ON `history` (`victim_id`);
CREATE INDEX IF NOT EXISTS `history_invoker_idx` ON `history` (`invoker_id`);
CREATE TABLE IF NOT EXISTS `mute` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`victim_id` INTEGER NOT NULL,
`invoker_id` INTEGER NOT NULL,
`issued` INTEGER NOT NULL,
`expires` INTEGER NOT NULL,
`duration` INTEGER NOT NULL,
`reason` TEXT NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `mute_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `mute_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
@ -78,14 +72,13 @@ CREATE INDEX IF NOT EXISTS `mute_victim_idx` ON `mute` (`victim_id`);
CREATE INDEX IF NOT EXISTS `mute_invoker_idx` ON `mute` (`invoker_id`);
CREATE TABLE IF NOT EXISTS `ban` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`victim_id` INTEGER NOT NULL,
`invoker_id` INTEGER NOT NULL,
`issued` INTEGER NOT NULL,
`expires` INTEGER NOT NULL,
`duration` INTEGER NOT NULL,
`reason` TEXT NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `ban_victim` FOREIGN KEY (`victim_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `ban_invoker` FOREIGN KEY (`invoker_id`) REFERENCES `player` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
);
@ -94,9 +87,8 @@ CREATE INDEX IF NOT EXISTS `ban_victim_idx` ON `ban` (`victim_id`);
CREATE INDEX IF NOT EXISTS `ban_invoker_idx` ON `ban` (`invoker_id`);
CREATE TABLE IF NOT EXISTS `map` (
`id` INTEGER NOT NULL AUTOINCREMENT,
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`name` TEXT NOT NULL,
PRIMARY KEY (`id`),
`lastplayed` INTEGER NOT NULL
);