Skip to content

218#225

Merged
RAprogramm merged 1 commit into
mainfrom
218
Jul 5, 2026
Merged

218#225
RAprogramm merged 1 commit into
mainfrom
218

Conversation

@RAprogramm

Copy link
Copy Markdown
Owner

Closes #218.

Restores a compile-time-like schema guarantee for generated (runtime) SQL with one integration test per entity:

  • {Entity}::SCHEMA — generated entity_core::schema::TableSchema const describing declared columns (name, DDL type, nullability)
  • {Entity}::assert_schema(pool) — compares the declaration against information_schema.columns and reports all drifts at once (missing table/column, nullability, type family)
  • entity-core gains a schema module (feature postgres): TableSchema/SchemaColumn/assert_table plus typed SchemaDrift/SchemaMismatch errors
  • Type comparison is family-based: TEXT/VARCHAR/CHAR fold into one text family, parametrised types drop arguments, arrays compare as arrays, USER-DEFINED (enums) skip the type check while keeping presence/nullability
  • The migrations type mapper is now compiled unconditionally (the migrations feature still gates its codegen), so the schema constant works on lean feature sets

Validated against a real consumer: six production entities asserted green against a live migrated database on the first run — including CHAR(3) columns declared as String, a TEXT[] array and three Postgres enums — plus a negative probe confirming a bogus column is reported.

@RAprogramm RAprogramm merged commit 8126384 into main Jul 5, 2026
16 checks passed
@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.88889% with 65 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/entity-core/src/schema.rs 52.55% 65 Missing ⚠️

📢 Thoughts on this report? Let us know!

@RAprogramm RAprogramm deleted the 218 branch July 5, 2026 05:03
@RAprogramm RAprogramm mentioned this pull request Jul 5, 2026
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.

feat(core): runtime schema assertion for entities

1 participant