| Conditions | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | # frozen_string_literal: true |
||
| 8 | def change |
||
| 9 | reversible do |dir| |
||
| 10 | dir.up do |
||
| 11 | MigrationProduct.where("priority < 0").where.not(name: "pending").each do |role| |
||
| 12 | role.decrement!(:priority) |
||
| 13 | end |
||
| 14 | |||
| 15 | add_index MigrationProduct, [:priority, :provider], unique: true |
||
| 16 | end |
||
| 17 | |||
| 18 | dir.down do |
||
| 19 | remove_index MigrationProduct, [:priority, :provider] |
||
| 20 | |||
| 21 | MigrationProduct.where("priority < 0").where.not(name: "pending").each do |role| |
||
| 22 | role.increment!(:priority) |
||
| 23 | end |
||
| 24 | end |
||
| 25 | end |
||
| 26 | end |
||
| 27 | end |
||
| 28 |