|
| 1 | +-- CreateEnum |
| 2 | +CREATE TYPE "OutboxEventStatus" AS ENUM ('pending', 'publishing', 'published', 'dead_letter'); |
| 3 | + |
| 4 | +-- CreateEnum |
| 5 | +CREATE TYPE "PluginStatus" AS ENUM ('installed', 'enabled', 'disabled', 'error'); |
| 6 | + |
| 7 | +-- CreateTable |
| 8 | +CREATE TABLE "outbox_events" ( |
| 9 | + "id" TEXT NOT NULL, |
| 10 | + "aggregate_type" TEXT NOT NULL, |
| 11 | + "aggregate_id" TEXT NOT NULL, |
| 12 | + "event_type" TEXT NOT NULL, |
| 13 | + "payload" JSONB NOT NULL, |
| 14 | + "status" "OutboxEventStatus" NOT NULL DEFAULT 'pending', |
| 15 | + "attempts" INTEGER NOT NULL DEFAULT 0, |
| 16 | + "last_error" TEXT, |
| 17 | + "published_at" TIMESTAMP(3), |
| 18 | + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 19 | + "updated_at" TIMESTAMP(3) NOT NULL, |
| 20 | + |
| 21 | + CONSTRAINT "outbox_events_pkey" PRIMARY KEY ("id") |
| 22 | +); |
| 23 | + |
| 24 | +-- CreateTable |
| 25 | +CREATE TABLE "plugins" ( |
| 26 | + "id" TEXT NOT NULL, |
| 27 | + "name" TEXT NOT NULL, |
| 28 | + "version" TEXT NOT NULL, |
| 29 | + "source" TEXT NOT NULL, |
| 30 | + "status" "PluginStatus" NOT NULL DEFAULT 'installed', |
| 31 | + "compatibility" JSONB NOT NULL, |
| 32 | + "health" JSONB NOT NULL, |
| 33 | + "installed_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 34 | + "updated_at" TIMESTAMP(3) NOT NULL, |
| 35 | + "disabled_at" TIMESTAMP(3), |
| 36 | + |
| 37 | + CONSTRAINT "plugins_pkey" PRIMARY KEY ("id") |
| 38 | +); |
| 39 | + |
| 40 | +-- CreateTable |
| 41 | +CREATE TABLE "plugin_configs" ( |
| 42 | + "id" TEXT NOT NULL, |
| 43 | + "plugin_id" TEXT NOT NULL, |
| 44 | + "environment" TEXT NOT NULL DEFAULT 'default', |
| 45 | + "config" JSONB NOT NULL, |
| 46 | + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 47 | + "updated_at" TIMESTAMP(3) NOT NULL, |
| 48 | + |
| 49 | + CONSTRAINT "plugin_configs_pkey" PRIMARY KEY ("id") |
| 50 | +); |
| 51 | + |
| 52 | +-- CreateTable |
| 53 | +CREATE TABLE "plugin_audit_logs" ( |
| 54 | + "id" TEXT NOT NULL, |
| 55 | + "plugin_id" TEXT NOT NULL, |
| 56 | + "actor_id" TEXT, |
| 57 | + "action" TEXT NOT NULL, |
| 58 | + "details" JSONB, |
| 59 | + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 60 | + |
| 61 | + CONSTRAINT "plugin_audit_logs_pkey" PRIMARY KEY ("id") |
| 62 | +); |
| 63 | + |
| 64 | +-- CreateIndex |
| 65 | +CREATE INDEX "outbox_events_status_created_at_idx" ON "outbox_events"("status", "created_at"); |
| 66 | + |
| 67 | +-- CreateIndex |
| 68 | +CREATE INDEX "outbox_events_aggregate_type_aggregate_id_idx" ON "outbox_events"("aggregate_type", "aggregate_id"); |
| 69 | + |
| 70 | +-- CreateIndex |
| 71 | +CREATE INDEX "outbox_events_event_type_idx" ON "outbox_events"("event_type"); |
| 72 | + |
| 73 | +-- CreateIndex |
| 74 | +CREATE INDEX "outbox_events_published_at_idx" ON "outbox_events"("published_at"); |
| 75 | + |
| 76 | +-- CreateIndex |
| 77 | +CREATE UNIQUE INDEX "plugins_name_key" ON "plugins"("name"); |
| 78 | + |
| 79 | +-- CreateIndex |
| 80 | +CREATE INDEX "plugins_status_idx" ON "plugins"("status"); |
| 81 | + |
| 82 | +-- CreateIndex |
| 83 | +CREATE INDEX "plugins_name_version_idx" ON "plugins"("name", "version"); |
| 84 | + |
| 85 | +-- CreateIndex |
| 86 | +CREATE UNIQUE INDEX "plugin_configs_plugin_id_environment_key" ON "plugin_configs"("plugin_id", "environment"); |
| 87 | + |
| 88 | +-- CreateIndex |
| 89 | +CREATE INDEX "plugin_audit_logs_plugin_id_created_at_idx" ON "plugin_audit_logs"("plugin_id", "created_at"); |
| 90 | + |
| 91 | +-- AddForeignKey |
| 92 | +ALTER TABLE "plugin_configs" ADD CONSTRAINT "plugin_configs_plugin_id_fkey" FOREIGN KEY ("plugin_id") REFERENCES "plugins"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
| 93 | + |
| 94 | +-- AddForeignKey |
| 95 | +ALTER TABLE "plugin_audit_logs" ADD CONSTRAINT "plugin_audit_logs_plugin_id_fkey" FOREIGN KEY ("plugin_id") REFERENCES "plugins"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
0 commit comments