Пример #1
0
    protected override IEnumerable <Command> OnAlter(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
    {
        var otherRole = FindOtherChecked(targetMetadata.MetadataRoles.Roles, RoleName, "role");

        if (EquatableHelper.PropertiesEqual(this, otherRole, EquatableProperties, nameof(RoleFlag), nameof(SystemPrivileges)))
        {
            if (EquatableHelper.PropertiesEqual(this, otherRole, EquatableProperties, nameof(RoleFlag)))
            {
                yield return(new Command()
                             .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} {(RoleFlag.HasFlag(RoleFlagType.RoleFlagMayTrust) ? "SET" : "DROP")} AUTO ADMIN MAPPING"));
            }
            if (EquatableHelper.PropertiesEqual(this, otherRole, EquatableProperties, nameof(SystemPrivileges)))
            {
                var systemPrivileges = SystemPrivileges?.ToPrivileges() ?? Enumerable.Empty <string>();
                if (systemPrivileges.Any())
                {
                    yield return(new Command()
                                 .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} SET SYSTEM PRIVILEGES TO {string.Join(", ", systemPrivileges)}"));
                }
                else
                {
                    yield return(new Command()
                                 .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} DROP SYSTEM PRIVILEGES"));
                }
            }
        }
        else
        {
            throw new NotSupportedOnFirebirdException($"Altering role is not supported ({RoleName}).");
        }
    }
Пример #2
0
        protected override IEnumerable <Command> OnCreate(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
        {
            yield return(new Command()
                         .Append($"CREATE ROLE {RoleName.AsSqlIndentifier()}"));

            if (RoleFlag.HasFlag(RoleFlagType.RoleFlagMayTrust))
            {
                yield return(new Command()
                             .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} SET AUTO ADMIN MAPPING"));
            }
        }
Пример #3
0
        protected override IEnumerable <Command> OnAlter(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
        {
            var otherRole = FindOtherChecked(targetMetadata.MetadataRoles.Roles, RoleName, "role");

            if (EquatableHelper.PropertiesEqual(this, otherRole, EquatableProperties, nameof(RoleFlag)))
            {
                yield return(new Command()
                             .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} {(RoleFlag.HasFlag(RoleFlagType.RoleFlagMayTrust) ? "SET" : "DROP")} AUTO ADMIN MAPPING"));
            }
            else
            {
                throw new NotSupportedOnFirebirdException($"Altering role is not supported ({RoleName}).");
            }
        }
Пример #4
0
    protected override IEnumerable <Command> OnCreate(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
    {
        var command = new Command()
                      .Append($"CREATE ROLE {RoleName.AsSqlIndentifier()}");
        var systemPrivileges = SystemPrivileges?.ToPrivileges() ?? Enumerable.Empty <string>();

        if (systemPrivileges.Any())
        {
            command.Append($" SET SYSTEM PRIVILEGES TO {string.Join(", ", systemPrivileges)}");
        }
        yield return(command);

        if (RoleFlag.HasFlag(RoleFlagType.RoleFlagMayTrust))
        {
            yield return(new Command()
                         .Append($"ALTER ROLE {RoleName.AsSqlIndentifier()} SET AUTO ADMIN MAPPING"));
        }
    }
Пример #5
0
 protected override IEnumerable <Command> OnDrop(IMetadata sourceMetadata, IMetadata targetMetadata, IComparerContext context)
 {
     yield return(new Command().Append($"DROP ROLE {RoleName.AsSqlIndentifier()}"));
 }