Run artifact

workspace/targets/ReadingList/blueprint/DATABASE.md

DATABASE: ReadingList

FieldValue
Version20261023 V1
DescriptionPersistence stores and typed interfaces for the ReadingList books table.
Depends OnARCHITECTURE.md
Providesbooks.create, books.list, books.get, books.delete
Build Order1

Persistence Boundary

BoundaryRule
Raw storage accessOnly the generated persistence/ package reaches the store.
Caller dependencyFeatures depend on declared access patterns and their DTOs, not on schemas.
ImplementationGenerated from this file at the DATABASE build step; never written by hand.

Access Patterns

Insertion order is preserved by the autoincrementing integer primary key id; listing is ordered by id ascending, so no position column exists.

FEATURE-BOOKS-001 — Create a book

FieldValue
OwnerFEATURE-AddBook.md
Accesswrite
Repository operationbooks.create
Compatibilityunchanged

Input: BookCreateInput

FieldTypeNotes
titleTEXTNon-empty, trimmed by the caller
authorTEXTNon-empty, trimmed by the caller

Output: BookRow

FieldTypeNotes
idINTEGERAssigned by the store
titleTEXTAs stored
authorTEXTAs stored

FEATURE-BOOKS-002 — List books in the order added

FieldValue
OwnerFEATURE-ListBooks.md
Accessread
Repository operationbooks.list
Compatibilityunchanged

Input: BookListInput

FieldTypeNotes
(none)Returns every book, ordered by id ascending

Output: BookRow

FieldTypeNotes
idINTEGERAscending across the returned sequence
titleTEXTAs stored
authorTEXTAs stored

FEATURE-BOOKS-003 — Get a book by id

FieldValue
OwnerFEATURE-RemoveBook.md
Accessread
Repository operationbooks.get
Compatibilityunchanged

Input: BookGetInput

FieldTypeNotes
idINTEGERBook identifier

Output: BookRow

FieldTypeNotes
idINTEGERBook identifier
titleTEXTAs stored
authorTEXTAs stored

FEATURE-BOOKS-004 — Delete a book

FieldValue
OwnerFEATURE-RemoveBook.md
Accesswrite
Repository operationbooks.delete
Compatibilityunchanged

Input: BookDeleteInput

FieldTypeNotes
idINTEGERBook identifier

Output: BookDeleteResult

FieldTypeNotes
idINTEGERIdentifier of the removed book

Schemas

books

FieldTypeNotes
idINTEGER PKAutoincrementing; defines insertion order
titleTEXT NOT NULLBook title
authorTEXT NOT NULLBook author

Migrations

Each relational change has one staged record in migrations/MIGRATION-<AccessPatternId>.md. The record carries Alembic upgrade/downgrade snippets and progresses from planned to built only when its DATABASE build story completes. Alembic records deployment application separately.

Access PatternRevisionState

Config (.env)

KeyTypeRequiredNotes

File Stores

StoreRoot dirNotes

External Services

ServiceWrapperNotes

External Libraries

LibraryOwnershipDistributionConsumer Contract

Programmatic Acceptance

=== AC books-create ===
Intent: Creating a book returns a row carrying the supplied title and author and an assigned id.
Suite: scoped

from persistence.testing import db_session

title = "Create Title" author = "Create Author" with db_session() as db: row = db.books.create(title=title, author=author) assert row.id is not None assert row.title == title assert row.author == author === END AC books-create ===

=== AC books-get ===
Intent: A created book can be read back by id with the supplied title and author.
Suite: scoped

from persistence.testing import db_session

title = "Get Title" author = "Get Author" with db_session() as db: created = db.books.create(title=title, author=author) fetched = db.books.get(id=created.id) assert fetched is not None assert fetched.id == created.id assert fetched.title == title assert fetched.author == author === END AC books-get ===

=== AC books-list-order ===
Intent: Listing returns books in the order they were created.
Suite: scoped

from persistence.testing import db_session

titles = ["Order One", "Order Two", "Order Three"] with db_session() as db: created_ids = [db.books.create(title=t, author="Order Author").id for t in titles] listed_ids = [row.id for row in db.books.list()] ours = [i for i in listed_ids if i in created_ids] assert ours == created_ids assert created_ids == sorted(created_ids) === END AC books-list-order ===

=== AC books-delete ===
Intent: A deleted book is absent from the list on the next read and other books remain.
Suite: scoped

from persistence.testing import db_session

with db_session() as db: first = db.books.create(title="Delete First", author="Delete Author") second = db.books.create(title="Delete Second", author="Delete Author") db.books.delete(id=first.id) listed_ids = [row.id for row in db.books.list()] assert first.id not in listed_ids assert second.id in listed_ids === END AC books-delete ===

User Acceptance

Guardrails