بنقرة واحدة
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 \".