CREATE TABLE IF NOT EXISTS `games` (
	`user_id` text NOT NULL,
	`world` text NOT NULL,
	`state` text NOT NULL,
	`revision` integer DEFAULT 0 NOT NULL,
	`previous` text,
	`updated_at` integer NOT NULL,
	PRIMARY KEY(`user_id`, `world`)
);

CREATE TABLE IF NOT EXISTS `game_backups` (
	`user_id` text NOT NULL,
	`world` text NOT NULL,
	`revision` integer NOT NULL,
	`state` text NOT NULL,
	`created_at` integer NOT NULL,
	PRIMARY KEY(`user_id`, `world`, `revision`)
);

CREATE TABLE IF NOT EXISTS `state_parts` (
	`user_id` text NOT NULL,
	`world` text NOT NULL,
	`token` text NOT NULL,
	`part` integer NOT NULL,
	`data` text NOT NULL,
	PRIMARY KEY(`user_id`, `world`, `token`, `part`)
);

