Skip to content

Commit

Permalink
Fix readme.gymhistory.md syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Obihoernchen authored Feb 1, 2018
1 parent 172c83b commit 4689864
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions readme.gymhistory.md
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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.