mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 01:47:47 +08:00
feat(data): complete portable SQL backend parity
Align MySQL and SQLite schemas, migrations, usage, stats, export, and backfill behavior with the shared data contracts. Extend gateway startup and maintenance support across all SQL drivers.
This commit is contained in:
@@ -764,7 +764,8 @@ impl GatewayDataState {
|
||||
}
|
||||
|
||||
pub(crate) fn has_usage_counter_flush_backend(&self) -> bool {
|
||||
self.has_usage_writer() && self.database_driver() == Some(DatabaseDriver::Postgres)
|
||||
self.has_usage_writer()
|
||||
&& database_driver_supports_usage_counter_flush(self.database_driver())
|
||||
}
|
||||
|
||||
pub(crate) fn has_usage_worker_queue(&self) -> bool {
|
||||
@@ -1075,3 +1076,30 @@ impl GatewayDataState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn database_driver_supports_usage_counter_flush(driver: Option<DatabaseDriver>) -> bool {
|
||||
matches!(
|
||||
driver,
|
||||
Some(DatabaseDriver::Postgres | DatabaseDriver::Mysql | DatabaseDriver::Sqlite)
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod usage_counter_flush_backend_tests {
|
||||
use super::database_driver_supports_usage_counter_flush;
|
||||
use aether_data::DatabaseDriver;
|
||||
|
||||
#[test]
|
||||
fn every_sql_driver_supports_usage_counter_flush() {
|
||||
assert!(database_driver_supports_usage_counter_flush(Some(
|
||||
DatabaseDriver::Postgres
|
||||
)));
|
||||
assert!(database_driver_supports_usage_counter_flush(Some(
|
||||
DatabaseDriver::Mysql
|
||||
)));
|
||||
assert!(database_driver_supports_usage_counter_flush(Some(
|
||||
DatabaseDriver::Sqlite
|
||||
)));
|
||||
assert!(!database_driver_supports_usage_counter_flush(None));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user