diff --git a/components/model/repository/scripts/access_control.sql b/components/model/repository/scripts/access_control.sql index a462e82..29aa5c3 100644 --- a/components/model/repository/scripts/access_control.sql +++ b/components/model/repository/scripts/access_control.sql @@ -1,42 +1,41 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `access_controls` +CREATE TABLE "access_controls_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "key" BIGINT NOT NULL, + "value" BIGINT NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_access_controls_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `access_controls` +CREATE TABLE "access_controls" ( - `id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; + "id" BIGINT NOT NULL, + "key" BIGINT NOT NULL, + "value" BIGINT NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_access_controls" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_access_controls_status" ON "access_controls" ("status"); diff --git a/components/model/repository/scripts/access_control_triggers.sql b/components/model/repository/scripts/access_control_triggers.sql index da26222..eb773e5 100644 --- a/components/model/repository/scripts/access_control_triggers.sql +++ b/components/model/repository/scripts/access_control_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "access_controls_after_update"() RETURNS TRIGGER AS $access_controls_after_update$ + BEGIN + INSERT INTO "access_controls_history"("action", "original_id", "key", "value", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."key", "OLD"."value", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$access_controls_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `access_controls_after_update` -AFTER UPDATE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "access_controls_after_update_trigger" AFTER UPDATE ON "access_controls" + FOR EACH ROW EXECUTE FUNCTION "access_controls_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "access_controls_after_delete"() RETURNS TRIGGER AS $access_controls_after_delete$ + BEGIN + INSERT INTO "access_controls_history"("action", "original_id", "key", "value", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."key", "OLD"."value", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$access_controls_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "access_controls_after_delete_trigger" AFTER DELETE ON "access_controls" + FOR EACH ROW EXECUTE FUNCTION "access_controls_after_delete"(); -CREATE TRIGGER `access_controls_after_delete` -AFTER DELETE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/activity_pub_follower.sql b/components/model/repository/scripts/activity_pub_follower.sql index 2a0f3a6..677342a 100644 --- a/components/model/repository/scripts/activity_pub_follower.sql +++ b/components/model/repository/scripts/activity_pub_follower.sql @@ -1,48 +1,47 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `activity_pub_followers` +CREATE TABLE "activity_pub_followers_history" ( - `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`; + "id" BIGSERIAL NOT NULL, + "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" BOOLEAN NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_followers_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `activity_pub_followers` +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`; + "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" BOOLEAN NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_followers" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_activity_pub_followers_status" ON "activity_pub_followers" ("status"); diff --git a/components/model/repository/scripts/activity_pub_follower_triggers.sql b/components/model/repository/scripts/activity_pub_follower_triggers.sql index d2aa39d..e5d9fde 100644 --- a/components/model/repository/scripts/activity_pub_follower_triggers.sql +++ b/components/model/repository/scripts/activity_pub_follower_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "activity_pub_followers_after_update"() RETURNS TRIGGER AS $activity_pub_followers_after_update$ + BEGIN + INSERT INTO "activity_pub_followers_history"("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; +$activity_pub_followers_after_update$ LANGUAGE plpgsql; -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 OR REPLACE TRIGGER "activity_pub_followers_after_update_trigger" AFTER UPDATE ON "activity_pub_followers" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_followers_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "activity_pub_followers_after_delete"() RETURNS TRIGGER AS $activity_pub_followers_after_delete$ + BEGIN + INSERT INTO "activity_pub_followers_history"("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; +$activity_pub_followers_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "activity_pub_followers_after_delete_trigger" AFTER DELETE ON "activity_pub_followers" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_followers_after_delete"(); -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; diff --git a/components/model/repository/scripts/activity_pub_incoming_activity.sql b/components/model/repository/scripts/activity_pub_incoming_activity.sql index a57651f..2213c1b 100644 --- a/components/model/repository/scripts/activity_pub_incoming_activity.sql +++ b/components/model/repository/scripts/activity_pub_incoming_activity.sql @@ -1,53 +1,52 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `activity_pub_incoming_activities` +CREATE TABLE "activity_pub_incoming_activities_history" ( - `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`; + "id" BIGSERIAL NOT NULL, + "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" JSONB NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_incoming_activities_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `activity_pub_incoming_activities` +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`; + "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" JSONB NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_incoming_activities" PRIMARY KEY ("id"), + CONSTRAINT "fk_activity_pub_incoming_activities_to_identities" FOREIGN KEY ("identity_id") REFERENCES "identities" ("id") +); + +########## + +CREATE INDEX "idx_activity_pub_incoming_activities_status" ON "activity_pub_incoming_activities" ("status"); diff --git a/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql b/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql index ff1c823..3ded987 100644 --- a/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql +++ b/components/model/repository/scripts/activity_pub_incoming_activity_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "activity_pub_incoming_activities_after_update"() RETURNS TRIGGER AS $activity_pub_incoming_activities_after_update$ + BEGIN + INSERT INTO "activity_pub_incoming_activities_history"("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; +$activity_pub_incoming_activities_after_update$ LANGUAGE plpgsql; -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 OR REPLACE TRIGGER "activity_pub_incoming_activities_after_update_trigger" AFTER UPDATE ON "activity_pub_incoming_activities" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_incoming_activities_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "activity_pub_incoming_activities_after_delete"() RETURNS TRIGGER AS $activity_pub_incoming_activities_after_delete$ + BEGIN + INSERT INTO "activity_pub_incoming_activities_history"("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; +$activity_pub_incoming_activities_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "activity_pub_incoming_activities_after_delete_trigger" AFTER DELETE ON "activity_pub_incoming_activities" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_incoming_activities_after_delete"(); -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/components/model/repository/scripts/activity_pub_outgoing_activity.sql b/components/model/repository/scripts/activity_pub_outgoing_activity.sql index b179c21..4819dfc 100644 --- a/components/model/repository/scripts/activity_pub_outgoing_activity.sql +++ b/components/model/repository/scripts/activity_pub_outgoing_activity.sql @@ -1,53 +1,52 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `activity_pub_outgoing_activities` +CREATE TABLE "activity_pub_outgoing_activities_history" ( - `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`; + "id" BIGSERIAL NOT NULL, + "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" JSONB NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_outgoing_activities_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `activity_pub_outgoing_activities` +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`; + "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" JSONB NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_activity_pub_outgoing_activities" PRIMARY KEY ("id"), + CONSTRAINT "fk_activity_pub_outgoing_activities_to_identities" FOREIGN KEY ("identity_id") REFERENCES "identities" ("id") +); + +########## + +CREATE INDEX "idx_activity_pub_outgoing_activities_status" ON "activity_pub_outgoing_activities" ("status"); diff --git a/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql b/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql index 1c3380f..1134595 100644 --- a/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql +++ b/components/model/repository/scripts/activity_pub_outgoing_activity_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "activity_pub_outgoing_activities_after_update"() RETURNS TRIGGER AS $activity_pub_outgoing_activities_after_update$ + BEGIN + INSERT INTO "activity_pub_outgoing_activities_history"("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; +$activity_pub_outgoing_activities_after_update$ LANGUAGE plpgsql; -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 OR REPLACE TRIGGER "activity_pub_outgoing_activities_after_update_trigger" AFTER UPDATE ON "activity_pub_outgoing_activities" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_outgoing_activities_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "activity_pub_outgoing_activities_after_delete"() RETURNS TRIGGER AS $activity_pub_outgoing_activities_after_delete$ + BEGIN + INSERT INTO "activity_pub_outgoing_activities_history"("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; +$activity_pub_outgoing_activities_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "activity_pub_outgoing_activities_after_delete_trigger" AFTER DELETE ON "activity_pub_outgoing_activities" + FOR EACH ROW EXECUTE FUNCTION "activity_pub_outgoing_activities_after_delete"(); -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; diff --git a/components/model/repository/scripts/category.sql b/components/model/repository/scripts/category.sql index e7dfcf4..dc0cefb 100644 --- a/components/model/repository/scripts/category.sql +++ b/components/model/repository/scripts/category.sql @@ -1,48 +1,47 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `categories` +CREATE TABLE "categories_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "category_type_id" BIGINT NOT NULL, + "category_id" BIGINT NOT NULL, + "title" VARCHAR(64) NOT NULL, + "description" VARCHAR(64) NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_categories_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `categories` +CREATE TABLE "categories" ( - `id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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_categories_to_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `category_types` (`id`), - CONSTRAINT `fk_categories_to_categories` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; + "id" BIGINT NOT NULL, + "category_type_id" BIGINT NOT NULL, + "category_id" BIGINT NOT NULL, + "title" VARCHAR(64) NOT NULL, + "description" VARCHAR(64) NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_categories" PRIMARY KEY ("id"), + CONSTRAINT "fk_categories_to_category_types" FOREIGN KEY ("category_type_id") REFERENCES "category_types" ("id"), + CONSTRAINT "fk_categories_to_categories" FOREIGN KEY ("category_id") REFERENCES "categories" ("id") +); + +########## + +CREATE INDEX "idx_categories_status" ON "categories" ("status"); diff --git a/components/model/repository/scripts/category_triggers.sql b/components/model/repository/scripts/category_triggers.sql index 1be5e9f..2ad8991 100644 --- a/components/model/repository/scripts/category_triggers.sql +++ b/components/model/repository/scripts/category_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "categories_after_update"() RETURNS TRIGGER AS $categories_after_update$ + BEGIN + INSERT INTO "categories_history"("action", "original_id", "category_type_id", "category_id", "title", "description", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."category_type_id", "OLD"."category_id", "OLD"."title", "OLD"."description", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$categories_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `categories_after_update` -AFTER UPDATE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "categories_after_update_trigger" AFTER UPDATE ON "categories" + FOR EACH ROW EXECUTE FUNCTION "categories_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "categories_after_delete"() RETURNS TRIGGER AS $categories_after_delete$ + BEGIN + INSERT INTO "categories_history"("action", "original_id", "category_type_id", "category_id", "title", "description", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."category_type_id", "OLD"."category_id", "OLD"."title", "OLD"."description", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$categories_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "categories_after_delete_trigger" AFTER DELETE ON "categories" + FOR EACH ROW EXECUTE FUNCTION "categories_after_delete"(); -CREATE TRIGGER `categories_after_delete` -AFTER DELETE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/category_type.sql b/components/model/repository/scripts/category_type.sql index 2dc3043..31d55ab 100644 --- a/components/model/repository/scripts/category_type.sql +++ b/components/model/repository/scripts/category_type.sql @@ -1,40 +1,39 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `category_types` +CREATE TABLE "category_types_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "description" VARCHAR(64) NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_category_types_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `category_types` +CREATE TABLE "category_types" ( - `id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; + "id" BIGINT NOT NULL, + "description" VARCHAR(64) NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_category_types" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_category_types_status" ON "category_types" ("status"); diff --git a/components/model/repository/scripts/category_type_triggers.sql b/components/model/repository/scripts/category_type_triggers.sql index 8425c57..6381c7b 100644 --- a/components/model/repository/scripts/category_type_triggers.sql +++ b/components/model/repository/scripts/category_type_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "category_types_after_update"() RETURNS TRIGGER AS $category_types_after_update$ + BEGIN + INSERT INTO "category_types_history"("action", "original_id", "description", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."description", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$category_types_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `category_types_after_update` -AFTER UPDATE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "category_types_after_update_trigger" AFTER UPDATE ON "category_types" + FOR EACH ROW EXECUTE FUNCTION "category_types_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "category_types_after_delete"() RETURNS TRIGGER AS $category_types_after_delete$ + BEGIN + INSERT INTO "category_types_history"("action", "original_id", "description", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."description", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$category_types_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "category_types_after_delete_trigger" AFTER DELETE ON "category_types" + FOR EACH ROW EXECUTE FUNCTION "category_types_after_delete"(); -CREATE TRIGGER `category_types_after_delete` -AFTER DELETE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/document.sql b/components/model/repository/scripts/document.sql index 8af6d10..90c21ba 100644 --- a/components/model/repository/scripts/document.sql +++ b/components/model/repository/scripts/document.sql @@ -1,40 +1,39 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `documents` +CREATE TABLE "documents_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `content` 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "content" JSONB NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_documents_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `documents` +CREATE TABLE "documents" ( - `id` BIGINT NOT NULL, - `content` 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`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; + "id" BIGINT NOT NULL, + "content" JSONB NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_documents" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_documents_status" ON "documents" ("status"); diff --git a/components/model/repository/scripts/document_triggers.sql b/components/model/repository/scripts/document_triggers.sql index b2e4693..ba74ea7 100644 --- a/components/model/repository/scripts/document_triggers.sql +++ b/components/model/repository/scripts/document_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "documents_after_update"() RETURNS TRIGGER AS $documents_after_update$ + BEGIN + INSERT INTO "documents_history"("action", "original_id", "content", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."content", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$documents_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `documents_after_update` -AFTER UPDATE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "documents_after_update_trigger" AFTER UPDATE ON "documents" + FOR EACH ROW EXECUTE FUNCTION "documents_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "documents_after_delete"() RETURNS TRIGGER AS $documents_after_delete$ + BEGIN + INSERT INTO "documents_history"("action", "original_id", "content", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."content", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$documents_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "documents_after_delete_trigger" AFTER DELETE ON "documents" + FOR EACH ROW EXECUTE FUNCTION "documents_after_delete"(); -CREATE TRIGGER `documents_after_delete` -AFTER DELETE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/identity.sql b/components/model/repository/scripts/identity.sql index da7fe3d..c7bd914 100644 --- a/components/model/repository/scripts/identity.sql +++ b/components/model/repository/scripts/identity.sql @@ -1,80 +1,79 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `identities` +CREATE TABLE "identities_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "username" VARCHAR(32) NOT NULL, + "phone_number" VARCHAR(12) NOT NULL, + "phone_number_confirmed" BOOLEAN NOT NULL, + "first_name" VARCHAR(128) NOT NULL, + "last_name" VARCHAR(128) NOT NULL, + "display_name" VARCHAR(128) NOT NULL, + "email" VARCHAR(128) NOT NULL, + "email_confirmed" BOOLEAN NOT NULL, + "avatar" VARCHAR(512) NOT NULL, + "banner" VARCHAR(512) NOT NULL, + "summary" VARCHAR(512) NOT NULL, + "token" VARCHAR(256) NOT NULL, + "multi_factor" BOOLEAN NOT NULL, + "hash" VARCHAR(256) NOT NULL, + "salt" VARCHAR(64) NOT NULL, + "public_key" VARCHAR(4096) NOT NULL, + "private_key" VARCHAR(4096) NOT NULL, + "permission" BIGINT NOT NULL, + "restriction" INT NOT NULL, + "last_login" BIGINT NOT NULL, + "login_count" INT NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_identities_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `identities` +CREATE TABLE "identities" ( - `id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL UNIQUE, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL UNIQUE, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL UNIQUE, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; + "id" BIGINT NOT NULL, + "username" VARCHAR(32) NOT NULL CONSTRAINT "udx_identities_username" UNIQUE, + "phone_number" VARCHAR(12) NOT NULL, + "phone_number_confirmed" BOOLEAN NOT NULL, + "first_name" VARCHAR(128) NOT NULL, + "last_name" VARCHAR(128) NOT NULL, + "display_name" VARCHAR(128) NOT NULL, + "email" VARCHAR(128) NOT NULL CONSTRAINT "udx_identities_email" UNIQUE, + "email_confirmed" BOOLEAN NOT NULL, + "avatar" VARCHAR(512) NOT NULL, + "banner" VARCHAR(512) NOT NULL, + "summary" VARCHAR(512) NOT NULL, + "token" VARCHAR(256) NOT NULL CONSTRAINT "udx_identities_token" UNIQUE, + "multi_factor" BOOLEAN NOT NULL, + "hash" VARCHAR(256) NOT NULL, + "salt" VARCHAR(64) NOT NULL, + "public_key" VARCHAR(4096) NOT NULL, + "private_key" VARCHAR(4096) NOT NULL, + "permission" BIGINT NOT NULL, + "restriction" INT NOT NULL, + "last_login" BIGINT NOT NULL, + "login_count" INT NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_identities" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_identities_status" ON "identities" ("status"); diff --git a/components/model/repository/scripts/identity_triggers.sql b/components/model/repository/scripts/identity_triggers.sql index 0f93c1b..0bc2d89 100644 --- a/components/model/repository/scripts/identity_triggers.sql +++ b/components/model/repository/scripts/identity_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "identities_after_update"() RETURNS TRIGGER AS $identities_after_update$ + BEGIN + INSERT INTO "identities_history"("action", "original_id", "username", "phone_number", "phone_number_confirmed", "first_name", "last_name", "display_name", "email", "email_confirmed", "avatar", "banner", "summary", "token", "multi_factor", "hash", "salt", "public_key", "private_key", "permission", "restriction", "last_login", "login_count", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."username", "OLD"."phone_number", "OLD"."phone_number_confirmed", "OLD"."first_name", "OLD"."last_name", "OLD"."display_name", "OLD"."email", "OLD"."email_confirmed", "OLD"."avatar", "OLD"."banner", "OLD"."summary", "OLD"."token", "OLD"."multi_factor", "OLD"."hash", "OLD"."salt", "OLD"."public_key", "OLD"."private_key", "OLD"."permission", "OLD"."restriction", "OLD"."last_login", "OLD"."login_count", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$identities_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `identities_after_update` -AFTER UPDATE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "identities_after_update_trigger" AFTER UPDATE ON "identities" + FOR EACH ROW EXECUTE FUNCTION "identities_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "identities_after_delete"() RETURNS TRIGGER AS $identities_after_delete$ + BEGIN + INSERT INTO "identities_history"("action", "original_id", "username", "phone_number", "phone_number_confirmed", "first_name", "last_name", "display_name", "email", "email_confirmed", "avatar", "banner", "summary", "token", "multi_factor", "hash", "salt", "public_key", "private_key", "permission", "restriction", "last_login", "login_count", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."username", "OLD"."phone_number", "OLD"."phone_number_confirmed", "OLD"."first_name", "OLD"."last_name", "OLD"."display_name", "OLD"."email", "OLD"."email_confirmed", "OLD"."avatar", "OLD"."banner", "OLD"."summary", "OLD"."token", "OLD"."multi_factor", "OLD"."hash", "OLD"."salt", "OLD"."public_key", "OLD"."private_key", "OLD"."permission", "OLD"."restriction", "OLD"."last_login", "OLD"."login_count", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$identities_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "identities_after_delete_trigger" AFTER DELETE ON "identities" + FOR EACH ROW EXECUTE FUNCTION "identities_after_delete"(); -CREATE TRIGGER `identities_after_delete` -AFTER DELETE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/remote_activity.sql b/components/model/repository/scripts/remote_activity.sql index 9922104..8814b23 100644 --- a/components/model/repository/scripts/remote_activity.sql +++ b/components/model/repository/scripts/remote_activity.sql @@ -1,54 +1,53 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `remote_activities` +CREATE TABLE "remote_activities_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "entry_point" VARCHAR(256) NOT NULL, + "duration" BIGINT NOT NULL, + "successful" BOOLEAN NOT NULL, + "error_message" VARCHAR(1024) NOT NULL, + "remote_address" VARCHAR(128) NOT NULL, + "user_agent" VARCHAR(512) NOT NULL, + "event_type" INT NOT NULL, + "timestamp" BIGINT NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_remote_activities_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `remote_activities` +CREATE TABLE "remote_activities" ( - `id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; + "id" BIGINT NOT NULL, + "entry_point" VARCHAR(256) NOT NULL, + "duration" BIGINT NOT NULL, + "successful" BOOLEAN NOT NULL, + "error_message" VARCHAR(1024) NOT NULL, + "remote_address" VARCHAR(128) NOT NULL, + "user_agent" VARCHAR(512) NOT NULL, + "event_type" INT NOT NULL, + "timestamp" BIGINT NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_remote_activities" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_remote_activities_status" ON "remote_activities" ("status"); diff --git a/components/model/repository/scripts/remote_activity_triggers.sql b/components/model/repository/scripts/remote_activity_triggers.sql index 1a1e7b3..4d91a4e 100644 --- a/components/model/repository/scripts/remote_activity_triggers.sql +++ b/components/model/repository/scripts/remote_activity_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "remote_activities_after_update"() RETURNS TRIGGER AS $remote_activities_after_update$ + BEGIN + INSERT INTO "remote_activities_history"("action", "original_id", "entry_point", "duration", "successful", "error_message", "remote_address", "user_agent", "event_type", "timestamp", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."entry_point", "OLD"."duration", "OLD"."successful", "OLD"."error_message", "OLD"."remote_address", "OLD"."user_agent", "OLD"."event_type", "OLD"."timestamp", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$remote_activities_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `remote_activities_after_update` -AFTER UPDATE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "remote_activities_after_update_trigger" AFTER UPDATE ON "remote_activities" + FOR EACH ROW EXECUTE FUNCTION "remote_activities_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "remote_activities_after_delete"() RETURNS TRIGGER AS $remote_activities_after_delete$ + BEGIN + INSERT INTO "remote_activities_history"("action", "original_id", "entry_point", "duration", "successful", "error_message", "remote_address", "user_agent", "event_type", "timestamp", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."entry_point", "OLD"."duration", "OLD"."successful", "OLD"."error_message", "OLD"."remote_address", "OLD"."user_agent", "OLD"."event_type", "OLD"."timestamp", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$remote_activities_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "remote_activities_after_delete_trigger" AFTER DELETE ON "remote_activities" + FOR EACH ROW EXECUTE FUNCTION "remote_activities_after_delete"(); -CREATE TRIGGER `remote_activities_after_delete` -AFTER DELETE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/system_schedule.sql b/components/model/repository/scripts/system_schedule.sql index 50a4e07..45e1843 100644 --- a/components/model/repository/scripts/system_schedule.sql +++ b/components/model/repository/scripts/system_schedule.sql @@ -1,42 +1,41 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `system_schedules` +CREATE TABLE "system_schedules_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "enabled" BOOLEAN NOT NULL, + "config" VARCHAR(1024) NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_system_schedules_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `system_schedules` +CREATE TABLE "system_schedules" ( - `id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; + "id" BIGINT NOT NULL, + "enabled" BOOLEAN NOT NULL, + "config" VARCHAR(1024) NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_system_schedules" PRIMARY KEY ("id") +); + +########## + +CREATE INDEX "idx_system_schedules_status" ON "system_schedules" ("status"); diff --git a/components/model/repository/scripts/system_schedule_triggers.sql b/components/model/repository/scripts/system_schedule_triggers.sql index b160caa..95c3f8b 100644 --- a/components/model/repository/scripts/system_schedule_triggers.sql +++ b/components/model/repository/scripts/system_schedule_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "system_schedules_after_update"() RETURNS TRIGGER AS $system_schedules_after_update$ + BEGIN + INSERT INTO "system_schedules_history"("action", "original_id", "enabled", "config", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."enabled", "OLD"."config", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$system_schedules_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `system_schedules_after_update` -AFTER UPDATE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "system_schedules_after_update_trigger" AFTER UPDATE ON "system_schedules" + FOR EACH ROW EXECUTE FUNCTION "system_schedules_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "system_schedules_after_delete"() RETURNS TRIGGER AS $system_schedules_after_delete$ + BEGIN + INSERT INTO "system_schedules_history"("action", "original_id", "enabled", "config", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."enabled", "OLD"."config", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$system_schedules_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "system_schedules_after_delete_trigger" AFTER DELETE ON "system_schedules" + FOR EACH ROW EXECUTE FUNCTION "system_schedules_after_delete"(); -CREATE TRIGGER `system_schedules_after_delete` -AFTER DELETE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/model/repository/scripts/user.sql b/components/model/repository/scripts/user.sql index 861c694..44a5fa2 100644 --- a/components/model/repository/scripts/user.sql +++ b/components/model/repository/scripts/user.sql @@ -1,41 +1,40 @@ -USE `###DATABASE###_history`; +########## -CREATE TABLE `users` +CREATE TABLE "users_history" ( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `github` VARCHAR(512) 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`; + "id" BIGSERIAL NOT NULL, + "action" VARCHAR(16) NOT NULL, + "original_id" BIGINT NOT NULL, + "github" VARCHAR(512) NOT NULL, + "editor" BIGINT NOT NULL, + "status" BIGINT NOT NULL, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_users_history" PRIMARY KEY ("id") +); -USE `###DATABASE###`; +########## -CREATE TABLE `users` +CREATE TABLE "users" ( - `id` BIGINT NOT NULL, - `github` VARCHAR(512) 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_users_to_identities` FOREIGN KEY (`id`) REFERENCES `identities` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; + "id" BIGINT NOT NULL, + "github" VARCHAR(512) NOT NULL, + "editor" BIGINT NOT NULL DEFAULT 0, + "status" BIGINT NOT NULL DEFAULT 0, + "sort_order" REAL 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, + "payload" JSONB NULL, + CONSTRAINT "pk_users" PRIMARY KEY ("id"), + CONSTRAINT "fk_users_to_identities" FOREIGN KEY ("id") REFERENCES "identities" ("id") +); + +########## + +CREATE INDEX "idx_users_status" ON "users" ("status"); diff --git a/components/model/repository/scripts/user_triggers.sql b/components/model/repository/scripts/user_triggers.sql index cd5e431..0004132 100644 --- a/components/model/repository/scripts/user_triggers.sql +++ b/components/model/repository/scripts/user_triggers.sql @@ -1,18 +1,28 @@ +########## -USE `###DATABASE###`; +CREATE OR REPLACE FUNCTION "users_after_update"() RETURNS TRIGGER AS $users_after_update$ + BEGIN + INSERT INTO "users_history"("action", "original_id", "github", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('update', "OLD"."id", "OLD"."github", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$users_after_update$ LANGUAGE plpgsql; -CREATE TRIGGER `users_after_update` -AFTER UPDATE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; +########## + +CREATE OR REPLACE TRIGGER "users_after_update_trigger" AFTER UPDATE ON "users" + FOR EACH ROW EXECUTE FUNCTION "users_after_update"(); + +########## + +CREATE OR REPLACE FUNCTION "users_after_delete"() RETURNS TRIGGER AS $users_after_delete$ + BEGIN + INSERT INTO "users_history"("action", "original_id", "github", "editor", "status", "sort_order", "queued_at", "created_at", "updated_at", "payload") + VALUES('delete', "OLD"."id", "OLD"."github", "OLD"."editor", "OLD"."status", "OLD"."sort_order", "OLD"."queued_at", "OLD"."created_at", "OLD"."updated_at", "OLD"."payload"); + END; +$users_after_delete$ LANGUAGE plpgsql; + +########## + +CREATE OR REPLACE TRIGGER "users_after_delete_trigger" AFTER DELETE ON "users" + FOR EACH ROW EXECUTE FUNCTION "users_after_delete"(); -CREATE TRIGGER `users_after_delete` -AFTER DELETE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `###DATABASE###_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END; diff --git a/components/scripts/.gitkeep b/components/scripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/components/scripts/ddl/development.sql b/components/scripts/ddl/development.sql deleted file mode 100644 index 17382fa..0000000 --- a/components/scripts/ddl/development.sql +++ /dev/null @@ -1,843 +0,0 @@ -DROP DATABASE IF EXISTS `greatape_dev_history`; -CREATE DATABASE `greatape_dev_history` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_dev_history`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `content` 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `github` VARCHAR(512) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ══════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -DROP DATABASE IF EXISTS `greatape_dev`; -CREATE DATABASE `greatape_dev` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_dev`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL, - `content` 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`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `documents_after_update` -AFTER UPDATE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `documents_after_delete` -AFTER DELETE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -DELIMITER $$ - -CREATE TRIGGER `system_schedules_after_update` -AFTER UPDATE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `system_schedules_after_delete` -AFTER DELETE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL UNIQUE, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL UNIQUE, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL UNIQUE, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `identities_after_update` -AFTER UPDATE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `identities_after_delete` -AFTER DELETE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `access_controls_after_update` -AFTER UPDATE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `access_controls_after_delete` -AFTER DELETE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -DELIMITER $$ - -CREATE TRIGGER `remote_activities_after_update` -AFTER UPDATE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `remote_activities_after_delete` -AFTER DELETE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -DELIMITER $$ - -CREATE TRIGGER `category_types_after_update` -AFTER UPDATE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `category_types_after_delete` -AFTER DELETE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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_categories_to_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `category_types` (`id`), - CONSTRAINT `fk_categories_to_categories` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `categories_after_update` -AFTER UPDATE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `categories_after_delete` -AFTER DELETE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL, - `github` VARCHAR(512) 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_users_to_identities` FOREIGN KEY (`id`) REFERENCES `identities` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `users_after_update` -AFTER UPDATE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `users_after_delete` -AFTER DELETE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_incoming_activities_after_update` -AFTER UPDATE -ON `activity_pub_incoming_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_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 `greatape_dev_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_outgoing_activities_after_update` -AFTER UPDATE -ON `activity_pub_outgoing_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_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 `greatape_dev_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_followers_after_update` -AFTER UPDATE -ON `activity_pub_followers` FOR EACH ROW -BEGIN - INSERT INTO `greatape_dev_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 `greatape_dev_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Initialization -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -# Identities -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (0, 'INVALID', '0', false, '', '', '', 'invalid@localhost', false, '', '', '', '0', b'0', '', '', '', '', 0, 0, 0, 0); -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (1, 'root', '1', false, '', '', '', 'root@localhost', false, '', '', '', '1', b'1', '', '', '', '', 0xFFFFFFFF, 0, 0, 0); - -# Users -INSERT INTO `users` (`id`, `github`) VALUES (0, ''); -INSERT INTO `users` (`id`, `github`) VALUES (1, ''); - -# CategoryTypes -INSERT INTO `category_types` (`id`, `description`) VALUES (0, 'INVALID'); - -# Categories -INSERT INTO `categories` (`id`, `category_type_id`, `category_id`, `title`, `description`) VALUES (0, 0, 0, 'INVALID', ''); diff --git a/components/scripts/ddl/production.sql b/components/scripts/ddl/production.sql deleted file mode 100644 index e1b235b..0000000 --- a/components/scripts/ddl/production.sql +++ /dev/null @@ -1,843 +0,0 @@ -DROP DATABASE IF EXISTS `greatape_history`; -CREATE DATABASE `greatape_history` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_history`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `content` 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `github` VARCHAR(512) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ══════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -DROP DATABASE IF EXISTS `greatape`; -CREATE DATABASE `greatape` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL, - `content` 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`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `documents_after_update` -AFTER UPDATE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `documents_after_delete` -AFTER DELETE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -DELIMITER $$ - -CREATE TRIGGER `system_schedules_after_update` -AFTER UPDATE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `system_schedules_after_delete` -AFTER DELETE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL UNIQUE, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL UNIQUE, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL UNIQUE, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `identities_after_update` -AFTER UPDATE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `identities_after_delete` -AFTER DELETE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `access_controls_after_update` -AFTER UPDATE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `access_controls_after_delete` -AFTER DELETE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -DELIMITER $$ - -CREATE TRIGGER `remote_activities_after_update` -AFTER UPDATE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `remote_activities_after_delete` -AFTER DELETE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -DELIMITER $$ - -CREATE TRIGGER `category_types_after_update` -AFTER UPDATE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `category_types_after_delete` -AFTER DELETE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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_categories_to_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `category_types` (`id`), - CONSTRAINT `fk_categories_to_categories` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `categories_after_update` -AFTER UPDATE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `categories_after_delete` -AFTER DELETE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL, - `github` VARCHAR(512) 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_users_to_identities` FOREIGN KEY (`id`) REFERENCES `identities` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `users_after_update` -AFTER UPDATE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `users_after_delete` -AFTER DELETE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_incoming_activities_after_update` -AFTER UPDATE -ON `activity_pub_incoming_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_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 `greatape_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_outgoing_activities_after_update` -AFTER UPDATE -ON `activity_pub_outgoing_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_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 `greatape_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_followers_after_update` -AFTER UPDATE -ON `activity_pub_followers` FOR EACH ROW -BEGIN - INSERT INTO `greatape_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 `greatape_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Initialization -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -# Identities -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (0, 'INVALID', '0', false, '', '', '', 'invalid@localhost', false, '', '', '', '0', b'0', '', '', '', '', 0, 0, 0, 0); -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (1, 'root', '1', false, '', '', '', 'root@localhost', false, '', '', '', '1', b'1', '', '', '', '', 0xFFFFFFFF, 0, 0, 0); - -# Users -INSERT INTO `users` (`id`, `github`) VALUES (0, ''); -INSERT INTO `users` (`id`, `github`) VALUES (1, ''); - -# CategoryTypes -INSERT INTO `category_types` (`id`, `description`) VALUES (0, 'INVALID'); - -# Categories -INSERT INTO `categories` (`id`, `category_type_id`, `category_id`, `title`, `description`) VALUES (0, 0, 0, 'INVALID', ''); diff --git a/components/scripts/ddl/staging.sql b/components/scripts/ddl/staging.sql deleted file mode 100644 index af155b5..0000000 --- a/components/scripts/ddl/staging.sql +++ /dev/null @@ -1,843 +0,0 @@ -DROP DATABASE IF EXISTS `greatape_staging_history`; -CREATE DATABASE `greatape_staging_history` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_staging_history`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `content` 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `github` VARCHAR(512) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ══════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -DROP DATABASE IF EXISTS `greatape_staging`; -CREATE DATABASE `greatape_staging` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_staging`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL, - `content` 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`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `documents_after_update` -AFTER UPDATE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `documents_after_delete` -AFTER DELETE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -DELIMITER $$ - -CREATE TRIGGER `system_schedules_after_update` -AFTER UPDATE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `system_schedules_after_delete` -AFTER DELETE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL UNIQUE, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL UNIQUE, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL UNIQUE, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `identities_after_update` -AFTER UPDATE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `identities_after_delete` -AFTER DELETE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `access_controls_after_update` -AFTER UPDATE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `access_controls_after_delete` -AFTER DELETE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -DELIMITER $$ - -CREATE TRIGGER `remote_activities_after_update` -AFTER UPDATE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `remote_activities_after_delete` -AFTER DELETE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -DELIMITER $$ - -CREATE TRIGGER `category_types_after_update` -AFTER UPDATE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `category_types_after_delete` -AFTER DELETE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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_categories_to_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `category_types` (`id`), - CONSTRAINT `fk_categories_to_categories` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `categories_after_update` -AFTER UPDATE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `categories_after_delete` -AFTER DELETE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL, - `github` VARCHAR(512) 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_users_to_identities` FOREIGN KEY (`id`) REFERENCES `identities` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `users_after_update` -AFTER UPDATE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `users_after_delete` -AFTER DELETE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_incoming_activities_after_update` -AFTER UPDATE -ON `activity_pub_incoming_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_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 `greatape_staging_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_outgoing_activities_after_update` -AFTER UPDATE -ON `activity_pub_outgoing_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_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 `greatape_staging_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_followers_after_update` -AFTER UPDATE -ON `activity_pub_followers` FOR EACH ROW -BEGIN - INSERT INTO `greatape_staging_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 `greatape_staging_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Initialization -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -# Identities -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (0, 'INVALID', '0', false, '', '', '', 'invalid@localhost', false, '', '', '', '0', b'0', '', '', '', '', 0, 0, 0, 0); -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (1, 'root', '1', false, '', '', '', 'root@localhost', false, '', '', '', '1', b'1', '', '', '', '', 0xFFFFFFFF, 0, 0, 0); - -# Users -INSERT INTO `users` (`id`, `github`) VALUES (0, ''); -INSERT INTO `users` (`id`, `github`) VALUES (1, ''); - -# CategoryTypes -INSERT INTO `category_types` (`id`, `description`) VALUES (0, 'INVALID'); - -# Categories -INSERT INTO `categories` (`id`, `category_type_id`, `category_id`, `title`, `description`) VALUES (0, 0, 0, 'INVALID', ''); diff --git a/components/scripts/ddl/test.sql b/components/scripts/ddl/test.sql deleted file mode 100644 index 9c505bf..0000000 --- a/components/scripts/ddl/test.sql +++ /dev/null @@ -1,843 +0,0 @@ -DROP DATABASE IF EXISTS `greatape_test_history`; -CREATE DATABASE `greatape_test_history` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_test_history`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `content` 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL AUTO_INCREMENT, - `action` VARCHAR(16) NOT NULL, - `original_id` BIGINT NOT NULL, - `github` VARCHAR(512) 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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -# ══════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -DROP DATABASE IF EXISTS `greatape_test`; -CREATE DATABASE `greatape_test` CHARSET = `utf8mb4` COLLATE = `utf8mb4_unicode_ci`; -USE `greatape_test`; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Documents -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `documents` -( - `id` BIGINT NOT NULL, - `content` 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`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `documents_after_update` -AFTER UPDATE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `documents_after_delete` -AFTER DELETE -ON `documents` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`documents`(`action`, `original_id`, `content`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`content`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ SystemSchedules -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `system_schedules` -( - `id` BIGINT NOT NULL, - `enabled` BIT(1) NOT NULL, - `config` VARCHAR(1024) 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`; - -DELIMITER $$ - -CREATE TRIGGER `system_schedules_after_update` -AFTER UPDATE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `system_schedules_after_delete` -AFTER DELETE -ON `system_schedules` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`system_schedules`(`action`, `original_id`, `enabled`, `config`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`enabled`, `old`.`config`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Identities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `identities` -( - `id` BIGINT NOT NULL, - `username` VARCHAR(32) NOT NULL UNIQUE, - `phone_number` VARCHAR(12) NOT NULL, - `phone_number_confirmed` BIT(1) NOT NULL, - `first_name` VARCHAR(128) NOT NULL, - `last_name` VARCHAR(128) NOT NULL, - `display_name` VARCHAR(128) NOT NULL, - `email` VARCHAR(128) NOT NULL UNIQUE, - `email_confirmed` BIT(1) NOT NULL, - `avatar` VARCHAR(512) NOT NULL, - `banner` VARCHAR(512) NOT NULL, - `summary` VARCHAR(512) NOT NULL, - `token` VARCHAR(256) NOT NULL UNIQUE, - `multi_factor` BIT(1) NOT NULL, - `hash` VARCHAR(256) NOT NULL, - `salt` VARCHAR(64) NOT NULL, - `public_key` VARCHAR(4096) NOT NULL, - `private_key` VARCHAR(4096) NOT NULL, - `permission` BIGINT UNSIGNED NOT NULL, - `restriction` INT UNSIGNED NOT NULL, - `last_login` BIGINT NOT NULL, - `login_count` INT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `identities_after_update` -AFTER UPDATE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `identities_after_delete` -AFTER DELETE -ON `identities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`identities`(`action`, `original_id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`username`, `old`.`phone_number`, `old`.`phone_number_confirmed`, `old`.`first_name`, `old`.`last_name`, `old`.`display_name`, `old`.`email`, `old`.`email_confirmed`, `old`.`avatar`, `old`.`banner`, `old`.`summary`, `old`.`token`, `old`.`multi_factor`, `old`.`hash`, `old`.`salt`, `old`.`public_key`, `old`.`private_key`, `old`.`permission`, `old`.`restriction`, `old`.`last_login`, `old`.`login_count`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ AccessControls -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `access_controls` -( - `id` BIGINT NOT NULL, - `key` BIGINT UNSIGNED NOT NULL, - `value` BIGINT UNSIGNED 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`; - -DELIMITER $$ - -CREATE TRIGGER `access_controls_after_update` -AFTER UPDATE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `access_controls_after_delete` -AFTER DELETE -ON `access_controls` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`access_controls`(`action`, `original_id`, `key`, `value`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`key`, `old`.`value`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ RemoteActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `remote_activities` -( - `id` BIGINT NOT NULL, - `entry_point` VARCHAR(256) NOT NULL, - `duration` BIGINT NOT NULL, - `successful` BIT(1) NOT NULL, - `error_message` VARCHAR(1024) NOT NULL, - `remote_address` VARCHAR(128) NOT NULL, - `user_agent` VARCHAR(512) NOT NULL, - `event_type` INT UNSIGNED NOT NULL, - `timestamp` BIGINT 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`; - -DELIMITER $$ - -CREATE TRIGGER `remote_activities_after_update` -AFTER UPDATE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `remote_activities_after_delete` -AFTER DELETE -ON `remote_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`remote_activities`(`action`, `original_id`, `entry_point`, `duration`, `successful`, `error_message`, `remote_address`, `user_agent`, `event_type`, `timestamp`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`entry_point`, `old`.`duration`, `old`.`successful`, `old`.`error_message`, `old`.`remote_address`, `old`.`user_agent`, `old`.`event_type`, `old`.`timestamp`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ CategoryTypes -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `category_types` -( - `id` BIGINT NOT NULL, - `description` VARCHAR(64) 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`; - -DELIMITER $$ - -CREATE TRIGGER `category_types_after_update` -AFTER UPDATE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `category_types_after_delete` -AFTER DELETE -ON `category_types` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`category_types`(`action`, `original_id`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Categories -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `categories` -( - `id` BIGINT NOT NULL, - `category_type_id` BIGINT NOT NULL, - `category_id` BIGINT NOT NULL, - `title` VARCHAR(64) NOT NULL, - `description` VARCHAR(64) 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_categories_to_category_types` FOREIGN KEY (`category_type_id`) REFERENCES `category_types` (`id`), - CONSTRAINT `fk_categories_to_categories` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `categories_after_update` -AFTER UPDATE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `categories_after_delete` -AFTER DELETE -ON `categories` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`categories`(`action`, `original_id`, `category_type_id`, `category_id`, `title`, `description`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`category_type_id`, `old`.`category_id`, `old`.`title`, `old`.`description`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Users -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -CREATE TABLE `users` -( - `id` BIGINT NOT NULL, - `github` VARCHAR(512) 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_users_to_identities` FOREIGN KEY (`id`) REFERENCES `identities` (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = `utf8mb4` - COLLATE = `utf8mb4_unicode_ci`; - -DELIMITER $$ - -CREATE TRIGGER `users_after_update` -AFTER UPDATE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('update', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -CREATE TRIGGER `users_after_delete` -AFTER DELETE -ON `users` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_history`.`users`(`action`, `original_id`, `github`, `editor`, `status`, `sort_order`, `queued_at`, `created_at`, `updated_at`, `payload`) - VALUES('delete', `old`.`id`, `old`.`github`, `old`.`editor`, `old`.`status`, `old`.`sort_order`, `old`.`queued_at`, `old`.`created_at`, `old`.`updated_at`, `old`.`payload`); -END$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubIncomingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_incoming_activities_after_update` -AFTER UPDATE -ON `activity_pub_incoming_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_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 `greatape_test_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubOutgoingActivities -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_outgoing_activities_after_update` -AFTER UPDATE -ON `activity_pub_outgoing_activities` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_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 `greatape_test_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ ActivityPubFollowers -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -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`; - -DELIMITER $$ - -CREATE TRIGGER `activity_pub_followers_after_update` -AFTER UPDATE -ON `activity_pub_followers` FOR EACH ROW -BEGIN - INSERT INTO `greatape_test_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 `greatape_test_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$$ - -DELIMITER ; - -# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════ -# ║ Initialization -# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════ - -# Identities -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (0, 'INVALID', '0', false, '', '', '', 'invalid@localhost', false, '', '', '', '0', b'0', '', '', '', '', 0, 0, 0, 0); -INSERT INTO `identities` (`id`, `username`, `phone_number`, `phone_number_confirmed`, `first_name`, `last_name`, `display_name`, `email`, `email_confirmed`, `avatar`, `banner`, `summary`, `token`, `multi_factor`, `hash`, `salt`, `public_key`, `private_key`, `permission`, `restriction`, `last_login`, `login_count`) VALUES (1, 'root', '1', false, '', '', '', 'root@localhost', false, '', '', '', '1', b'1', '', '', '', '', 0xFFFFFFFF, 0, 0, 0); - -# Users -INSERT INTO `users` (`id`, `github`) VALUES (0, ''); -INSERT INTO `users` (`id`, `github`) VALUES (1, ''); - -# CategoryTypes -INSERT INTO `category_types` (`id`, `description`) VALUES (0, 'INVALID'); - -# Categories -INSERT INTO `categories` (`id`, `category_type_id`, `category_id`, `title`, `description`) VALUES (0, 0, 0, 'INVALID', '');