138 datasource entity ef migration - #166
Open
bolsson wants to merge 9 commits into
Open
Conversation
- Add ProviderType enum replacing RemoteDataSourceTypeEnum
- Add DataSource entity (flat table, inherits BaseEntity)
- Doi replaces GbifDataSetId (nullable in DB, enforced at app layer)
- Cleaned-up property names: RemoteAddress, ArchiveName,
NonValidOccurrenceIds, WebServiceVersion
- GbifApiQuery/HarvestPropertyOverrides/ImportPropertyOverrides
stored as nvarchar(max) for large JSON payloads
- Add DataSourceConfiguration with column constraints and indexes
- Wire up OnModelCreatingPartial call in ArtskartDbContext
- Add EF migration AddDataSource
3-database architecture: DB1 Artskart3Import - raw import data (this project) DB2 Artskart3Core - processed/standardised observations (Artskart3.Infrastructure) DB3 Artskart3Index - search-optimised index (future index3core) Changes: - Remove DataSource entity and ProviderType enum from Artskart3.Core - Revert Artskart3.Infrastructure to pre-DataSource state (migration, DbSet, EntityConfiguration and OnModelCreatingPartial call removed, model snapshot restored) - Create Artskart3.Import class library (net10.0, EF Core 10.0.5) - Add DataSource entity, ProviderType enum, DataSourceConfiguration, ArtskartImportDbContext and ArtskartImportDbContextFactory - Add InitialImportBaseline EF migration for Artskart3Import database - Add Artskart3.Import to solution and as reference in Artskart3.Api - Add ArtskartImportDb connection string to appsettings.json
…port.Infrastructure)
…hitecture overview
| <ItemGroup> | ||
| <ProjectReference Include="..\Artskart3.Core\Artskart3.Core.csproj" /> | ||
| <ProjectReference Include="..\Artskart3.Infrastructure\Artskart3.Infrastructure.csproj" /> | ||
| <ProjectReference Include="..\Artskart3.Import.Infrastructure\Artskart3.Import.Infrastructure.csproj" /> |
Contributor
There was a problem hiding this comment.
Jeg lurer litt på om det er nødvendig å ha egne prosjekt for dette? Ser at undermappene i disse nye Artskart3.Import prosjektene er helt like de som er under Core og Infrastructure allerede 🤔
Contributor
Author
There was a problem hiding this comment.
Seperation of concerns. Det er helt eget prosjekt, men med samme undermapper ettersom at vi følger Clean Architecture prinsippene tenker jeg.
Contributor
There was a problem hiding this comment.
Hva er det denne configuration fila gjør egentlig?
…ity-ef-migration # Conflicts: # Artskart3.Api/appsettings.json # Artskart3.slnx
Updated summary comment for DataSource class to remove reference to SourceDataBase in RavenDB. Signed-off-by: bolsson <6236608+bolsson@users.noreply.github.com>
30 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Få oversikt over objekttyper i RavenDB #138 — DataSource entity and EF migration
Summary
As part of the RavenDB → SQL Server migration analysis for Artskart3, this PR introduces the DataSource entity which replaces the SourceDataBase document type from the old RavenDB store (Artskart2Core).
The design is based on a live data analysis of all 430 SourceDataBase documents across the four provider types found in production:
• 389 × GbifIpt
• 36 × ArtskartDataDeliveryWebServiceV1
• 4 × GbifApi
• 1 × Artsobservasjoner20Api
Changes
• ProviderType enum — clean replacement for RemoteDataSourceTypeEnum (dropped GbifJson which had zero live records)
• DataSource entity — flat table inheriting BaseEntity, with:
• Doi (string?) replacing GbifDataSetId — nullable in DB, enforced at the application layer for relevant provider types
• GbifApiQuery, HarvestPropertyOverrides, ImportPropertyOverrides — stored as nvarchar(max) (large JSON payloads)
• Property names cleaned up: RemoteAddress, ArchiveName, NonValidOccurrenceIds, WebServiceVersion
• GbifPublisherId kept as Guid? (nullable — only relevant for API-based providers)
• DataSourceConfiguration — EF fluent configuration with column constraints and indexes on ProviderType and IsDeleted
• EF migration AddDataSource — generates the DataSource table
• Fixed a pre-existing bug: OnModelCreatingPartial was declared but never called from OnModelCreating
Additional changes (extended scope)
Refactored import layer into Clean Architecture
The initial single Artskart3.Import project was split into two projects following the same Clean Architecture pattern as the rest of the solution:
• Artskart3.Import.Core — domain entities, enums, repository interfaces (no EF dependency)
• Artskart3.Import.Infrastructure — EF DbContext, migrations, repository implementations, DI wiring
GbifDatasetDiscovery entity
Replaces GbifDataSetInfo from RavenDB — a staging table for datasets discovered via the GBIF API. The NonRelevant bool has been replaced with a proper DiscoveryStatus enum (Pending, Approved, Rejected). A unique index on GbifId prevents duplicate discoveries.
Architecture decisions documented
• Three-database architecture agreed: Artskart3Import, Artskart3Cache, Artskart3Index
• Taxonomy sourced from Nortaxa API — not stored as owned data; taxon tree will be cached in Artskart3Index for UI performance
• README updated with database overview and EF migration commands for all contexts
Running locally
Ensure your Artskart3.Api/appsettings.json connection string points at your local SQL Server instance, then run:
Create/update the Artskart3Import database
dotnet ef database update
--project Artskart3.Import.Infrastructure--startup-project Artskart3.Api `
--context ArtskartImportDbContext
This will create the Artskart3Import database (if it doesn't exist) and apply both migrations:
• InitialImportBaseline — creates the DataSource table
• AddGbifDatasetDiscovery — creates the GbifDatasetDiscovery table
Out of scope / future work
• RawOccurrence entity in Artskart3Cache — SQL representation of a raw Darwin Core (DwC) occurrence record as received from providers (DwC-A archives, GBIF API). Largest migration item, warrants its own issue.
• Occurrence entity in Artskart3Index
• TaxonomyChangeLog (replacement for ArtskartEvent)
• Data migration tool from RavenDB → SQL