Skip to content

Commit 4ea6bb1

Browse files
authored
Merge pull request #1105 from noplanman/mysql_fixes
MySQL fixes
2 parents 617e524 + 9f31564 commit 4ea6bb1

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
1919
### Removed
2020
### Fixed
2121
- Primary key for `poll_answer` also requires the `user_id`.
22+
- Small SQL foreign key fixes.
2223
### Security
2324

2425
## [0.62.0] - 2020-04-08

structure.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ CREATE TABLE IF NOT EXISTS `message` (
133133
FOREIGN KEY (`forward_from`) REFERENCES `user` (`id`),
134134
FOREIGN KEY (`forward_from_chat`) REFERENCES `chat` (`id`),
135135
FOREIGN KEY (`reply_to_chat`, `reply_to_message`) REFERENCES `message` (`chat_id`, `id`),
136-
FOREIGN KEY (`forward_from`) REFERENCES `user` (`id`),
137136
FOREIGN KEY (`left_chat_member`) REFERENCES `user` (`id`)
138137
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
139138

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
SET FOREIGN_KEY_CHECKS=0;
2+
3+
ALTER TABLE `telegram_update`
4+
DROP KEY `message_id`;
5+
16
ALTER TABLE `telegram_update`
2-
DROP KEY `message_id`,
37
ADD KEY `message_id` (`message_id`),
48
ADD KEY `chat_message_id` (`chat_id`, `message_id`);
9+
10+
SET FOREIGN_KEY_CHECKS=1;

utils/db-schema-update/0.62.0-unreleased.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ ALTER TABLE `poll` ADD COLUMN `open_period` int UNSIGNED DEFAULT NULL COMMENT 'A
44
ALTER TABLE `poll` ADD COLUMN `close_date` timestamp NULL DEFAULT NULL COMMENT 'Point in time (Unix timestamp) when the poll will be automatically closed' AFTER `open_period`;
55

66
ALTER TABLE `poll_answer` DROP PRIMARY KEY, ADD PRIMARY KEY (`poll_id`, `user_id`);
7+
8+
ALTER TABLE `message` DROP CONSTRAINT `message_ibfk_6`;

0 commit comments

Comments
 (0)