mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 02:47:45 +08:00
refactor(data): remove MySQL and SQLite support
Use PostgreSQL as the only database backend across runtime, schema tooling, installation, Compose, and CI. Update regression tests and reject removed drivers explicitly.
This commit is contained in:
@@ -139,10 +139,6 @@ pub enum DefaultValue {
|
||||
pub struct DriverColumnOverrides {
|
||||
#[serde(default)]
|
||||
pub postgres: Option<DriverColumnOverride>,
|
||||
#[serde(default)]
|
||||
pub mysql: Option<DriverColumnOverride>,
|
||||
#[serde(default)]
|
||||
pub sqlite: Option<DriverColumnOverride>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Deserialize, PartialEq, Eq)]
|
||||
@@ -430,12 +426,6 @@ pub fn generate_sources_to_dir(
|
||||
write_driver_sources(output_root, "postgres", sources, |tables| {
|
||||
dialect::postgres::emit_named_schema(schema, tables)
|
||||
})?;
|
||||
write_driver_sources(output_root, "mysql", sources, |tables| {
|
||||
dialect::mysql::emit_named_schema(schema, tables)
|
||||
})?;
|
||||
write_driver_sources(output_root, "sqlite", sources, |tables| {
|
||||
dialect::sqlite::emit_named_schema(schema, tables)
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -449,12 +439,6 @@ pub fn check_generated_dir(
|
||||
check_driver_sources(output_root, "postgres", &loaded.sources, |tables| {
|
||||
dialect::postgres::emit_named_schema(&loaded.schema, tables)
|
||||
})?;
|
||||
check_driver_sources(output_root, "mysql", &loaded.sources, |tables| {
|
||||
dialect::mysql::emit_named_schema(&loaded.schema, tables)
|
||||
})?;
|
||||
check_driver_sources(output_root, "sqlite", &loaded.sources, |tables| {
|
||||
dialect::sqlite::emit_named_schema(&loaded.schema, tables)
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -688,12 +672,7 @@ fn write_generated_readme(output_root: &Path) -> Result<(), SchemaError> {
|
||||
}
|
||||
|
||||
fn assert_generated_root_files(output_root: &Path) -> Result<(), SchemaError> {
|
||||
let expected = BTreeSet::from([
|
||||
"README.md".to_string(),
|
||||
"mysql".to_string(),
|
||||
"postgres".to_string(),
|
||||
"sqlite".to_string(),
|
||||
]);
|
||||
let expected = BTreeSet::from(["README.md".to_string(), "postgres".to_string()]);
|
||||
let actual = fs::read_dir(output_root)
|
||||
.map_err(|source| SchemaError::Read {
|
||||
path: output_root.to_path_buf(),
|
||||
@@ -774,7 +753,7 @@ fn generated_readme() -> String {
|
||||
bash crates/aether-data/runtime/schema/compose_schema.sh generate\n\
|
||||
```\n\n\
|
||||
Runtime migrations are not loaded from this directory. The executable SQL lives under \
|
||||
`crates/aether-data/adapters/{postgres,mysql,sqlite}/migrations`, and the Postgres bootstrap snapshot \
|
||||
`crates/aether-data/adapters/postgres/migrations`, and the Postgres bootstrap snapshot \
|
||||
is generated at build time from `crates/aether-data/runtime/schema/bootstrap/postgres` into the crate \
|
||||
build output until a generated fragment is deliberately promoted into the driver-specific \
|
||||
schema manifests.\n"
|
||||
@@ -808,7 +787,7 @@ fn write_generated(path: PathBuf, contents: &str) -> Result<(), SchemaError> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::dialect::{mysql, postgres, sqlite};
|
||||
use crate::dialect::postgres;
|
||||
|
||||
fn announcements_schema() -> LogicalSchema {
|
||||
LogicalSchema {
|
||||
@@ -879,42 +858,6 @@ mod tests {
|
||||
assert!(postgres_sql.contains(
|
||||
"CREATE INDEX IF NOT EXISTS announcements_is_active_idx ON public.announcements USING btree (is_active);"
|
||||
));
|
||||
|
||||
let mysql_sql = mysql::emit_schema(&schema);
|
||||
assert!(mysql_sql.contains("`id` VARCHAR(64) NOT NULL"));
|
||||
assert!(mysql_sql.contains("`is_active` TINYINT(1) NOT NULL DEFAULT 1"));
|
||||
assert!(mysql_sql.contains("KEY announcements_is_active_idx (`is_active`)"));
|
||||
|
||||
let sqlite_sql = sqlite::emit_schema(&schema);
|
||||
assert!(sqlite_sql.contains("id TEXT PRIMARY KEY NOT NULL"));
|
||||
assert!(sqlite_sql.contains("is_active INTEGER NOT NULL DEFAULT 1"));
|
||||
assert!(sqlite_sql.contains(
|
||||
"CREATE INDEX IF NOT EXISTS announcements_is_active_idx ON announcements (is_active);"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mysql_column_type_override_can_select_binary_collation() {
|
||||
let mut schema = announcements_schema();
|
||||
schema
|
||||
.tables
|
||||
.get_mut("announcements")
|
||||
.expect("fixture table exists")
|
||||
.columns
|
||||
.first_mut()
|
||||
.expect("fixture id column exists")
|
||||
.driver
|
||||
.mysql = Some(DriverColumnOverride {
|
||||
sql_type: Some(
|
||||
"VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin".to_string(),
|
||||
),
|
||||
default: None,
|
||||
nullable: None,
|
||||
});
|
||||
|
||||
let mysql_sql = mysql::emit_schema(&schema);
|
||||
assert!(mysql_sql
|
||||
.contains("`id` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_bin NOT NULL"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1028,19 +971,8 @@ ALTER TABLE users ADD COLUMN ldap_dn VARCHAR(1024);
|
||||
.and_then(Path::parent)
|
||||
.expect("crate should live under workspace/crates/aether-data");
|
||||
let schema_dir = workspace.join("crates/aether-data/runtime/schema/logical");
|
||||
let mut required_sql_paths = vec![workspace
|
||||
let required_sql_paths = vec![workspace
|
||||
.join("crates/aether-data/adapters/postgres/migrations/20260403000000_baseline.sql")];
|
||||
for driver in ["mysql", "sqlite"] {
|
||||
let driver_dir =
|
||||
workspace.join(format!("crates/aether-data/adapters/{driver}/migrations"));
|
||||
let mut paths = std::fs::read_dir(&driver_dir)
|
||||
.unwrap_or_else(|err| panic!("failed to read {}: {err}", driver_dir.display()))
|
||||
.map(|entry| entry.expect("migration entry should be readable").path())
|
||||
.filter(|path| path.extension().and_then(|ext| ext.to_str()) == Some("sql"))
|
||||
.collect::<Vec<_>>();
|
||||
paths.sort();
|
||||
required_sql_paths.extend(paths);
|
||||
}
|
||||
|
||||
let loaded = load_schema_sources(schema_dir).expect("workspace logical schema should load");
|
||||
check_required_tables(&loaded.schema, &required_sql_paths)
|
||||
|
||||
Reference in New Issue
Block a user