2

i have a rails migration script:

add_index :site_tracking_codes, [:site_id, :is_published], where: "is_published IS TRUE", unique: true

but it generates the index like so:

CREATE UNIQUE INDEX index_site_tracking_codes_on_site_id_and_is_published ON public.site_tracking_codes USING btree (site_id, is_published);

without the where condition. rails version: ~> 4.2.11. postgreSQL 9.6 DB

Tanya
  • 55
  • 1
  • 1
  • 8
  • I wonder if you want `where: "is_published"` instead of `where: "is_published IS TRUE"`. A stab in the dark. – jvillian Sep 22 '20 at 20:00
  • The only thing I can see in the docs is `unique: true` is before the `where: ".."` – Ben Trewern Sep 22 '20 at 22:02
  • @jvillian, @ben-trewern tried the `where: "is_published"` and` unique: true` before `where` .. same results.When i run the migration script this is the console output `add_index(:site_tracking_codes, [:site_id, :is_published], {:unique=>true, :where=>"is_published"}) -> 0.0056s` but the `CREATE UNIQUE INDEX` is missing the where condition – Tanya Sep 24 '20 at 15:47

0 Answers0