pub async fn initialize_metadata_system(pool: &Pool<MySql>) -> Result<()>
Expand description
Initializes the metadata system, ensuring the table exists and is clean.
This function provides a safe way to initialize the metadata system by:
- Creating the metadata table if it doesn’t exist
- Cleaning up any duplicate keys that might exist
It’s designed to be called during application startup to ensure the metadata system is in a consistent state before it’s used.
§Arguments
pool
- Database connection pool for executing the query
§Returns
Ok(())
- Successfully initialized the metadata systemErr(anyhow::Error)
- Failed to initialize the metadata system
§Concurrency
This function acquires the global metadata mutex to ensure thread safety during initialization.
§Warning
If duplicate keys are found and cleaned up during initialization, an error is logged as this could indicate issues with the application’s use of the metadata API.