package port

import (
	"context"

	"github.com/orchard9/rdev/internal/domain"
)

// DatabaseProvisioner provisions isolated databases for projects.
// Implementation uses CockroachDB to create per-project databases and users.
type DatabaseProvisioner interface {
	// CreateProjectDatabase provisions an isolated database for a project.
	// Creates a database and user scoped to the project.
	// Returns credentials that should be injected into the project's environment.
	CreateProjectDatabase(ctx context.Context, projectID string) (*domain.DatabaseCredentials, error)

	// DeleteProjectDatabase removes database access for a project.
	// Drops the database and user.
	DeleteProjectDatabase(ctx context.Context, projectID string) error

	// GetProjectDatabase retrieves database credentials for a project.
	// Returns nil if the project has no database provisioned.
	// Note: Password cannot be retrieved, only verified against stored credentials.
	GetProjectDatabase(ctx context.Context, projectID string) (*domain.DatabaseCredentials, error)

	// TestConnection verifies the database provisioner can connect to CockroachDB.
	TestConnection(ctx context.Context) error
}
