今日、移行中に部分的な postgres インデックスをテーブルに追加したいという状況がありました。当然のことながら、この種のものは、使用するレールではまだ不可能ですadd_index
(いつか来る予定です)
execute
そのため、移行ではステートメントを使用する必要があります。
さて、schema.rb
このコメントが一番上にあります:
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
残念ながら、カスタム DML がある場合、このステートメントはほとんど役に立たないため、このexecute
ステートメントは追跡されません。schema.rb
schema.rb
execute
DML を含むステートメントを強制的にschema.rb
.