Permalink
Browse files

Fix readme.gymhistory.md syntax

  • Loading branch information...
Obihoernchen committed Feb 1, 2018
1 parent 172c83b commit 468986469fe6ec96b7cb40a4ee7971dce0d00bc4
Showing with 15 additions and 18 deletions.
  1. +15 −18 readme.gymhistory.md
@@ -1,9 +1,7 @@
Use the following SQL-Statements to create the new table:
=========================================================
## Use the following SQL-Statements to create the new table:
--
-- Table structure for table `gymhistory`
--
### Table structure for table `gymhistory`
```sql
CREATE TABLE IF NOT EXISTS `gymhistory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`gym_id` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -22,24 +20,22 @@ CREATE TABLE IF NOT EXISTS `gymhistory` (
KEY `last_updated` (`last_updated`),
KEY `combined` (`gym_id`, `team_id`, `total_cp`, `last_updated`, `pokemon_count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
```
--
-- Add inital dataset for table `gymhistory`
--
### Add inital dataset for table `gymhistory`
```sql
INSERT INTO `gymhistory` (
SELECT NULL, g.gym_id, g.team_id, g.guard_pokemon_id, g.total_cp, g.last_modified, g.last_modified as last_updated,
(SELECT GROUP_CONCAT(DISTINCT pokemon_uid ORDER BY deployment_time SEPARATOR ',') FROM gymmember AS gm WHERE gm.gym_id = g.gym_id GROUP BY gym_id) AS pokemon_uids,
(SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = g.gym_id) AS pokemon_count
FROM gym AS g
);
```
## Use the following SQL-Statements to create the event to update the new table:
Use the following SQL-Statements to create the event to update the new table:
=============================================================================
--
-- Create event `gymhistory_update`
--
### Create event `gymhistory_update`
```sql
DELIMITER //
CREATE EVENT IF NOT EXISTS `gymhistory_update`
ON SCHEDULE EVERY 15 SECOND
@@ -55,8 +51,9 @@ DO BEGIN
END
//
DELIMITER ;
```
--
-- Enable MySQL event scheduler
--
SET GLOBAL event_scheduler = ON;
### Enable MySQL event scheduler
```sql
SET GLOBAL event_scheduler = ON;
```

0 comments on commit 4689864

Please sign in to comment.