text: # Generated by Django 3.1.6 on 2021-02-09 16:57
  from django.apps.registry import Apps
  from django.db import migrations, models
  from django.db.backends.base.schema import BaseDatabaseSchemaEditor
  
  
  def token_view_to_secret_view(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
      from authentik.events.models import EventAction
  
      db_alias = schema_editor.connection.alias
      Event = apps.get_model("authentik_events", "Event")
  
      events = Event.objects.using(db_alias).filter(action="token_view")
  
      for event in events:
          event.context["secret"] = event.context.pop("token")
          event.action = EventAction.SECRET_VIEW
  
      Event.objects.using(db_alias).bulk_update(events, ["context", "action"])
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ("authentik_events", "0012_auto_20210202_1821"),
      ]
  
      operations = [
          migrations.AlterField(
              model_name="event",
              name="action",
              field=models.TextField(
                  choices=[
                      ("login", "Login"),
                      ("login_failed", "Login Failed"),
                      ("logout", "Logout"),
                      ("user_write", "User Write"),
                      ("suspicious_request", "Suspicious Request"),
                      ("password_set", "Password Set"),
                      ("secret_view", "Secret View"),
                      ("invitation_used", "Invite Used"),
                      ("authorize_application", "Authorize Application"),
                      ("source_linked", "Source Linked"),
                      ("impersonation_started", "Impersonation Started"),
                      ("impersonation_ended", "Impersonation Ended"),
                      ("policy_execution", "Policy Execution"),
                      ("policy_exception", "Policy Exception"),
                      ("property_mapping_exception", "Property Mapping Exception"),
                      ("system_task_execution", "System Task Execution"),
                      ("system_task_exception", "System Task Exception"),
                      ("configuration_error", "Configuration Error"),
                      ("model_created", "Model Created"),
                      ("model_updated", "Model Updated"),
                      ("model_deleted", "Model Deleted"),
                      ("update_available", "Update Available"),
                      ("custom_", "Custom Prefix"),
                  ]
              ),
          ),
          migrations.RunPython(token_view_to_secret_view),
      ]
  