Remove database string validation from sql migration connector
This is now done at the datamodel parser level.
@@ -41,8 +41,6 @@ pub struct SqlMigrationConnector {
impl SqlMigrationConnector {
pub async fn new(database_str: &str, provider: &str) -> ConnectorResult<Self> {
- validate_database_str(database_str, provider)?;
-
let connection_info =
ConnectionInfo::from_url(database_str).map_err(|err| ConnectorError::url_parse_error(err, database_str))?;
@@ -247,22 +245,3 @@ pub(crate) async fn catch<O>(
Err(sql_error) => Err(sql_error.into_connector_error(connection_info)),
}
}
-
-fn validate_database_str(database_str: &str, provider: &str) -> ConnectorResult<()> {
- let scheme = database_str.split(":").next();
-
- match (provider, scheme) {
- ("mysql", Some("mysql")) => Ok(()),
- ("postgresql", Some(scheme)) if scheme.starts_with("postgresql") => Ok(()),
- ("postgres", Some(scheme)) if scheme.starts_with("postgres") => Ok(()),
- ("sqlite", Some("file")) | ("sqlite", Some("sqlite")) => Ok(()),
- _ => {
- let error = ConnectorError {
- kind: migration_connector::ErrorKind::InvalidDatabaseUrl,
- user_facing_error: None,
- };
-
- Err(error)
- }
- }
-}
