Skip to content

Add schema versioning for database migrations#890

Merged
pmachapman merged 4 commits intomainfrom
database_migrarations
Mar 25, 2026
Merged

Add schema versioning for database migrations#890
pmachapman merged 4 commits intomainfrom
database_migrarations

Conversation

@pmachapman
Copy link
Copy Markdown
Collaborator

@pmachapman pmachapman commented Mar 12, 2026

Fixes #567


This change is Reviewable

@pmachapman pmachapman requested review from Enkidu93 and ddaspit March 12, 2026 02:55
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.94%. Comparing base (a4e5a8e) to head (d428d92).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #890      +/-   ##
==========================================
+ Coverage   67.52%   67.94%   +0.41%     
==========================================
  Files         385      386       +1     
  Lines       21107    21205      +98     
  Branches     2748     2736      -12     
==========================================
+ Hits        14253    14408     +155     
+ Misses       5870     5812      -58     
- Partials      984      985       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Collaborator

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

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

So far so good! I forget - are you planning on making a more dedicated place for migration tests?

@Enkidu93 reviewed 11 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ddaspit).

@pmachapman pmachapman changed the title Added schema versioning for database migrations Add schema versioning for database migrations Mar 15, 2026
@pmachapman pmachapman force-pushed the database_migrarations branch from d247ecc to 6673647 Compare March 15, 2026 23:15
Copy link
Copy Markdown
Collaborator Author

@pmachapman pmachapman left a comment

Choose a reason for hiding this comment

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

I forget - are you planning on making a more dedicated place for migration tests?

I have added integration tests for SIL.DataAccess, with a sample test for a migration. Is this the sort of migration testing you were thinking of?

@pmachapman made 1 comment.
Reviewable status: 11 of 29 files reviewed, all discussions resolved (waiting on ddaspit).

Copy link
Copy Markdown
Collaborator

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

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

Yes, that's great! Do you think the content from MongoMigrations and the test MongoMigration_TargetQuoteConvention in TranslationEngineTests should be relocated/refactored at all to fit with this new arrangement?

@Enkidu93 reviewed 18 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on ddaspit).

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

@ddaspit reviewed 29 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on pmachapman).


src/DataAccess/src/SIL.DataAccess/IMongoDataAccessConfiguratorExtensions.cs line 9 at r2 (raw file):

        string collectionName,
        Action<BsonClassMap<T>>? mapSetup = null,
        Func<IMongoCollection<T>, Task>[]? init = null

Nit: IReadOnlyList would make this slightly more flexible.


src/DataAccess/test/SIL.DataAccess.IntegrationTests/ServalSharedTests.cs line 5 at r2 (raw file):

[TestFixture]
[Category("Integration")]
public class ServalSharedTests

The fact that these tests have a dependency on Serval projects makes me feel like they should be in the Serval integration tests. Alternatively, you could create a test DB setup, since these tests are not testing Serval but the data access migrations.

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

@ddaspit made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on pmachapman).


src/DataAccess/test/SIL.DataAccess.IntegrationTests/ServalSharedTests.cs line 5 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

The fact that these tests have a dependency on Serval projects makes me feel like they should be in the Serval integration tests. Alternatively, you could create a test DB setup, since these tests are not testing Serval but the data access migrations.

Actually, I think I misunderstood the purpose of these tests. These actually are testing the Serval migrations, right? I would prefer that these are included in Serval integration tests.

Copy link
Copy Markdown
Collaborator Author

@pmachapman pmachapman left a comment

Choose a reason for hiding this comment

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

Do you think the content from MongoMigrations and the test MongoMigration_TargetQuoteConvention in TranslationEngineTests should be relocated/refactored at all to fit with this new arrangement?

I don't think it needs to be. The existing test does the job well, and uses the model. If it the old property gets dropped from the model, then it would make sense to move.

@pmachapman made 3 comments and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ddaspit).


src/DataAccess/src/SIL.DataAccess/IMongoDataAccessConfiguratorExtensions.cs line 9 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Nit: IReadOnlyList would make this slightly more flexible.

