Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Migration name check #26396

Merged
merged 4 commits into from
May 19, 2022
Merged

Conversation

KevRitchie
Copy link
Contributor

Summary of the changes:

  • Add a check during the Validate method of MigrationsAddCommand to throw a CommandException when someone tries to call their migration "migration".
  • Add a new resource "CircularBaseClassDependency" to notify the user that "You cannot add a migration with the name 'Migration'".

Fixes #23222

@KevRitchie
Copy link
Contributor Author

Hi @bricelam, does this look OK? Is there anything else I need to consider?

@bricelam
Copy link
Contributor

bricelam commented Oct 26, 2021

This check should probably be a bit deeper into the internals to handle scenarios outside of the CLI and PMC tools. Probably here:

Check.NotEmpty(migrationName, nameof(migrationName));
if (Dependencies.MigrationsAssembly.FindMigrationId(migrationName) != null)
{
throw new OperationException(DesignStrings.DuplicateMigrationName(migrationName));
}

@KevRitchie
Copy link
Contributor Author

Thanks. I'll take a look 👍

src/ef/Commands/MigrationsAddCommand.cs Outdated Show resolved Hide resolved
src/ef/Properties/Resources.resx Outdated Show resolved Hide resolved
Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AndriySvyryd
Copy link
Member

@bricelam Is there anything preventing this from being checked in apart from the conflict?

@bricelam
Copy link
Contributor

Nope, good to merge.

@AndriySvyryd
Copy link
Member

Thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migration name filter
4 participants