--- users-groups-perms

-- Find and drop default constraint name before dropping the column

DECLARE @ConstraintName NVARCHAR(100)
SELECT @ConstraintName = OBJECT_NAME([default_object_id]) FROM SYS.COLUMNS
WHERE [object_id] = OBJECT_ID('user_groups_members') AND [name] = 'role_deleted'
EXEC('ALTER TABLE user_groups_members DROP CONSTRAINT ' + @ConstraintName);

ALTER TABLE user_groups_members
  DROP COLUMN role_deleted;

ALTER TABLE user_groups
  ADD perms_users VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE user_groups
  ADD perms_channels VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE user_groups
  ADD perms_settings VARCHAR(255) NOT NULL DEFAULT '';
