1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-18 11:14:57 +02:00
unleash.unleash/src/migrations/20230420125500-v5-strategy-changes.js
Gastón Fournier 5019f4fcbc
chore!: removing userId strategy for new installations of Unleash (#9800)
This removes a strategy that was already deprecated, but only for new
installations.

I tested starting with an installation with this strategy being used and
then updating, and I was still able to edit the strategy, so this should
not impact current users.

On a fresh install the strategy is no longer available.

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2025-06-04 09:30:13 +02:00

70 lines
2.4 KiB
JavaScript

'use strict';
exports.up = function (db, callback) {
db.runSql(
`
-- delete deprecated strategies still present in v4
delete from strategies
where name in ('gradualRolloutUserId', 'gradualRolloutRandom', 'gradualRolloutSessionId')
and deprecated
and not exists (select * from feature_strategies where strategy_name = name limit 1);
-- update strategy descriptions and sort order
update strategies set sort_order = 1, description = 'This strategy turns on / off for your entire userbase. Prefer using "Gradual rollout" strategy (100%=on, 0%=off).' WHERE name = 'default';
update strategies set sort_order = 0 WHERE name = 'flexibleRollout';
`,
callback,
);
};
exports.down = function (db, callback) {
db.runSql(
`
-- restore deleted strategies
insert into strategies (name, description, parameters, deprecated, sort_order) values
('gradualRolloutRandom', 'Randomly activate the feature toggle. No stickiness.', '[
{
"name": "percentage",
"type": "percentage",
"description": "",
"required": false
}
]', true, 3),
('gradualRolloutSessionId', 'Gradually activate feature toggle. Stickiness based on session id.', '[
{
"name": "percentage",
"type": "percentage",
"description": "",
"required": false
},
{
"name": "groupId",
"type": "string",
"description": "Used to define a activation groups, which allows you to correlate across feature toggles.",
"required": true
}
]', true, 4),
('gradualRolloutUserId', 'Gradually activate feature toggle for logged in users. Stickiness based on user id.', '[
{
"name": "percentage",
"type": "percentage",
"description": "",
"required": false
},
{
"name": "groupId",
"type": "string",
"description": "Used to define a activation groups, which allows you to correlate across feature toggles.",
"required": true
}
]', true, 5);
-- revert sort order
update strategies set sort_order = 0 WHERE name = 'default';
update strategies set sort_order = 1 WHERE name = 'flexibleRollout';
`,
callback,
);
};