initialize_waffle
Initialize Waffle flags and switches.
- class smarter.apps.api.management.commands.initialize_waffle.Command(*args, **kwargs)[source]
Bases:
SmarterCommandManagement command to initialize and synchronize Waffle feature switches for the Smarter platform.
This command ensures that all required Waffle switches, as defined by the Smarter application, are present and correctly initialized in the database. It also removes any orphaned switches that are no longer needed, maintaining a clean and consistent feature flag environment.
Key Features and Workflow:
Iterates through the list of expected switches and creates any that are missing, defaulting them to the “off” state.
Verifies the existence of each switch, providing feedback for each verification or creation.
Identifies and deletes orphaned switches that are present in the database but not defined in the current application configuration.
In local development environments, enables the
ENABLE_REACTAPP_DEBUG_MODEswitch for enhanced debugging capabilities.
Usage:
This command is intended to be run during deployment, environment setup, or whenever the set of feature switches may have changed. It helps prevent configuration drift and ensures that feature flags are always in sync with the application’s requirements.
Error Handling and Output:
Provides clear console output for each switch that is verified, created, or deleted.
Handles all operations atomically to avoid partial updates or inconsistent states.
Intended Audience:
Developers, system administrators, and DevOps engineers responsible for managing feature flags and application configuration in Smarter environments. This command is especially useful for onboarding new environments or cleaning up after configuration changes.
See also
waffle.models.Switch- The Django Waffle model representing feature switches.smarter.lib.django.waffle.SmarterWaffleSwitches- The class defining all Smarter-specific Waffle switches.smarter.common.conf.settings.smarter_settings- The Smarter settings module for environment detection.