ALTER TABLE kb_articles ADD COLUMN article_group_id TEXT NULL;

ALTER TABLE kb_articles ADD COLUMN language TEXT NULL DEFAULT 'ru';

UPDATE kb_articles
SET language = 'ru'
WHERE language IS NULL OR TRIM(language) = '';

UPDATE kb_articles
SET article_group_id = article_id
WHERE article_group_id IS NULL OR TRIM(article_group_id) = '';

CREATE INDEX IF NOT EXISTS idx_kb_articles_article_group_id ON kb_articles (article_group_id);

CREATE INDEX IF NOT EXISTS idx_kb_articles_language ON kb_articles (language);
