Skip to content

Commit

Permalink
me: temporarily refuse to handle mysql multi-schema schemas
Browse files Browse the repository at this point in the history
Until it is implemented.

closes prisma/prisma#16274
  • Loading branch information
tomhoule committed Dec 13, 2022
1 parent 4e2b494 commit 2297bd5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
Expand Up @@ -124,6 +124,11 @@ pub(crate) trait SqlFlavour:
None
}

/// Check a schema for preview features not implemented in migrate/introspection.
fn check_schema_features(&self, _schema: &psl::ValidatedSchema) -> ConnectorResult<()> {
Ok(())
}

/// The connection string received in set_params().
fn connection_string(&self) -> Option<&str>;

Expand Down
Expand Up @@ -139,6 +139,21 @@ impl SqlFlavour for MysqlFlavour {
}
}

fn check_schema_features(&self, schema: &psl::ValidatedSchema) -> ConnectorResult<()> {
let has_namespaces = schema
.configuration
.datasources
.first()
.map(|ds| !ds.namespaces.is_empty());
if let Some(true) = has_namespaces {
Err(ConnectorError::from_msg(
"multiSchema migrations and introspection are not implemented on MySQL yet".to_owned(),
))
} else {
Ok(())
}
}

fn connection_string(&self) -> Option<&str> {
self.state
.params()
Expand Down
Expand Up @@ -123,6 +123,7 @@ impl SqlMigrationConnector {
match target {
DiffTarget::Datamodel(schema) => {
let schema = psl::parse_schema(schema).map_err(ConnectorError::new_schema_parser_error)?;
self.flavour.check_schema_features(&schema)?;
Ok(sql_schema_calculator::calculate_sql_schema(
&schema,
self.flavour.as_ref(),
Expand Down
33 changes: 33 additions & 0 deletions migration-engine/migration-engine-tests/tests/schema_push/mod.rs
Expand Up @@ -454,3 +454,36 @@ fn issue_repro_extended_indexes(api: TestApi) {
api.schema_push_w_datasource(dm).send().assert_executable();
api.schema_push_w_datasource(dm).send().assert_green().assert_no_steps();
}

#[test]
fn multi_schema_not_implemented_on_mysql() {
test_setup::only!(Mysql);

let schema = r#"
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
datasource db {
provider = "mysql"
url = env("TEST_DATABASE_URL")
schemas = ["s1", "s2"]
}
model m1 {
id Int @id
@@schema("s2")
}
"#;

let api = migration_core::migration_api(Some(schema.to_owned()), None).unwrap();
let err = tok(api.schema_push(migration_core::json_rpc::types::SchemaPushInput {
force: false,
schema: schema.to_owned(),
}))
.unwrap_err();

let expected = expect_test::expect![[""]];
expected.assert_eq(&err.to_string());
}

0 comments on commit 2297bd5

Please sign in to comment.