Done. Thanks!


src/DataAccess/test/SIL.DataAccess.IntegrationTests/ServalSharedTests.cs line 5 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Actually, I think I misunderstood the purpose of these tests. These actually are testing the Serval migrations, right? I would prefer that these are included in Serval integration tests.

@ddaspit Do you mean the API integration tests? These didn't feel like that quite fit there, as the tests in that project communicate with the API directly.

Also, one of the test classes is for Serval.Machine (which did not previously have any tests outside of e2e testing the migrations), while the other class is for Serval.

I wonder if I should create two projects - Serval.Machine.IntegrationTests, and Serval.IntegrationTests? I created the SIL.DataAccess.Integration tests project as I couldn't figure out just where to place these tests.

If you still want these in Serval.ApiServer.IntegrationTests, not a problem, I just thought I'd explain my reasoning before doing that.

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

@ddaspit reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on pmachapman).


src/DataAccess/test/SIL.DataAccess.IntegrationTests/ServalSharedTests.cs line 5 at r2 (raw file):

Previously, pmachapman (Peter Chapman) wrote…

@ddaspit Do you mean the API integration tests? These didn't feel like that quite fit there, as the tests in that project communicate with the API directly.

Also, one of the test classes is for Serval.Machine (which did not previously have any tests outside of e2e testing the migrations), while the other class is for Serval.

I wonder if I should create two projects - Serval.Machine.IntegrationTests, and Serval.IntegrationTests? I created the SIL.DataAccess.Integration tests project as I couldn't figure out just where to place these tests.

If you still want these in Serval.ApiServer.IntegrationTests, not a problem, I just thought I'd explain my reasoning before doing that.

Yeah, I get what you mean. They don't really fit in the API integration tests, since they aren't testing the REST API. The Machine tests certainly don't belong in that project. You should definitely create a Serval.Machine.Shared.IntegrationTests and move the Machine tests there. The right thing to do would be to create a new Serval.IntegrationTests project. If you don't feel like doing that, I wouldn't have a problem if you move them to the Serval.ApiServer.IntegrationTests project, since it should have all of the required dependencies. If you do create a new Serval.IntegrationTests project, then go ahead and move the existing migration test there.

@pmachapman pmachapman force-pushed the database_migrarations branch from 605d2c7 to 08ca2e9 Compare March 18, 2026 19:32
Copy link
Copy Markdown
Collaborator Author

@pmachapman pmachapman left a comment

Choose a reason for hiding this comment

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

@pmachapman made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ddaspit).


src/DataAccess/test/SIL.DataAccess.IntegrationTests/ServalSharedTests.cs line 5 at r2 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

Yeah, I get what you mean. They don't really fit in the API integration tests, since they aren't testing the REST API. The Machine tests certainly don't belong in that project. You should definitely create a Serval.Machine.Shared.IntegrationTests and move the Machine tests there. The right thing to do would be to create a new Serval.IntegrationTests project. If you don't feel like doing that, I wouldn't have a problem if you move them to the Serval.ApiServer.IntegrationTests project, since it should have all of the required dependencies. If you do create a new Serval.IntegrationTests project, then go ahead and move the existing migration test there.

Done.

Copy link
Copy Markdown
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

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

:lgtm:

@ddaspit partially reviewed 19 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on pmachapman).

@pmachapman pmachapman force-pushed the database_migrarations branch from 08ca2e9 to 41fe374 Compare March 22, 2026 20:31
Copy link
Copy Markdown
Collaborator

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

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

:lgtm:

@Enkidu93 partially reviewed 20 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on pmachapman).

@pmachapman pmachapman force-pushed the database_migrarations branch from 41fe374 to d428d92 Compare March 25, 2026 17:38
@pmachapman pmachapman merged commit c57e306 into main Mar 25, 2026
2 checks passed
@pmachapman pmachapman deleted the database_migrarations branch March 25, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

standard database migrations

4 participants