feat(components): 🗃️ migration scripts

master
Xeronith 2022-11-07 20:09:15 +03:30
rodzic 0caad0b14d
commit 70dbd87f49
2 zmienionych plików z 66 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,48 @@
USE `###DATABASE###_history`;
CREATE TABLE `activity_pub_followers`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`action` VARCHAR(16) NOT NULL,
`original_id` BIGINT NOT NULL,
`handle` VARCHAR(256) NOT NULL,
`inbox` VARCHAR(256) NOT NULL,
`subject` VARCHAR(256) NOT NULL,
`activity` VARCHAR(4096) NOT NULL,
`accepted` BIT(1) NOT NULL,
`editor` BIGINT NOT NULL,
`status` BIGINT NOT NULL,
`sort_order` FLOAT NOT NULL,
`queued_at` BIGINT NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`triggered_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`changed_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`payload` JSON NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
DEFAULT CHARSET = `utf8mb4`
COLLATE = `utf8mb4_unicode_ci`;
USE `###DATABASE###`;
CREATE TABLE `activity_pub_followers`
(
`id` BIGINT NOT NULL,
`handle` VARCHAR(256) NOT NULL,
`inbox` VARCHAR(256) NOT NULL,
`subject` VARCHAR(256) NOT NULL,
`activity` VARCHAR(4096) NOT NULL,
`accepted` BIT(1) NOT NULL,
`editor` BIGINT NOT NULL DEFAULT 0,
`status` BIGINT NOT NULL DEFAULT 0,
`sort_order` FLOAT NOT NULL DEFAULT 0,
`queued_at` BIGINT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`payload` JSON NULL,
PRIMARY KEY (`id`),
INDEX (`status`)
) ENGINE = InnoDB
DEFAULT CHARSET = `utf8mb4`
COLLATE = `utf8mb4_unicode_ci`;

Wyświetl plik

@ -0,0 +1,18 @@
USE `###DATABASE###`;
CREATE TRIGGER `activity_pub_followers_after_update`
AFTER UPDATE
ON `activity_pub_followers` FOR EACH ROW
BEGIN
INSERT INTO `###DATABASE###_history`.`activity_pub_followers`(`action`, `original_id`, `handle`, `inbox`, `subject`, `activity`, `accepted`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`)
VALUES('update', `old`.`id`, `old`.`handle`, `old`.`inbox`, `old`.`subject`, `old`.`activity`, `old`.`accepted`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`);
END;
CREATE TRIGGER `activity_pub_followers_after_delete`
AFTER DELETE
ON `activity_pub_followers` FOR EACH ROW
BEGIN
INSERT INTO `###DATABASE###_history`.`activity_pub_followers`(`action`, `original_id`, `handle`, `inbox`, `subject`, `activity`, `accepted`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`)
VALUES('delete', `old`.`id`, `old`.`handle`, `old`.`inbox`, `old`.`subject`, `old`.`activity`, `old`.`accepted`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`);
END;