-- Foundation : système Plugin Karbé

CREATE TABLE "Plugin" (
  "key" TEXT PRIMARY KEY,
  "name" TEXT NOT NULL,
  "description" TEXT NOT NULL,
  "category" TEXT NOT NULL,
  "version" TEXT NOT NULL DEFAULT '0.1.0',
  "enabled" BOOLEAN NOT NULL DEFAULT false,
  "config" JSONB NOT NULL DEFAULT '{}',
  "migrationsApplied" TEXT[] NOT NULL DEFAULT ARRAY[]::TEXT[],
  "installedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
  "updatedAt" TIMESTAMP(3) NOT NULL,
  "lastEnabledAt" TIMESTAMP(3),
  "lastDisabledAt" TIMESTAMP(3)
);

CREATE INDEX "Plugin_category_idx" ON "Plugin" ("category");
CREATE INDEX "Plugin_enabled_idx" ON "Plugin" ("enabled");
