Skip to content

Commit

Permalink
fixed schema doc #102
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Sep 7, 2016
1 parent 32ddc56 commit 3da5b89
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,32 +40,4 @@ Used by db-migrate module to keep track of migrations.
| enabled | int4 | 10 | 1 | 0 | |
| description | text | 2147483647 | 1 | (null) | |
| archived | int4 | 10 | 1 | 0 | |
| parameters | json | 2147483647 | 1 | (null) | deprecated (*) |
| strategy_name | varchar | 255 | 1 | (null) | deprecated (*) |
| strategies | json | 2147483647 | 1 | (null) | |

(*) we migrated from `parmaters` and `strategy_name` to `strategies` which should contain an array of these.

For [aggregate strategies](https:/finn-no/unleash/issues/102) we had the following sql to migrate to the strategies column:

```sql
ALTER TABLE features ADD "strategies" json;

--populate the strategies column
UPDATE features
SET strategies = ('[{"name":"'||f.strategy_name||'","parameters":'||f.parameters||'}]')::json
FROM features as f
WHERE f.name = features.name;
```

In order to migrate back, one can use the following sql (it will loose all, but the first activation strategy):

```sql
UPDATE features
SET strategy_name = f.strategies->0->>'name',
parameters = f.strategies->0->'parameters'
FROM features as f
WHERE f.name = features.name;

ALTER TABLE features DROP COLUMN "strategies";
```

0 comments on commit 3da5b89

Please sign in to comment.