# 06. Implement iOS database layer (Core Data/GRDB)

meta:
  id: native-business-logic-migration-06
  feature: native-business-logic-migration
  priority: P0
  depends_on: [native-business-logic-migration-03]
  tags: [implementation, ios, database]

objective:
- Implement database layer using Core Data for iOS

deliverables:
- RSSuper.xcdatamodeld
- DatabaseManager.swift
- Subscription+CoreDataClass.swift
- FeedItem+CoreDataClass.swift
- SearchHistory+CoreDataClass.swift
- Database migrations
- FTS virtual table implementation

tests:
- Unit: Test CRUD operations
- Unit: Test relationships
- Unit: Test FTS queries
- Integration: Test database migrations

acceptance_criteria:
- Core Data model created with all entities
- Relationships properly configured
- FTS search working
- Migrations implemented
- Background context used for writes

validation:
- Run unit tests
- Verify with Instruments (Core Data editor)

notes:
- Use NSPersistentContainer
- Implement FTS using SQLite directly or GRDB
- Consider using NSPredicate for queries
