// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package v1_26

import (
	"code.gitea.io/gitea/modules/timeutil"

	"xorm.io/xorm"
)

// AddWikiIndexTable adds the wiki_index table for full-text search
func AddWikiIndexTable(x *xorm.Engine) error {
	type WikiIndex struct {
		ID          int64              `xorm:"pk autoincr"`
		RepoID      int64              `xorm:"INDEX NOT NULL"`
		PageName    string             `xorm:"VARCHAR(255) NOT NULL"`
		PagePath    string             `xorm:"VARCHAR(512) NOT NULL"`
		Title       string             `xorm:"VARCHAR(255)"`
		Content     string             `xorm:"LONGTEXT"`
		ContentHash string             `xorm:"VARCHAR(64)"`
		CommitSHA   string             `xorm:"VARCHAR(64)"`
		WordCount   int                `xorm:"DEFAULT 0"`
		LinksOut    string             `xorm:"TEXT"`
		UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
		CreatedUnix timeutil.TimeStamp `xorm:"created"`
	}

	return x.Sync(new(WikiIndex))
}
