diff --git a/greataped/components/model/repository/scripts/activity_pub_incoming_activity.sql b/greataped/components/model/repository/scripts/activity_pub_incoming_activity.sql new file mode 100644 index 0000000..a57651f --- /dev/null +++ b/greataped/components/model/repository/scripts/activity_pub_incoming_activity.sql @@ -0,0 +1,53 @@ +USE `###DATABASE###_history`; + +CREATE TABLE `activity_pub_incoming_activities` +( + `id` BIGINT NOT NULL AUTO_INCREMENT, + `action` VARCHAR(16) NOT NULL, + `original_id` BIGINT NOT NULL, + `identity_id` BIGINT NOT NULL, + `unique_identifier` VARCHAR(128) NOT NULL, + `timestamp` BIGINT NOT NULL, + `from` VARCHAR(256) NOT NULL, + `to` VARCHAR(256) NOT NULL, + `content` VARCHAR(4096) NOT NULL, + `raw` JSON 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_incoming_activities` +( + `id` BIGINT NOT NULL, + `identity_id` BIGINT NOT NULL, + `unique_identifier` VARCHAR(128) NOT NULL, + `timestamp` BIGINT NOT NULL, + `from` VARCHAR(256) NOT NULL, + `to` VARCHAR(256) NOT NULL, + `content` VARCHAR(4096) NOT NULL, + `raw` JSON 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`), + CONSTRAINT `fk_activity_pub_incoming_activities_to_identities` FOREIGN KEY (`identity_id`) REFERENCES `identities` (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = `utf8mb4` + COLLATE = `utf8mb4_unicode_ci`; diff --git a/greataped/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql b/greataped/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql new file mode 100644 index 0000000..ff1c823 --- /dev/null +++ b/greataped/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql @@ -0,0 +1,18 @@ + +USE `###DATABASE###`; + +CREATE TRIGGER `activity_pub_incoming_activities_after_update` +AFTER UPDATE +ON `activity_pub_incoming_activities` FOR EACH ROW +BEGIN + INSERT INTO `###DATABASE###_history`.`activity_pub_incoming_activities`(`action`, `original_id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) + VALUES('update', `old`.`id`, `old`.`identity_id`, `old`.`unique_identifier`, `old`.`timestamp`, `old`.`from`, `old`.`to`, `old`.`content`, `old`.`raw`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); +END; + +CREATE TRIGGER `activity_pub_incoming_activities_after_delete` +AFTER DELETE +ON `activity_pub_incoming_activities` FOR EACH ROW +BEGIN + INSERT INTO `###DATABASE###_history`.`activity_pub_incoming_activities`(`action`, `original_id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) + VALUES('delete', `old`.`id`, `old`.`identity_id`, `old`.`unique_identifier`, `old`.`timestamp`, `old`.`from`, `old`.`to`, `old`.`content`, `old`.`raw`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); +END; diff --git a/greataped/components/model/repository/scripts/activity_pub_outgoing_activity.sql b/greataped/components/model/repository/scripts/activity_pub_outgoing_activity.sql new file mode 100644 index 0000000..b179c21 --- /dev/null +++ b/greataped/components/model/repository/scripts/activity_pub_outgoing_activity.sql @@ -0,0 +1,53 @@ +USE `###DATABASE###_history`; + +CREATE TABLE `activity_pub_outgoing_activities` +( + `id` BIGINT NOT NULL AUTO_INCREMENT, + `action` VARCHAR(16) NOT NULL, + `original_id` BIGINT NOT NULL, + `identity_id` BIGINT NOT NULL, + `unique_identifier` VARCHAR(128) NOT NULL, + `timestamp` BIGINT NOT NULL, + `from` VARCHAR(256) NOT NULL, + `to` VARCHAR(256) NOT NULL, + `content` VARCHAR(4096) NOT NULL, + `raw` JSON 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_outgoing_activities` +( + `id` BIGINT NOT NULL, + `identity_id` BIGINT NOT NULL, + `unique_identifier` VARCHAR(128) NOT NULL, + `timestamp` BIGINT NOT NULL, + `from` VARCHAR(256) NOT NULL, + `to` VARCHAR(256) NOT NULL, + `content` VARCHAR(4096) NOT NULL, + `raw` JSON 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`), + CONSTRAINT `fk_activity_pub_outgoing_activities_to_identities` FOREIGN KEY (`identity_id`) REFERENCES `identities` (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = `utf8mb4` + COLLATE = `utf8mb4_unicode_ci`; diff --git a/greataped/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql b/greataped/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql new file mode 100644 index 0000000..1c3380f --- /dev/null +++ b/greataped/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql @@ -0,0 +1,18 @@ + +USE `###DATABASE###`; + +CREATE TRIGGER `activity_pub_outgoing_activities_after_update` +AFTER UPDATE +ON `activity_pub_outgoing_activities` FOR EACH ROW +BEGIN + INSERT INTO `###DATABASE###_history`.`activity_pub_outgoing_activities`(`action`, `original_id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) + VALUES('update', `old`.`id`, `old`.`identity_id`, `old`.`unique_identifier`, `old`.`timestamp`, `old`.`from`, `old`.`to`, `old`.`content`, `old`.`raw`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); +END; + +CREATE TRIGGER `activity_pub_outgoing_activities_after_delete` +AFTER DELETE +ON `activity_pub_outgoing_activities` FOR EACH ROW +BEGIN + INSERT INTO `###DATABASE###_history`.`activity_pub_outgoing_activities`(`action`, `original_id`, `identity_id`, `unique_identifier`, `timestamp`, `from`, `to`, `content`, `raw`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) + VALUES('delete', `old`.`id`, `old`.`identity_id`, `old`.`unique_identifier`, `old`.`timestamp`, `old`.`from`, `old`.`to`, `old`.`content`, `old`.`raw`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); +END;