refactor plan created

This commit is contained in:
Kalana B. Thilakarathna
2026-09-18 12:18:00 +05:30
parent 03d01d4c4e
commit c8c04c357d
2 changed files with 17 additions and 18 deletions
@@ -898,23 +898,7 @@ namespace Distribution.Migrations
private static void DropForeignKeyIfExists(MigrationBuilder migrationBuilder, string tableName, string constraintName) private static void DropForeignKeyIfExists(MigrationBuilder migrationBuilder, string tableName, string constraintName)
{ {
migrationBuilder.Sql($""" migrationBuilder.Sql($"ALTER TABLE `{tableName}` DROP FOREIGN KEY IF EXISTS `{constraintName}`;");
SET @sql = IF(
EXISTS(
SELECT 1
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = DATABASE()
AND TABLE_NAME = '{tableName}'
AND CONSTRAINT_NAME = '{constraintName}'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
),
'ALTER TABLE `{tableName}` DROP FOREIGN KEY `{constraintName}`',
'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
""");
} }
private static void DropIndexIfExists(MigrationBuilder migrationBuilder, string tableName, string indexName) private static void DropIndexIfExists(MigrationBuilder migrationBuilder, string tableName, string indexName)
@@ -1,8 +1,23 @@
# Refactor Implementation Plan # Refactor Implementation Plan
**Status**: Ready to implement **Status**: Implementation complete — migration pending (see Phase 5)
**Design docs**: [order_invoice_lifecycle.md](./order_invoice_lifecycle.md), [loading_event.md](./loading_event.md), [dispatch_pipeline.md](./dispatch_pipeline.md), [ride_lifecycle.md](./ride_lifecycle.md) **Design docs**: [order_invoice_lifecycle.md](./order_invoice_lifecycle.md), [loading_event.md](./loading_event.md), [dispatch_pipeline.md](./dispatch_pipeline.md), [ride_lifecycle.md](./ride_lifecycle.md)
| Phase | Title | Status |
|-------|-------|--------|
| 1 | Enums | ✅ Done |
| 2 | Remove Sale | ✅ Done |
| 3 | Model Changes | ✅ Done |
| 4 | DbContext | ✅ Done |
| 5 | Migration | ⚠️ Migration created — `dotnet ef database update` failing (FK drop error — fix applied 2026-09-17) |
| 6 | Invoice Feature | ✅ Done (GET list/detail only; create/print/finalize endpoints pending) |
| 7 | ShopPO Feature | ✅ Done (GET list/detail only; confirm/cancel/items endpoints pending) |
| 8 | Payment Feature | ✅ Done |
| 9 | LoadingEvent Overhaul | ✅ Done |
| 10 | Ride Overhaul | ✅ Done |
| 11 | SysConfig + InvoiceCreationMode | ✅ Done (replaces original Program.cs/appsettings plan; implemented as DB-backed key-value store) |
| 12 | Permission Seeding | ⏳ Pending |
--- ---
## Scope ## Scope