2023-04-21 11:42:36 +02:00
'use strict' ;
exports . up = function ( db , callback ) {
db . runSql (
`
-- delete deprecated strategies still present in v4
2023-04-21 15:57:54 +02:00
delete from strategies
where name in ( 'gradualRolloutUserId' , 'gradualRolloutRandom' , 'gradualRolloutSessionId' )
and deprecated
2023-04-21 11:42:36 +02:00
and not exists ( select * from feature _strategies where strategy _name = name limit 1 ) ;
2023-04-21 15:57:54 +02:00
2023-04-21 11:42:36 +02:00
-- deprecate strategies on v5
update strategies set deprecated = true where name in ( 'userWithId' ) ;
2023-04-21 15:57:54 +02:00
2023-04-21 11:42:36 +02:00
-- 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' ;
update strategies set description = 'Enable the feature for a specific set of userIds. Prefer using "Gradual rollout" strategy with user id constraints.' WHERE name = 'userWithId' ;
` ,
callback ,
) ;
} ;
exports . down = function ( db , callback ) {
db . runSql (
`
2023-04-21 15:57:54 +02:00
-- 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
2023-04-21 11:42:36 +02:00
} ,
2023-04-21 15:57:54 +02:00
{
"name" : "groupId" ,
"type" : "string" ,
"description" : "Used to define a activation groups, which allows you to correlate across feature toggles." ,
"required" : true
2023-04-21 11:42:36 +02:00
}
2023-04-21 15:57:54 +02:00
] ' , true , 5 ) ;
2023-04-21 11:42:36 +02:00
-- revert sort order
update strategies set sort _order = 0 WHERE name = 'default' ;
update strategies set sort _order = 1 WHERE name = 'flexibleRollout' ;
` ,
callback ,
) ;
} ;