shinkan-jinkendo/backend/migrations/018_wiki_import_tracking.sql
Lars 6801c60604
Some checks failed
Deploy Development / deploy (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Failing after 1m55s
feat: Add MediaWiki import functionality with tracking and mapping
- Implemented a new SQL migration for wiki import tracking tables.
- Created an import router for handling MediaWiki imports of exercises, skills, and methods.
- Developed a Semantic MediaWiki API client for direct API interactions.
- Added a mapper to convert SMW properties to local database fields.
- Introduced background tasks for asynchronous import processing.
- Implemented logging and error handling for import operations.
- Added endpoints for previewing imports, checking import status, and managing import references.
2026-04-24 14:41:52 +02:00

41 lines
1.9 KiB
SQL

-- Migration 018: MediaWiki Import Tracking Tables
-- Tracks import runs and cross-references between Wiki pages and local DB entries
CREATE TABLE IF NOT EXISTS wiki_import_log (
id SERIAL PRIMARY KEY,
import_type VARCHAR(50) NOT NULL
CHECK (import_type IN ('exercise', 'skill', 'method', 'maturity_model')),
import_status VARCHAR(20) NOT NULL DEFAULT 'running'
CHECK (import_status IN ('running', 'completed', 'failed')),
category VARCHAR(200), -- Wiki category name used
dry_run BOOLEAN DEFAULT false,
reimport BOOLEAN DEFAULT false,
items_total INT DEFAULT 0,
items_imported INT DEFAULT 0,
items_skipped INT DEFAULT 0,
items_failed INT DEFAULT 0,
error_log JSONB DEFAULT '[]'::jsonb, -- [{item, error}, ...]
imported_by INT REFERENCES profiles(id),
started_at TIMESTAMP DEFAULT NOW(),
finished_at TIMESTAMP,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE TABLE IF NOT EXISTS wiki_import_references (
id SERIAL PRIMARY KEY,
wiki_page_title VARCHAR(500) NOT NULL,
wiki_page_id INT, -- MediaWiki internal page ID
content_type VARCHAR(50) NOT NULL
CHECK (content_type IN ('exercise', 'skill', 'method', 'maturity_model')),
local_id INT NOT NULL, -- ID in the local DB table
last_imported TIMESTAMP DEFAULT NOW(),
created_at TIMESTAMP DEFAULT NOW(),
UNIQUE(wiki_page_title, content_type)
);
CREATE INDEX IF NOT EXISTS idx_wiki_refs_title ON wiki_import_references(wiki_page_title);
CREATE INDEX IF NOT EXISTS idx_wiki_refs_type ON wiki_import_references(content_type);
CREATE INDEX IF NOT EXISTS idx_wiki_log_status ON wiki_import_log(import_status);
CREATE INDEX IF NOT EXISTS idx_wiki_log_type ON wiki_import_log(import_type);