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

package v1_27

import (
	"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/timeutil"

	"xorm.io/xorm"
)

type orgProtectedBranch struct {
	ID                            int64              `xorm:"pk autoincr"`
	OrgID                         int64              `xorm:"UNIQUE(s) index"`
	RuleName                      string             `xorm:"UNIQUE(s)"`
	Priority                      int64              `xorm:"NOT NULL DEFAULT 0"`
	CanPush                       bool               `xorm:"NOT NULL DEFAULT false"`
	EnableWhitelist               bool               `xorm:"NOT NULL DEFAULT false"`
	WhitelistTeamIDs              []int64            `xorm:"JSON TEXT"`
	EnableMergeWhitelist          bool               `xorm:"NOT NULL DEFAULT false"`
	MergeWhitelistTeamIDs         []int64            `xorm:"JSON TEXT"`
	CanForcePush                  bool               `xorm:"NOT NULL DEFAULT false"`
	EnableForcePushAllowlist      bool               `xorm:"NOT NULL DEFAULT false"`
	ForcePushAllowlistTeamIDs     []int64            `xorm:"JSON TEXT"`
	EnableStatusCheck             bool               `xorm:"NOT NULL DEFAULT false"`
	StatusCheckContexts           []string           `xorm:"JSON TEXT"`
	RequiredApprovals             int64              `xorm:"NOT NULL DEFAULT 0"`
	EnableApprovalsWhitelist      bool               `xorm:"NOT NULL DEFAULT false"`
	ApprovalsWhitelistTeamIDs     []int64            `xorm:"JSON TEXT"`
	BlockOnRejectedReviews        bool               `xorm:"NOT NULL DEFAULT false"`
	BlockOnOfficialReviewRequests bool               `xorm:"NOT NULL DEFAULT false"`
	BlockOnOutdatedBranch         bool               `xorm:"NOT NULL DEFAULT false"`
	DismissStaleApprovals         bool               `xorm:"NOT NULL DEFAULT false"`
	IgnoreStaleApprovals          bool               `xorm:"NOT NULL DEFAULT false"`
	RequireSignedCommits          bool               `xorm:"NOT NULL DEFAULT false"`
	ProtectedFilePatterns         string             `xorm:"TEXT"`
	UnprotectedFilePatterns       string             `xorm:"TEXT"`
	BlockAdminMergeOverride       bool               `xorm:"NOT NULL DEFAULT false"`
	CreatedUnix                   timeutil.TimeStamp `xorm:"created"`
	UpdatedUnix                   timeutil.TimeStamp `xorm:"updated"`
}

func (orgProtectedBranch) TableName() string {
	return "org_protected_branch"
}

// AddOrgProtectedBranchTable creates the org_protected_branch table.
func AddOrgProtectedBranchTable(x *xorm.Engine) error {
	return x.Sync(new(orgProtectedBranch))
}
