mirror of
https://dev.azure.com/tstanciu94/Packages/_git/Netmash
synced 2025-07-30 11:11:10 +03:00
2.9 KiB
2.9 KiB
Quick Start Guide for Future AI Agents
What This Project Is
A .NET database migration library that helps applications manage database schema changes across versions, supporting SQL Server and SQLite with flexible metadata storage.
What Was Accomplished This Session
✅ Added multi-schema support for SQL Server
✅ Added table/file prefixing for service isolation
✅ Implemented placeholder-based SQL script system
✅ Simplified Entity Framework configurations
✅ Added comprehensive validation rules
✅ Updated all documentation
Current Entry Points
// Main configuration method
services.AddMigration(
databaseType: DatabaseType.SQLServer, // or SQLite
metadataStorage: MetadataStorage.Database, // or XmlFile
metadataSchema: "myservice", // SQL Server only
metadataPrefix: "svc_" // table/file prefix
);
// Start migrations
app.UseMigration();
Key Files to Understand
DependencyInjectionExtensions.cs
- Main entry point and configurationServiceConfiguration.cs
- Central configuration objectTableNamingService.cs
- Handles dynamic naming and SQL placeholder processingServices/MigrationService.cs
- Core migration execution logicScripts/
folders - SQL scripts with{MetadataSchema}
and{TablePrefix}
placeholders
How It Works
- User calls
AddMigration()
with configuration - System validates configuration and registers services
- On
UseMigration()
, system:- Checks if migration tables exist, creates if needed
- Finds script folders organized by version (1.0.0, 1.0.1, etc.)
- Runs scripts in version order, tracks progress in metadata
- Supports both XML file and database metadata storage
Common Tasks for Future Development
Adding New Database Support
- Add enum value to
DatabaseType
- Create scripts in
Scripts/{NewDatabase}/
folder - Add case to
GetSqlResources()
inMetadataLocationService
- Update
MigrationRepository.MigrationTablesAreSet()
query logic
Adding New Validation Rules
Add to ValidateConfiguration()
in DependencyInjectionExtensions.cs
Modifying SQL Scripts
Edit scripts in Scripts/
folders using placeholders:
{MetadataSchema}
for schema names{TablePrefix}
for table prefixes
Testing Changes
dotnet build # Should compile without errors
Project Dependencies
- .NET 8.0
- Entity Framework Core (SQL Server + SQLite providers)
- Microsoft.Extensions.* packages for DI and logging
Current Limitations
- No rollback support
- No MySQL/PostgreSQL support
- No unit tests implemented
- No migration script validation
User Preferences (Important!)
- Prefers simplicity over complexity
- Likes placeholder systems over dynamic generation
- Values dependency injection and testability
- Wants clear validation with helpful error messages
- Prefers embedded resources over external files