| 398 | } |
| 399 | |
| 400 | async fn alter_table( |
| 401 | &self, |
| 402 | identifier: &Identifier, |
| 403 | changes: Vec<crate::spec::SchemaChange>, |
| 404 | ignore_if_not_exists: bool, |
| 405 | ) -> Result<()> { |
| 406 | let table_path = self.table_path(identifier); |
| 407 | if !self.table_exists(identifier).await? { |
| 408 | if ignore_if_not_exists { |
| 409 | return Ok(()); |
| 410 | } |
| 411 | return Err(Error::TableNotExist { |
| 412 | full_name: identifier.full_name(), |
| 413 | }); |
| 414 | } |
| 415 | |
| 416 | let current = self |
| 417 | .load_latest_table_schema(&table_path) |
| 418 | .await? |
| 419 | .ok_or_else(|| Error::TableNotExist { |
| 420 | full_name: identifier.full_name(), |
| 421 | })?; |
| 422 | |
| 423 | let new_schema = current.apply_changes(changes)?; |
| 424 | self.save_table_schema(&table_path, &new_schema).await |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | #[cfg(test)] |