본문으로 건너뛰기
cccskills
무료GitHub에 공개

ecto-migrations

Rules for Operately schema migrations (app/priv/repo/migrations/) and data migrations (app/lib/operately/data/change_*.ex). Use when adding, renaming, reviewing, or generating database migrations, ecto.gen.migration, Operately.Data.Change* modules, backfills, schema_migrations version collisions, mix ecto.migrate, or make gen.migration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.6 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Ecto Migrations

Two layers work together:

LayerLocationRole
Schema migrationapp/priv/repo/migrations/*.exsDDL and/or calls a data change; tracked in schema_migrations
Data migrationapp/lib/operately/data/change_NNN_*.exBackfills and data fixes; invoked from a thin schema migration

Creating schema migration files

Always create files in app/priv/repo/migrations/ with:

make gen.migration NAME=add_foo_to_bars

That runs mix ecto.gen.migration inside devenv (see root Makefile gen.migration target) and assigns a unique timestamp version.

Never create or copy migration files by hand (including inventing a YYYYMMDDHHMMSS_*.exs name). Manual timestamps collide across PRs that land close together. Ecto keys migrations by the numeric prefix only, so duplicates cause skipped migrations, re-runs, and production failures (e.g. duplicate_column or missing columns after a rename).

After generating, edit only the body of the generated file. Do not rename the file to “fix” a conflict with another branch — coordinate timestamps via make gen.migration on an up-to-date main instead.

Data migrations

Backfills and one-off data fixes live under app/lib/operately/data/ as Operately.Data.ChangeNNN… modules. A thin schema migration (created with make gen.migration) calls them:

defmodule Operately.Repo.Migrations.BaselineDocumentVersions do
  use Ecto.Migration

  def up do
    Operately.Data.Change110BaselineDocumentVersions.run()
  end

  def down do
    :ok
  end
end

Examples: change_110_baseline_document_versions.ex ← 20260720190200_baseline_document_versions.exs; change_106_backfill_document_names_from_nodes.ex ← 20260720120100_backfill_document_names_from_nodes.exs.

Naming

  • Next unused number: look at the highest change_NNN_*.ex under app/lib/operately/data/ (currently in the 110s).
  • Module: Operately.Data.ChangeNNNDescriptiveName
  • File: change_NNN_descriptive_name.ex
  • Prefer a run/0 entry point (some older modules use up/0).

Do not depend on application modules

Data migrations must not alias live app schemas such as Operately.Goals.Goal or Operately.Activities.Activity. Those modules change over time; a migration that imports them can break on fresh installs months later.

Define minimal inline structs/modules inside the change module with only the fields and helpers the migration needs.

# ❌ DON'T: referencing application modules directly inside migrations
defmodule Operately.Data.Change155MyMigration do
  alias Operately.Repo
  alias Operately.Activities.Activity

  def run do
    from(a in Activity, where: a.action == "task_description_change")
    |> Repo.update_all(set: [content: %{}])
  end
end

# ✅ DO: declare minimal inline structs/modules needed by the migration
defmodule Operately.Data.Change155MyMigration do
  alias Operately.Repo
  alias __MODULE__.Activity

  def run do
    from(a in Activity, where: a.action == "task_description_change")
    |> Repo.update_all(set: [content: %{}])
  end

  defmodule Activity do
    use Operately.Schema

    schema "activities" do
      field :action, :string
      field :content, :map
    end
  end
end

References: change_082_populate_goal_description_changed_activity_goal_name.ex, change_080_create_subscriptions_list_for_tasks.ex, change_110_baseline_document_versions.ex.

(Same rule is summarized in root AGENTS.md under Data Migration Guidelines.)

Idempotency and tests

  • Prefer idempotent run/0 (safe if re-run or if some rows already match the target state).
  • Add tests under app/test/operately/data/change_NNN_*_test.exs (see change_110_baseline_document_versions_test.exs).

Checklist

  • Schema migration created via make gen.migration NAME=...
  • No hand-written or hand-copied app/priv/repo/migrations/*.exs filenames
  • Version prefix is unique among existing migrations before opening the PR
  • Data backfill lives in Operately.Data.ChangeNNN… with inline schemas only
  • Schema migration’s up/0 only delegates to ChangeNNN.run() (plus any DDL)
  • Data change is idempotent where practical and covered by a unit test

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Clean-code engineering standards for writing, refactoring, and reviewing code in any programming language. Use this whenever the user asks to write clean code, follow clean-code principles, refactor for clarity, improve naming, reduce complexity or duplication, separate concerns, tighten error handling, work test-first or do TDD, or otherwise raise code quality, readability, and maintainability. Also use when writing or reviewing Operately APIs or Ecto queries. Apply these rules by default when producing or changing code for a quality-conscious user.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

Defines where UI components belong in Operately (TurboUI-first). Use when creating, changing, reviewing, or migrating UI components, adding features that need UI, or deciding whether to refactor legacy app UI in app/assets/js/components or app/assets/js/features. Covers pure TurboUI components, component reuse, the app bridge pattern, and legacy migration scenarios.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

help-docs

무료

Discover help documentation work from operately git history. Use when the user asks to audit what needs documenting since a release, tag, or SHA, or to identify documentation gaps from code changes. Requires a baseline SHA or tag as input.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

Maintain Operately translations when adding or changing user-visible copy, fixing missing translations, or adding a supported language. Covers shared Gettext/i18next catalogs, glossaries, generation, and completeness checks; excludes translating user-authored content or general prose outside the product.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

mcp-tools

무료

Defines how to add Operately MCP tools (API-first wrappers). Use when creating, changing, or reviewing MCP tools under app/lib/operately_web/mcp/tools/, when the user mentions MCP tools, tool catalog, @expected_tool_names, or when exposing a new Operately capability to ChatGPT/Claude MCP clients.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

Operately frontend data fetching with TanStack Query. Use when adding or changing page loaders, model hooks, Api.* calls, mutations, useLoadedData, Pages.useRefresh, or any web UI backend request. New code must use TanStack. When fixing or extending an existing surface, migrate that surface's API calls to TanStack in the same change.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

operately/operately5872026년 10월 17일 업데이트

operately의 스킬 모두 보기

이 스킬의 문제 신고