Skip to main content

Fix modify-schema is not allowed when migration plan is scoped to one schema error

How do I fix the ModifySchema is not allowed when migration plan is scoped to one schema error?

Answer

The error ModifySchema is not allowed when migration plan is scoped to one schema can occur when attempting to execute or generate a migration that includes schema modifications while the URL of the dev or target database is restricted to a single schema.

One reason you might see this error is that your dev-database schema attributes differ from the target database, causing the migration plan to include unintended schema modifications.

To fix this error, you can:

  1. Ensure that the database schema used by --dev-url matches the target database schema settings. For example, if the schema comment, character set, or collation differs, you may need to update the --dev-url to align with the target database schema.

  2. Target the entire database by removing the schema name from the dev-url path. This allows you to modify schema-level attributes like CHARACTER SET or COLLATE without restrictions. See Atlas Connection URLs for details.

Why does Atlas restrict this?

Commands like CREATE TABLE t(...) (without a schema prefix) could be executed in any schema. To ensure predictable behavior, schema modifications such as ALTER SCHEMA ... must be explicitly scoped at the database level along with the schema name.