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 special note for EDD and EF #398

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/contributing/database-migrations/edd.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,26 @@ Prior to merging a PR please ensure that the database changes run well on the cu
version. We currently do not have an automated test suite for this and itโ€™s up to the developers to
ensure their database changes run correctly against the currently released version.

## EF-Only Databases with Code Migrations
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## EF-Only Databases with Code Migrations
## EF-only databases with code migrations


For EF only databases that use code as migrations (self-host), migrations will run before new code is deployed and therefore before the model that EF works off of has changed, since that is in the code.

Columns that are referenced in queries in the database have to be deleted over 2 releases. Here's the process:

1. Before the first release, delete the property in the C# class.

2. Keep that column in as a shadow property. Shadow properties are properties that are defined only in the EF model but are not defined in the C# classes. This can be particularly useful when you're transitioning columns in the database schema without immediately reflecting those changes in the code.

Comment on lines +319 to +320
Copy link
Member

Choose a reason for hiding this comment

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

How do I do this? I had a look at https://learn.microsoft.com/en-us/ef/core/modeling/shadow-properties but it wasn't obvious how that maps to our implementation.

3. Test creating EF migrations. They should be empty and then can be deleted.

4. Do a release.

5. That column should not be a part of any queries anymore.

6. Delete the shadow property configuration.

7. Create migrations that will drop that column.

## Further reading

1. [Evolutionary Database Design](https://martinfowler.com/articles/evodb.html) (Particularly
Expand Down
Loading