Search code examples
sql-serverredgate

Redgate SQL Source Control: ignoring Database Roles


I'm using Redgate Source Control to changetrack a database. I have a testing database from which I commit, and a production database which is the final target.

I want to have a different Database Role (the setting found of Database->Security->Roles->Database Roles) in the production database because of specific requirements. I have changed one database on my production server, but every time I deploy to the production database, the Database Role resets to the status it was before I changed it (even though the specific role is not synced).

I found a filter on Comparison Options for user roles and checked the Ignore: "User's permissions and role memberships" and deployed the filter, but the Database role still resets every time I deploy any change to production. enter image description here

Is there a way to ignore Database roles or is there a workaround I could use?

EDIT: Larnu's answer is correct. I had a separate issue here which had to do with the role permissions not being defined in the role, but in the schema.sql file. So I had to commit the whole schema to get the role permissions committed.


Solution

  • In SQL Source Control, there is an option for ignoring roles entirely (or using a rule to ignore certain ones).

    Select your source controlled database in the Object Explorer, and then click SQL Source Control in your toolbar. Go to the Setup Page, and then select "Edit filter rules".

    Then simply untick Role and the Roles won't be source controlled any more, or you can add rules to exclude/include roles that meet said rule(s). Note you may need to remove the Role details from your Source Control repository as well, as otherwise the position of the role when you stopped Source Controlling it may be used (I suggest checking).

    Edit Filter Rules Screen