paperclip-forgejo-issue-plugin/migrations/001_initial.sql

75 lines
2.5 KiB
MySQL
Raw Normal View History

CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.forgejo_sync_state (
2026-06-02 02:57:49 +00:00
key text PRIMARY KEY,
value jsonb NOT NULL DEFAULT '{}'::jsonb,
updated_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.webhook_deliveries (
2026-06-02 02:57:49 +00:00
request_id text PRIMARY KEY,
delivery_key text NOT NULL,
event_name text NOT NULL,
company_id uuid NOT NULL,
payload jsonb NOT NULL,
status text NOT NULL,
received_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.issue_mappings (
2026-06-02 02:57:49 +00:00
company_id uuid NOT NULL,
paperclip_issue_id uuid NOT NULL,
forgejo_issue_id bigint,
forgejo_issue_number integer,
forgejo_issue_url text,
forgejo_api_url text,
repo_owner text NOT NULL,
repo_name text NOT NULL,
2026-06-02 02:57:49 +00:00
dedupe_key text NOT NULL,
source_title text NOT NULL,
source_body text NOT NULL,
2026-06-02 02:57:49 +00:00
attachment_metadata jsonb NOT NULL DEFAULT '[]'::jsonb,
manual_review_required boolean NOT NULL DEFAULT false,
review_reason_code text,
sync_status text NOT NULL DEFAULT 'pending',
last_error text,
created_at timestamptz NOT NULL DEFAULT now(),
2026-06-02 02:57:49 +00:00
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (company_id, paperclip_issue_id)
2026-06-02 02:57:49 +00:00
);
CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.comment_mappings (
2026-06-02 02:57:49 +00:00
company_id uuid NOT NULL,
source_id text NOT NULL,
dedupe_key text NOT NULL,
title text,
body text NOT NULL,
attachment_metadata jsonb NOT NULL DEFAULT '[]'::jsonb,
manual_review_required boolean NOT NULL DEFAULT false,
review_reason_code text,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (company_id, source_id)
);
CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.review_queue (
2026-06-02 02:57:49 +00:00
company_id uuid NOT NULL,
source_kind text NOT NULL,
source_id text NOT NULL,
dedupe_key text NOT NULL,
review_reason_code text NOT NULL,
review_payload jsonb NOT NULL,
status text NOT NULL DEFAULT 'pending',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (company_id, source_kind, source_id)
);
CREATE TABLE plugin_private_adoption_forgejo_issue_sync_5fd4e14106.reconciliation_runs (
2026-06-02 02:57:49 +00:00
id bigserial PRIMARY KEY,
completed_at timestamptz NOT NULL,
trigger text NOT NULL,
pending_reviews integer NOT NULL,
pending_deliveries integer NOT NULL,
mapped_issues integer NOT NULL,
mapped_comments integer NOT NULL,
snapshot jsonb NOT NULL
);