package migrations

import (
	"github.com/forgeo/forgebucket/internal/models"
	"xorm.io/xorm"
)

// Run011 adds the workspace and workspace_member tables and adds the nullable
// workspace_id column to the repository table to support workspace-owned repos.
func Run011(engine *xorm.Engine) error {
	if err := engine.Sync2(
		&models.Workspace{},
		&models.WorkspaceMember{},
	); err != nil {
		return err
	}
	// Sync2 on Repository will add the new workspace_id column to existing rows
	// (default NULL, meaning existing repos remain user-owned).
	return engine.Sync2(&models.Repository{})
}
