원클릭으로
production-database-changes-on-flyio
Query or modify production database records on Fly.io using SSH console and Ecto.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Query or modify production database records on Fly.io using SSH console and Ecto.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Add or change database-backed models using Ecto + SQLite conventions in this codebase.
Add or extend external service adapters using Req, consistent error handling, and config.
Add a new LiveView UI feature following the project's layout, routing, and testing patterns.
Build and compose reusable UI components in Phoenix HEEx with Tailwind CSS.
Build filterable/paginated list pages using embedded ViewModels and Scrivener.
| name | Production Database Changes on Fly.io |
| description | Query or modify production database records on Fly.io using SSH console and Ecto. |
Use this skill when you need to inspect or modify production database records on the Fly.io deployment.
fly status --app sarduty)fly.toml: sarduty)fly status --app sarduty
Note the machine ID (e.g., 87ede0c01595e8). If only one machine exists, you can omit --machine flag.
Use fly ssh console with the eval command:
fly ssh console -a sarduty --machine <MACHINE_ID> -C 'bin/sarduty eval "<ELIXIR_CODE>"'
Critical: Always include Application.ensure_all_started(:sarduty) at the beginning of eval code.
Query by email:
fly ssh console -a sarduty --machine <MACHINE_ID> -C 'bin/sarduty eval "Application.ensure_all_started(:sarduty); user = App.Repo.get_by(App.Accounts.User, email: \"user@example.com\"); IO.inspect(user)"'
Update a field:
fly ssh console -a sarduty --machine <MACHINE_ID> -C 'bin/sarduty eval "Application.ensure_all_started(:sarduty); user = App.Repo.get_by!(App.Accounts.User, email: \"user@example.com\"); changeset = Ecto.Changeset.change(user, is_admin: true); App.Repo.update!(changeset); IO.puts(\"Updated\")"'
Query with Ecto.Query:
fly ssh console -a sarduty --machine <MACHINE_ID> -C 'bin/sarduty eval "Application.ensure_all_started(:sarduty); import Ecto.Query; users = App.Repo.all(from u in App.Accounts.User, where: u.is_admin == true); IO.inspect(users)"'
")\");)IO.inspect() to view resultsget!, update!) for simpler error handlingEcto.Query when using from macroSet user as admin:
fly ssh console -a sarduty --machine 87ede0c01595e8 -C 'bin/sarduty eval "Application.ensure_all_started(:sarduty); user = App.Repo.get_by!(App.Accounts.User, email: \"andrew.wallwork@sfsar.ca\"); changeset = Ecto.Changeset.change(user, is_admin: true); App.Repo.update!(changeset); IO.puts(\"User updated\")"'
List all admin users:
fly ssh console -a sarduty --machine 87ede0c01595e8 -C 'bin/sarduty eval "Application.ensure_all_started(:sarduty); import Ecto.Query; admins = App.Repo.all(from u in App.Accounts.User, where: u.is_admin == true, select: {u.id, u.email}); IO.inspect(admins)"'
"could not lookup Ecto repo": Forgot to start the app. Add Application.ensure_all_started(:sarduty).
"app has no started VMs": Check fly status. Start machine with fly machines start <ID> if needed.
Quote escaping issues: Ensure outer quotes are " and inner quotes are \".