forked from Desenvolvimento-de-Software/mslovelace_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the database updates to federations.
- Loading branch information
1 parent
25f57b9
commit 14fb5be
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
CREATE TABLE `ada`.`federations` ( | ||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, | ||
`user_id` int(10) unsigned NOT NULL, | ||
`hash` varchar(32) NOT NULL, | ||
`description` varchar(100) DEFAULT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `idx_hash` (`hash`), | ||
KEY `fk_federations_user_id_idx` (`user_id`), | ||
CONSTRAINT `fk_federations_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION | ||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 | ||
|
||
ALTER TABLE `ada`.`chats` | ||
ADD COLUMN `federation_id` INT UNSIGNED NULL AFTER `id`, | ||
ADD INDEX `idx_federation_id` (`federation_id` ASC) VISIBLE; | ||
|
||
ALTER TABLE `ada`.`chats` | ||
ADD CONSTRAINT `fk_chats_federation_id` | ||
FOREIGN KEY (`federation_id`) | ||
REFERENCES `ada`.`federations` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION; | ||
|
||
ALTER TABLE `ada`.`bans` | ||
ADD COLUMN `federation_id` INT UNSIGNED NULL AFTER `chat_id`, | ||
ADD INDEX `fk_bans_federation_id_idx` (`federation_id` ASC) VISIBLE; | ||
|
||
ALTER TABLE `ada`.`bans` | ||
ADD CONSTRAINT `fk_bans_federation_id` | ||
FOREIGN KEY (`federation_id`) | ||
REFERENCES `ada`.`federations` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION; | ||
|
||
CREATE TABLE `ada`.`rel_users_federations` ( | ||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, | ||
`user_id` INT UNSIGNED NOT NULL, | ||
`federation_id` INT UNSIGNED NOT NULL, | ||
`date` INT UNSIGNED NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE INDEX `idx_uq_user_id_federation_id` (`user_id` ASC, `federation_id` ASC) VISIBLE, | ||
INDEX `fk_rel_users_federations_federation_id_idx` (`federation_id` ASC) VISIBLE, | ||
CONSTRAINT `fk_rel_users_federations_user_id` | ||
FOREIGN KEY (`user_id`) | ||
REFERENCES `ada`.`users` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_rel_users_federations_federation_id` | ||
FOREIGN KEY (`federation_id`) | ||
REFERENCES `ada`.`federations` (`id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION); |