在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