Add migration to change environment_roles role column from string to

enum type.
Fix tests and functions affected by the column type change.
This commit is contained in:
leigh-mil
2020-01-08 17:38:55 -05:00
parent bffd981105
commit 17864cc060
14 changed files with 98 additions and 45 deletions

View File

@@ -14,7 +14,7 @@ SERVICE_BRANCHES = [
]
ENV_ROLE_NO_ACCESS = "No Access"
ENV_ROLES = [(role.value, role.value) for role in CSPRole] + [
ENV_ROLES = [(role.name, role.value) for role in CSPRole] + [
(ENV_ROLE_NO_ACCESS, ENV_ROLE_NO_ACCESS)
]

View File

@@ -9,10 +9,9 @@ import atst.models.types as types
class CSPRole(Enum):
BASIC_ACCESS = "Basic Access"
NETWORK_ADMIN = "Network Admin"
BUSINESS_READ = "Business Read-only"
TECHNICAL_READ = "Technical Read-only"
ADMIN = "Admin"
BILLING_READ = "Billing Read-only"
CONTRIBUTOR = "Contributor"
class EnvironmentRole(
@@ -26,7 +25,7 @@ class EnvironmentRole(
)
environment = relationship("Environment")
role = Column(String())
role = Column(SQLAEnum(CSPRole, native_enum=False), nullable=True)
application_role_id = Column(
UUID(as_uuid=True), ForeignKey("application_roles.id"), nullable=False

View File

@@ -99,7 +99,7 @@ def filter_env_roles_form_data(member, environments):
if len(env_roles_set) == 1:
(env_role,) = env_roles_set
env_data["role"] = env_role.role
env_data["role"] = env_role.role.name
env_data["disabled"] = env_role.disabled
env_roles_form_data.append(env_data)