using Microsoft.EntityFrameworkCore.Migrations;

namespace Tiku.Infrastructure.Persistence.Migrations;

internal static class MigrationBuilderTenantGuardExtensions
{
    public static void EnsureTenantIsolationGuards(this MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(PostgreSqlTenantConstraintSql.DropTenantGuards);
        migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTenantQuestionReferenceGuard);
        migrationBuilder.Sql(PostgreSqlTenantConstraintSql.CreateTaxonomyParentGuard);
    }

    public static void DropTenantIsolationGuards(this MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(PostgreSqlTenantConstraintSql.DropTenantGuards);
    }

    public static void EnsureSaasCatalogGuards(this MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(PostgreSqlSaasCatalogConstraintSql.DropOfferingVersionImmutabilityGuards);
        migrationBuilder.Sql(PostgreSqlSaasCatalogConstraintSql.CreateOfferingVersionImmutabilityGuards);
        migrationBuilder.Sql(PostgreSqlSaasCatalogConstraintSql.CreateOfferingVersionChildrenImmutabilityGuards);
        migrationBuilder.Sql(PostgreSqlSaasCatalogConstraintSql.CreateSubscriptionOfferingTypeGuards);
    }

    public static void DropSaasCatalogGuards(this MigrationBuilder migrationBuilder)
    {
        migrationBuilder.Sql(PostgreSqlSaasCatalogConstraintSql.DropOfferingVersionImmutabilityGuards);
    }
}