一键导入
migration
Write database migrations for PostgreSQL with PostGIS, UUID primary keys, enums, and counter caches
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write database migrations for PostgreSQL with PostGIS, UUID primary keys, enums, and counter caches
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create and manage Solid Queue background jobs with perform_now vs perform_later patterns
Perform deep critical analysis of changes with focus on performance vs sustainability trade-offs
Add controllers and routes following project patterns for organizer namespaces, strong params, and Turbo
Build Rails forms with Tailwind CSS, Turbo integration, and strong params validation
Create and modify Rails models following project conventions for STI, enums, validations, counter caches, and scopes
Create service objects in app/services/ using module namespaces for encapsulation
| name | migration |
| description | Write database migrations for PostgreSQL with PostGIS, UUID primary keys, enums, and counter caches |
| license | MIT |
bin/rails g model ModelName field:type
bin/rails g migration AddFieldNameToModelName field:type
id: :uuid, default: -> { "gen_random_uuid()" }created_at and updated_at always present, null: falset.string "type", default: "ClassName", null: falset.integer "field", default: 0 — enum mapping done in modelt.integer "related_count", default: 0, null: falseclass AddFieldNameToModels < ActiveRecord::Migration[8.0]
def change
add_column :models, :field_name, :string, null: false
add_index :models, :field_name
end
end
def change
add_column :events, :rounds_count, :integer, default: 0, null: false
add_column :events, :event_participants_count, :integer, default: 0, null: false
end
def change
add_column :events, :location, :geography, limit: { srid: 4326, type: "st_point", geographic: true }
execute 'CREATE INDEX index_events_on_location ON events USING GIST (location)'
end
def change
add_index :circuit_standings, [:circuit_id, :player_id], unique: true
add_index :results, [:event_participant_id, :round_id], unique: true
add_index :pods, [:number, :round_id], unique: true
end
def change
add_foreign_key :child_table, :parent_table, column: :parent_id
end
Schema-level (in schema.rb, not migrations):
enable_extension "pgcrypto"
enable_extension "postgis"
db/schema.rb is auto-generated, never edited directlybin/rails db:schema:load uses schema.rb for fast database setupbin/rails db:migrate applies pending migrationsgen_random_uuid() requires pgcrypto extension (enabled in schema)find(params[:id]) works with UUIDs automaticallyt.integer "state", default: 0, null: falseenum :state, { draft: 0, open: 1 }db/schema.rb — Reference for all current columns, types, indexes, foreign keysbin/rails db:setup — Creates DB, loads schema, seedsbin/rails db:migrate — Applies pending migrations