在Rails中,如何在具有特定排序順序的Postgres數據庫遷移中添加索引?按排序順序添加索引?
最終想拉斷此查詢:
CREATE INDEX index_apps_kind_release_date_rating ON apps(kind, itunes_release_date DESC, rating_count DESC);
但是現在在我的移民我有這樣的:
add_index :apps, [:kind, 'itunes_release_date desc', 'rating_count desc'], name: 'index_apps_kind_release_date_rating'
哪個吐出了這一點:
CREATE INDEX "index_apps_kind_release_date_rating" ON "apps" ("kind", "itunes_release_date desc", "rating_count desc")
哪些錯誤出:
PG::Error: ERROR: column "itunes_release_date desc" does not exist
你有[這裏API]檢查(http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/ add_index)?它具有「按排序順序創建索引」 – konyak