Schema & Model Design
Use Immutable Struct Models: Define
@Table models as Sendable value-type structs (struct Note: Sendable). Avoid mutable reference classes to eliminate concurrency data races.Explicit Primary Keys: Always specify an explicit primary key via
@Column(primaryKey: true). Prefer UUID or String keys for seamless CloudKit synchronization.Append-Only Migrations: Give every migration step a descriptive, versioned name (
"v1_create_notes", "v2_add_tags"). Never modify existing migration strings after app release.Performance & Query Ergonomics
BatchInsert.swift
SwiftUI State Management
- Keep
@LiveQuerydefinitions scoped to the child views that require them. - Avoid passing raw SQL connection objects across view boundaries.
- Use
BoutiqueDB.inMemoryURL()for SwiftUI Previews and unit tests.

