Repository navigation
feat(repositories): base record columns for mutable and append-only tables (XWING-2363) - #9
Merged
Merged
Conversation
…ables (XWING-2363)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The two table shapes from the target data model, ready to use as bases:
record_columns()— UUIDv4id+created_at+updated_at; model baseEntityappend_only_columns()— UUIDv4id+created_atonly; model baseAppendOnlyThe database owns identity and time
id:gen_random_uuid()on Postgres;uuid()on SQLite, driver-registered bycreate_database_engine(matching contracts'DEFAULT (uuid()))created_at/updated_at: DB defaults —now()on Postgres, contracts' millisecond-Zstrftimeon SQLite (_DbNow)updated_aton update is kept by the contracts<table>_touchtrigger — the SQLAlchemyonupdateis gone;_update_recordre-reads it on SQLite (AFTER triggers are invisible toRETURNINGthere)RecordUuidcolumn type: native UUID on Postgres, hyphenated text on SQLite so lookups match the stored formUtcTimestampbinds the same text format so ordering survives mixed writersThe app supplies only domain times (
occurred_at,observed_at, …) viaClock;id is None= not saved,add/updatereturn the saved record viaRETURNING.Tests
Contract tests over sqlite + Postgres in
tests/v1/repositories/test_sql.py, including a contracts-shaped touch trigger on the test table and a raw-SQL update test provingupdated_atis maintained for writers outside the app. Lint, 649 unit tests, coverage 92%.Note: local
make test-integrationcan fail withcolumn "severity" does not existwhen the shared traust_test container holds the in-flight one-owner DDL — environmental, unrelated to this change (CI uses its own container).Tracker: XWING-2363