Copilot 7647ddedd6
Abstract column migration logic into DatabaseTableProtocol for all tables (#4243)
## Summary

Table migration logic for adding new columns and removing obsolete
columns has been abstracted into `DatabaseTableProtocol` with a default
implementation. All 13 table implementations now conform to the extended
protocol and support automatic column migration.

**Protocol Changes:**
- Added `tableName: String` property requirement
- Added `definedColumns: [String]` property requirement  
- Added default `migrateColumns(database:)` implementation that handles
adding/removing columns

**Updated Tables:**
All tables now implement the protocol and support column migration:
- `HAppEntityTable`, `WatchConfigTable`, `CarPlayConfigTable`,
`AssistPipelinesTable`
- `AppEntityRegistryListForDisplayTable`, `AppEntityRegistryTable`,
`AppDeviceRegistryTable`
- `AppPanelTable`, `CustomWidgetTable`, `AppAreaTable`
- `HomeViewConfigurationTable`, `CameraListConfigurationTable`,
`AssistConfigurationTable`

**Column Enums:**
All column enums in `DatabaseTables` now conform to `CaseIterable` for
consistent migration support.

Relies on `ALTER TABLE ... DROP COLUMN` support (SQLite 3.35+, iOS 15+).

## Screenshots

N/A - Database internals only.

## Link to pull request in Documentation repository

N/A - No user-facing changes.

## Any other notes

The migration logic is now centralized in the protocol extension,
eliminating code duplication across table implementations. Each table
provides its `tableName` and `definedColumns`, and the shared
`migrateColumns(database:)` method handles the actual column
synchronization.

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> In GRDB+Initialization.swift each tablet has a logic to create table
columns that may not exist when the user updates the app, update those
table creationg to also delete columns that are not defined in the
create method anymore


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for
you](https://github.com/home-assistant/iOS/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-22 14:03:48 +01:00

Home Assistant for Apple Platforms

TestFlight Beta invite Download on the App Store GitHub issues License Apache 2.0

Getting Started

Home Assistant uses Bundler, Homebrew and Cocoapods to manage build dependencies. You'll need Xcode 26.2 (or later) which you can download from the App Store. You can get the app running using the following commands:

git clone https://github.com/home-assistant/iOS.git
cd iOS

# you must do one of the following, but you do not need to do all of them:

## install cocoapods via homebrew, use that
brew install cocoapods
$(brew --prefix)/opt/ruby/bin/gem install cocoapods-acknowledgements
pod install --repo-update

## install ruby via homebrew, use that
brew install ruby@3.1
$(brew --prefix)/opt/ruby@3.1/bin/bundle install
$(brew --prefix)/opt/ruby@3.1/bin/bundle exec pod install --repo-update

## install ruby via rbenv, use that
brew install rbenv ruby-build
rbenv install
bundle install
bundle exec pod install --repo-update

Once this completes, you can launch HomeAssistant.xcworkspace and run the App-Debug scheme onto your simulator or iOS device.

Testing just the frontend

To just test the frontend, you can use a simulator version built by our GitHub actions.

  1. Install Xcode from the App Store making sure it's at least the version noted above. You do not need to install or run anything else.
  2. Launch the simulator at /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app or in Xcode under the Xcode menu > Open Developer Tool.
  3. Open a simulator under File > Open Simulator. You can install older versions of iOS in Xcode's Components preferences.
  4. Download a simulator build from the the GitHub action under "Artifacts."
  5. Drag the result .app on drop it on top of the simulator.
  6. Locate the app on the home screen and click it to launch.

The simulator behaves different than you might expect:

Action Effect
Click Tap
Click & drag Scroll
Hold ⌥ Add a second touch point
Hold ⇧⌥ Move both touch points
⌘←, ⌘→ Rotate
⌘S Take screenshot
⌘R Record video
⌘K Toggle software keyboard

You can now debug the WebView in this simulator build using Safari's Web Inspector:

  1. Make sure "Show Develop menu in menu bar" is enabled in Safari's Advanced preferences.
  2. Under the Develop menu, expand the "Simulator" menu for the simulator you've opened.
  3. Choose the WebView you want to inspect. A new window will open.

Code Signing

Although the app is set up to use Automatic provisioning for Debug builds, you'll need to customize a few of the options. This is because the app makes heavy use of entitlements that require code signing, even for simulator builds.

Edit the file Configuration/HomeAssistant.overrides.xcconfig (which will not exist by default and is ignored by git) and add the following:

DEVELOPMENT_TEAM = YourTeamID
BUNDLE_ID_PREFIX = some.bundle.prefix

Xcode should generate provisioning profiles in your Team ID and our configuration will disable features your team doesn't have like Critical Alerts. You can find your Team ID on Apple's developer portal; it looks something like ABCDEFG123.

Code style

Linters run as part of Pull Request checks. Additionally, some linting requirements can be autocorrected.

# checks for linting problems, doesn't fix
bundle exec fastlane lint
# checks for linting problems and fixes them
bundle exec fastlane autocorrect

In the Xcode project, the autocorrectable linters will not modify your source code but will provide warnings. This project uses several linters:

Continuous Integration

We use Github Actions alongside Fastlane to perform continuous integration both by unit testing and deploying to App Store Connect. Mac Developer ID builds are available as an artifact on every build of master.

Environment variables

Fastlane scripts read from the environment or .env file for configuration like team IDs. See .env.sample for available values.

Deployment

Although all the deployment is done through Github Actions, you can do it manually through Fastlane:

Deployment to App Store Connect

# creates the builds and uploads to the app store
# each save their artifacts to build/
bundle exec fastlane mac build
bundle exec fastlane ios build

Contributing

See CONTRIBUTING.md

LICENSE

Apache-2.0

Credits

The format and some content of this README.md comes from the SwipeIt project.

Home Assistant - A project from the Open Home Foundation

Description
2025.6 (1305) Latest
2025-07-08 06:13:53 -05:00
Languages
Swift 99.2%
Ruby 0.6%
Shell 0.1%