docs: add stored procedure naming convention design
This commit is contained in:
@@ -0,0 +1,102 @@
|
|||||||
|
# Stored Procedure Naming Convention Design
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Rename stored procedures to follow SQL Server best practice `usp_` prefix convention for consistency and clarity.
|
||||||
|
|
||||||
|
## Current State
|
||||||
|
|
||||||
|
| Current Name | Has `usp_` Prefix |
|
||||||
|
|--------------|-------------------|
|
||||||
|
| `SubmitSearch` | No |
|
||||||
|
| `StartSearch` | No |
|
||||||
|
| `CompleteSearch` | No |
|
||||||
|
| `ResetPartialSearches` | No |
|
||||||
|
| `usp_ValidateSearchCriteria` | Yes (already correct) |
|
||||||
|
|
||||||
|
## Target State
|
||||||
|
|
||||||
|
| Current | New |
|
||||||
|
|---------|-----|
|
||||||
|
| `SubmitSearch` | `usp_SubmitSearch` |
|
||||||
|
| `StartSearch` | `usp_StartSearch` |
|
||||||
|
| `CompleteSearch` | `usp_CompleteSearch` |
|
||||||
|
| `ResetPartialSearches` | `usp_ResetPartialSearches` |
|
||||||
|
|
||||||
|
## Implementation Approach
|
||||||
|
|
||||||
|
### 1. SQL Scripts (Modify Existing)
|
||||||
|
|
||||||
|
Update scripts 040-043 directly with new procedure names:
|
||||||
|
|
||||||
|
- `040_CreateSubmitSearchProcedure.sql` → `usp_SubmitSearch`
|
||||||
|
- `041_CreateStartSearchProcedure.sql` → `usp_StartSearch`
|
||||||
|
- `042_CreateCompleteSearchProcedure.sql` → `usp_CompleteSearch`
|
||||||
|
- `043_CreateResetPartialSearchesProcedure.sql` → `usp_ResetPartialSearches`
|
||||||
|
|
||||||
|
### 2. Docker Database (Manual Update)
|
||||||
|
|
||||||
|
Since DbUp won't re-run already-executed scripts:
|
||||||
|
1. Drop old procedures from Docker database
|
||||||
|
2. Execute updated CREATE statements directly
|
||||||
|
|
||||||
|
### 3. C# Constants Class (New File)
|
||||||
|
|
||||||
|
Create `StoredProcedures.cs` in `JdeScoping.DataAccess`:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
namespace JdeScoping.DataAccess;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constants for stored procedure names.
|
||||||
|
/// </summary>
|
||||||
|
public static class StoredProcedures
|
||||||
|
{
|
||||||
|
public const string SubmitSearch = "usp_SubmitSearch";
|
||||||
|
public const string StartSearch = "usp_StartSearch";
|
||||||
|
public const string CompleteSearch = "usp_CompleteSearch";
|
||||||
|
public const string ResetPartialSearches = "usp_ResetPartialSearches";
|
||||||
|
public const string ValidateSearchCriteria = "usp_ValidateSearchCriteria";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Repository Update
|
||||||
|
|
||||||
|
Update `LotFinderRepository.SearchManagement.cs` to use constant:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// Before
|
||||||
|
await using var command = new SqlCommand("SubmitSearch", connection)
|
||||||
|
|
||||||
|
// After
|
||||||
|
await using var command = new SqlCommand(StoredProcedures.SubmitSearch, connection)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Documentation Updates
|
||||||
|
|
||||||
|
Update all files mentioning procedure names:
|
||||||
|
|
||||||
|
| File | Updates Needed |
|
||||||
|
|------|----------------|
|
||||||
|
| `DOCUMENTATION/Architecture/Testing.md` | Procedure references |
|
||||||
|
| `DOCUMENTATION/Architecture/Database.md` | Procedure references |
|
||||||
|
| `DOCUMENTATION/search_creation_page_new.md` | Procedure references |
|
||||||
|
| OpenSpec specs | Any procedure references |
|
||||||
|
| PLANS files | Historical references |
|
||||||
|
|
||||||
|
## Files Changed
|
||||||
|
|
||||||
|
| Category | Files |
|
||||||
|
|----------|-------|
|
||||||
|
| SQL Scripts | 4 files (040-043) |
|
||||||
|
| C# New | 1 file (`StoredProcedures.cs`) |
|
||||||
|
| C# Modified | 1 file (`LotFinderRepository.SearchManagement.cs`) |
|
||||||
|
| Documentation | ~5 files |
|
||||||
|
| Docker | Manual SQL execution |
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
|
||||||
|
1. Build succeeds
|
||||||
|
2. All existing tests pass
|
||||||
|
3. Docker database has renamed procedures
|
||||||
|
4. `SELECT name FROM sys.procedures` shows `usp_` prefix on all procedures
|
||||||
Reference in New Issue
Block a user