Skip to content

Removed Migrations#5

Merged
blebelo merged 1 commit into
mainfrom
benny/Entities
Dec 16, 2025
Merged

Removed Migrations#5
blebelo merged 1 commit into
mainfrom
benny/Entities

Conversation

@blebelo
Copy link
Copy Markdown
Owner

@blebelo blebelo commented Dec 16, 2025

Summary by CodeRabbit

  • Chores
    • Reorganized database migrations to consolidate schema changes
    • Added database utilities for maintenance and cleanup operations
    • Updated project dependencies

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Dec 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
moipone Ready Ready Preview, Comment Dec 16, 2025 0:20am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 16, 2025

Walkthrough

The PR removes older EF Core migration designer and implementation files, consolidating migration history into a single migration. The InitialCreate migration is renamed to Added_Entities and reorganized with entity table definitions. A new PowerShell database cleanup utility is introduced, and a JSON configuration package reference is removed from the Web.Host project.

Changes

Cohort / File(s) Summary
Removed EF Core Migrations
aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251212224515_InitialCreate.Designer.cs, 20251215223124_Added_Entities.Designer.cs, 20251215223124_Added_Entities.cs, 20251215234558_Refactored_Documents.cs
Deleted obsolete migration files and designer snapshots; consolidates migration history by removing intermediate migration steps.
Consolidated EF Core Migration
aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251216000313_Added_Entities.Designer.cs, 20251216000313_Added_Entities.cs
Renamed migration class from InitialCreate/Refactored_Documents to Added_Entities; updated migration attribute and consolidated entity table definitions (Addresses, ShortCourses, Students, CourseApplications) with primary keys, foreign keys, and indices.
Utility Script
aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/clear_database.ps1
New PowerShell script to drop all objects in the public schema of a PostgreSQL database; accepts host, port, database, username, and password parameters.
Project Configuration
aspnet-core/src/Moipone.PublicSite.Web.Host/Moipone.PublicSite.Web.Host.csproj
Removed PackageReference for Microsoft.Extensions.Configuration.Json version 10.0.1.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Migration consolidation logic: Verify that the renamed Added_Entities migration correctly encompasses all entity definitions and that no schema changes are lost during consolidation.
  • Migration attribute consistency: Confirm that the migration timestamp and class name alignment (20251216000313_Added_Entities) is consistent across Designer and implementation files.
  • PowerShell script safety: Review clear_database.ps1 for SQL injection risks and ensure CASCADE drop operations are intentional; note absence of explicit error handling.
  • Package removal impact: Validate that removing Microsoft.Extensions.Configuration.Json does not break configuration loading in Web.Host.

Possibly related PRs

  • Added Domain Entities & Implemented Address APIs #4: Directly reverses the same EF Core migrations and migration designer files (InitialCreate, Added_Entities, Refactored_Documents) that were originally introduced with domain entity additions and DbSet configurations.

Poem

🐰 Hopping through migrations with a cleanup spree,
Old snapshots dissolved, new schemas set free,
PowerShell whispers sweep clean the database past,
From InitialCreate to Added_Entities at last! ✨

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Removed Migrations' accurately summarizes the main change—deletion of multiple EF Core migration files and renaming of migration classes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Note

Free review on us!

CodeRabbit is offering free reviews until Wed Dec 17 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

@blebelo blebelo temporarily deployed to benny/Entities - Moipone PS API PR #5 December 16, 2025 00:20 — with Render Destroyed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f13d60 and fb1131e.

📒 Files selected for processing (8)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251212224515_InitialCreate.Designer.cs (0 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215223124_Added_Entities.Designer.cs (0 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215223124_Added_Entities.cs (0 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215234558_Refactored_Documents.cs (0 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251216000313_Added_Entities.Designer.cs (1 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251216000313_Added_Entities.cs (8 hunks)
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/clear_database.ps1 (1 hunks)
  • aspnet-core/src/Moipone.PublicSite.Web.Host/Moipone.PublicSite.Web.Host.csproj (0 hunks)
💤 Files with no reviewable changes (5)
  • aspnet-core/src/Moipone.PublicSite.Web.Host/Moipone.PublicSite.Web.Host.csproj
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215223124_Added_Entities.Designer.cs
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215223124_Added_Entities.cs
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251212224515_InitialCreate.Designer.cs
  • aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251215234558_Refactored_Documents.cs
🔇 Additional comments (8)
aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251216000313_Added_Entities.cs (7)

10-10: LGTM!

Migration class renamed appropriately to reflect the consolidated entity additions.


452-472: Verify PostalCode length constraint for your use case.

The PostalCode column has a maxLength: 5, which works for South African postal codes (4 digits) but would be too restrictive for international addresses (e.g., UK: 6-8 chars, Canada: 7 chars with space). If international addresses are in scope, consider increasing this limit.


474-498: LGTM!

The ShortCourses table structure is well-designed with appropriate constraints. The unique index on Code (created later) ensures course code uniqueness.


819-859: Clarify the purpose of ShortCourseId on Students vs CourseApplications.

The Students table has a direct ShortCourseId FK, while CourseApplications also links students to courses. This appears intentional for distinguishing "enrolled" students (via Students.ShortCourseId) from "applicants" (via CourseApplications). Ensure application logic correctly manages both relationships to prevent data inconsistency.

Also note: Document fields (CertifiedId, ProofOfResidence, etc.) store file paths. Ensure file lifecycle management handles orphaned files when student records are deleted.


965-998: Verify CASCADE DELETE behavior is intentional.

Both foreign keys use onDelete: ReferentialAction.Cascade:

  • Deleting a Student hard-deletes all their CourseApplications
  • Deleting a ShortCourse hard-deletes all applications to it

Since Students and ShortCourses use soft-delete (IsDeleted), this only affects hard deletes. However, for audit/compliance purposes, consider whether application history should be preserved. If so, add soft-delete to CourseApplications and change to ReferentialAction.Restrict or NoAction.


1348-1386: LGTM!

Index strategy is solid:

  • Unique constraints on EmailAddress and IdNumber ensure student data integrity
  • Composite unique index (StudentId, ShortCourseId) prevents duplicate course applications
  • FK indexes support efficient join queries

1473-1507: LGTM!

The Down method correctly drops tables in dependency order: CourseApplicationsStudentsAddresses/ShortCourses. This respects foreign key constraints and ensures reversibility.

aspnet-core/src/Moipone.PublicSite.EntityFrameworkCore/Migrations/20251216000313_Added_Entities.Designer.cs (1)

15-16: LGTM!

Auto-generated designer file correctly reflects the migration name and class. The model snapshot includes all new entities (Address, CourseApplication, ShortCourse, Student) with proper relationships and indexes.

@blebelo blebelo merged commit 34c2244 into main Dec 16, 2025
7 checks passed
@blebelo blebelo deleted the benny/Entities branch December 18, 2025 00:46
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.

1 participant