diff --git a/src/main/java/com/featureprobe/api/Application.java b/src/main/java/com/featureprobe/api/Application.java index 86670de..a7753a6 100644 --- a/src/main/java/com/featureprobe/api/Application.java +++ b/src/main/java/com/featureprobe/api/Application.java @@ -4,7 +4,9 @@ import io.swagger.v3.oas.annotations.info.Info; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; +@EnableCaching @SpringBootApplication @OpenAPIDefinition(info = @Info(title = "Feature Probe API", version = "1.0", description = "Feature Probe API")) public class Application { diff --git a/src/main/java/com/featureprobe/api/service/EnvironmentService.java b/src/main/java/com/featureprobe/api/service/EnvironmentService.java index 0ab7bd5..343854b 100644 --- a/src/main/java/com/featureprobe/api/service/EnvironmentService.java +++ b/src/main/java/com/featureprobe/api/service/EnvironmentService.java @@ -24,6 +24,7 @@ import com.featureprobe.sdk.server.FeatureProbe; import lombok.AllArgsConstructor; import org.apache.commons.lang3.StringUtils; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,6 +53,7 @@ public class EnvironmentService { private static final String LIMITER_TOGGLE_KEY = "FeatureProbe_env_limiter"; @Transactional(rollbackFor = Exception.class) + @CacheEvict(value="all_sdk_key_map", allEntries=true) public EnvironmentResponse create(String projectKey, EnvironmentCreateRequest createRequest) { validateLimit(projectKey); Project project = projectRepository.findByKey(projectKey).get(); diff --git a/src/main/java/com/featureprobe/api/service/GuestService.java b/src/main/java/com/featureprobe/api/service/GuestService.java index 2ed7d97..564a68c 100644 --- a/src/main/java/com/featureprobe/api/service/GuestService.java +++ b/src/main/java/com/featureprobe/api/service/GuestService.java @@ -45,9 +45,9 @@ public class GuestService { "`description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, " + "`client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) " + "VALUES (${organization_id}, 'feature toggle01', 'feature_toggle01', '', 'boolean', 0, " + - "'[{\\\"value\\\":\\\"false\\\", \\\"name\\\":\\\"不可见\\\"," + - "\\\"description\\\":\\\"运营活动对用户不可见\\\"},{\\\"value\\\":" + - "\\\"true\\\",\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"运营活动对用户可见\\\"}]', " + + "'[{\\\"value\\\":\\\"false\\\", \\\"name\\\":\\\"disabled\\\"," + + "\\\"description\\\":\\\"\\\"},{\\\"value\\\":" + + "\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]', " + "'${project_key}', 0, 1, 0, ${user_id}, ${user_id}, now(), now())", "INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " + @@ -55,34 +55,34 @@ public class GuestService { "`modified_time`) VALUES (${organization_id}, 'feature_toggle01', 'online', '${project_key}', " + "1, 1, '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0},\\\"defaultServe\\\":" + "{\\\"select\\\":1},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":" + - "\\\"不可见\\\",\\\"description\\\":\\\"运营活动对用户不可见\\\"},{\\\"value\\\":\\\"true\\\"," + - "\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"运营活动对用户可见\\\"}]}', 0, " + + "\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," + + "\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]}', 0, " + "${user_id}, ${user_id}, now(), now())", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle01', 'online', 1, 'true', 1, '可见')", + "'feature_toggle01', 'online', 1, 'true', 1, 'enabled')", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle01', 'online', 1, 'false', 0, '不可见')", + "'feature_toggle01', 'online', 1, 'false', 0, 'disabled')", "INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " + "`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " + "`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " + "'feature_toggle01', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," + "\\\"defaultServe\\\":{\\\"select\\\":1},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\"," + - "\\\"name\\\":\\\"不可见\\\",\\\"description\\\":\\\"运营活动对用户不可见\\\"}," + - "{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"" + - "运营活动对用户可见\\\"}]}', 1, 1, 0, now(), ${user_id}, now(), ${user_id})", + "\\\"name\\\":\\\"disabled\\\",\\\"description\\\":\\\"\\\"}," + + "{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"" + + "\\\"}]}', 1, 1, 0, now(), ${user_id}, now(), ${user_id})", "INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " + "`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " + "`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle02', " + "'feature_toggle02', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"" + - "不可见\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":" + - "\\\"可见\\\",\\\"description\\\":\\\"\\\"}]', '${project_key}', " + + "disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":" + + "\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]', '${project_key}', " + "0, 1, 0, ${user_id}, ${user_id}, now(), now())", "INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " + @@ -92,19 +92,19 @@ public class GuestService { "\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," + "\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," + "\\\"numberType\\\":false,\\\"datetimeType\\\":false,\\\"semVerType\\\":false}]," + - "\\\"name\\\":\\\"测试组可见\\\",\\\"serve\\\":{\\\"select\\\":1},\\\"notEmptyConditions\\\":true}]," + + "\\\"name\\\":\\\"\\\",\\\"serve\\\":{\\\"select\\\":1},\\\"notEmptyConditions\\\":true}]," + "\\\"disabledServe\\\":{\\\"select\\\":0},\\\"defaultServe\\\":{\\\"select\\\":0}," + - "\\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"不可见\\\"," + - "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"可见\\\"," + + "\\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"disabled\\\"," + + "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"enabled\\\"," + "\\\"description\\\":\\\"\\\"}]}', 0, ${user_id}, ${user_id}, now(), now())", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle02', 'online', 1, 'true', 1, '可见')", + "'feature_toggle02', 'online', 1, 'true', 1, 'enabled')", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle02', 'online', 1, 'false', 0, '不可见')", + "'feature_toggle02', 'online', 1, 'false', 0, 'disabled')", "INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " + "`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " + @@ -113,18 +113,18 @@ public class GuestService { "\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," + "\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," + "\\\"numberType\\\":false,\\\"datetimeType\\\":false,\\\"semVerType\\\":false}]," + - "\\\"name\\\":\\\"测试组可见\\\",\\\"serve\\\":{\\\"select\\\":1}," + + "\\\"name\\\":\\\"\\\",\\\"serve\\\":{\\\"select\\\":1}," + "\\\"notEmptyConditions\\\":true}],\\\"disabledServe\\\":{\\\"select\\\":0}," + "\\\"defaultServe\\\":{\\\"select\\\":0},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\"," + - "\\\"name\\\":\\\"不可见\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," + - "\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"\\\"}]}', 0, 1, 0, now(), ${user_id}, " + + "\\\"name\\\":\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," + + "\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]}', 0, 1, 0, now(), ${user_id}, " + "now(), ${user_id})", "INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " + "`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " + "`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle03', " + - "'feature_toggle03', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"不可见\\\"," + - "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"可见\\\"," + + "'feature_toggle03', '', 'boolean', 0, '[{\\\"value\\\":\\\"false\\\",\\\"name\\\":\\\"disabled\\\"," + + "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\",\\\"name\\\":\\\"enabled\\\"," + "\\\"description\\\":\\\"\\\"}]', '${project_key}', 0, 1, 0, ${user_id}, ${user_id}, now(), now())", "INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " + @@ -132,33 +132,33 @@ public class GuestService { "VALUES (${organization_id}, 'feature_toggle03', 'online', '${project_key}', 1, 0, " + "'{\\\"rules\\\":[], \\\"disabledServe\\\":{\\\"select\\\":0},\\\"defaultServe\\\":" + "{\\\"split\\\":[6000,4000]}, \\\"variations\\\":[{\\\"value\\\":\\\"false\\\",\\\"name\\\":" + - "\\\"不可见\\\",\\\"description\\\":\\\"运营活动对用户不可见\\\"},{\\\"value\\\":\\\"true\\\"," + - "\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"运营活动对用户可见\\\"}]}', 0, " + + "\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"true\\\"," + + "\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]}', 0, " + "${user_id}, ${user_id}, now(), now())", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle03', 'online', 1, 'true', 1, '可见')", + "'feature_toggle03', 'online', 1, 'true', 1, 'enabled')", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + - "'feature_toggle03', 'online', 1, 'false', 0, '不可见')", + "'feature_toggle03', 'online', 1, 'false', 0, 'disabled')", "INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, " + "`comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, " + "`created_time`, `modified_by`) VALUES (${organization_id}, '${project_key}', 'online', " + "'feature_toggle03', '', '{\\\"rules\\\":[],\\\"disabledServe\\\":{\\\"select\\\":0}," + "\\\"defaultServe\\\":{\\\"split\\\":[8000,2000]},\\\"variations\\\":[{\\\"value\\\":\\\"false\\\"," + - "\\\"name\\\":\\\"不可见\\\",\\\"description\\\":\\\"运营活动对用户不可见\\\"},{\\\"value\\\"" + - ":\\\"true\\\",\\\"name\\\":\\\"可见\\\",\\\"description\\\":\\\"运营活动对用户可见\\\"}]}', 0, " + + "\\\"name\\\":\\\"disabled\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\"" + + ":\\\"true\\\",\\\"name\\\":\\\"enabled\\\",\\\"description\\\":\\\"\\\"}]}', 0, " + "1, 0, now(), ${user_id}, now(), ${user_id})", "INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, " + "`variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, " + "`created_by`, `created_time`, `modified_time`) VALUES (${organization_id}, 'feature toggle04', " + "'feature_toggle04', '', 'number', 1, '[{\\\"value\\\":\\\"10\\\",\\\"name\\\":\\\"$10\\\"," + - "\\\"description\\\":\\\"商品价格为10美元\\\"},{\\\"value\\\":\\\"20\\\",\\\"name\\\":\\\"$20\\\"," + - "\\\"description\\\":\\\"商品价格为10美元\\\"}]', '${project_key}', 0, 1, 0, ${user_id}, " + + "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"20\\\",\\\"name\\\":\\\"$20\\\"," + + "\\\"description\\\":\\\"\\\"}]', '${project_key}', 0, 1, 0, ${user_id}, " + "${user_id}, now(), now())", "INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, " + @@ -168,16 +168,16 @@ public class GuestService { "\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," + "\\\"objects\\\":[\\\"00001\\\",\\\"00002\\\"],\\\"segmentType\\\":false," + "\\\"numberType\\\":false,\\\"datetimeType\\\":false,\\\"semVerType\\\":false}]," + - "\\\"name\\\":\\\"00001, 00002 用户商品价格为$10\\\",\\\"serve\\\":{\\\"select\\\":0}," + + "\\\"name\\\":\\\"\\\",\\\"serve\\\":{\\\"select\\\":0}," + "\\\"notEmptyConditions\\\":true},{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," + "\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\"," + "\\\"objects\\\":[\\\"00003\\\"],\\\"segmentType\\\":false,\\\"numberType\\\":false," + - "\\\"datetimeType\\\":false,\\\"semVerType\\\":false}],\\\"name\\\":\\\"00003 用户商品价格为$20\\\"," + + "\\\"datetimeType\\\":false,\\\"semVerType\\\":false}],\\\"name\\\":\\\"\\\"," + "\\\"serve\\\":{\\\"select\\\":1},\\\"notEmptyConditions\\\":true}]," + "\\\"disabledServe\\\":{\\\"select\\\":1},\\\"defaultServe\\\":{\\\"select\\\":1}," + "\\\"variations\\\":[{\\\"value\\\":\\\"10\\\",\\\"name\\\":\\\"$10\\\"," + - "\\\"description\\\":\\\"商品价格为10美元\\\"},{\\\"value\\\":\\\"20\\\",\\\"name\\\":\\\"$20\\\"," + - "\\\"description\\\":\\\"商品价格为20美元\\\"}]}', 0, ${user_id}, ${user_id}, now(), now())", + "\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"20\\\",\\\"name\\\":\\\"$20\\\"," + + "\\\"description\\\":\\\"\\\"}]}', 0, ${user_id}, ${user_id}, now(), now())", "INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, " + "`toggle_version`, `value`, `value_index`, `name`) VALUES (${organization_id}, '${project_key}', " + @@ -193,16 +193,16 @@ public class GuestService { "'feature_toggle04', '', '{\\\"rules\\\":[{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\"," + "\\\"subject\\\":\\\"userId\\\",\\\"predicate\\\":\\\"is one of\\\",\\\"objects\\\":[\\\"00001\\\"," + "\\\"00002\\\"],\\\"segmentType\\\":false,\\\"numberType\\\":false,\\\"datetimeType\\\":false," + - "\\\"semVerType\\\":false}],\\\"name\\\":\\\"00001, 00002 用户商品价格为$10\\\"," + + "\\\"semVerType\\\":false}],\\\"name\\\":\\\"\\\"," + "\\\"serve\\\":{\\\"select\\\":0},\\\"notEmptyConditions\\\":true}," + "{\\\"conditions\\\":[{\\\"type\\\":\\\"string\\\",\\\"subject\\\":\\\"userId\\\"," + "\\\"predicate\\\":\\\"is one of\\\",\\\"objects\\\":[\\\"00003\\\"],\\\"segmentType\\\":false," + "\\\"numberType\\\":false,\\\"datetimeType\\\":false,\\\"semVerType\\\":false}]," + - "\\\"name\\\":\\\"00003 用户商品价格为$20\\\",\\\"serve\\\":{\\\"select\\\":1}," + + "\\\"name\\\":\\\"\\\",\\\"serve\\\":{\\\"select\\\":1}," + "\\\"notEmptyConditions\\\":true}],\\\"disabledServe\\\":{\\\"select\\\":1}," + "\\\"defaultServe\\\":{\\\"select\\\":1},\\\"variations\\\":[{\\\"value\\\":\\\"10\\\"," + - "\\\"name\\\":\\\"$10\\\",\\\"description\\\":\\\"商品价格为10美元\\\"},{\\\"value\\\":\\\"20\\\"," + - "\\\"name\\\":\\\"$20\\\",\\\"description\\\":\\\"商品价格为20美元\\\"}]}', 0, 1, 0, now(), " + + "\\\"name\\\":\\\"$10\\\",\\\"description\\\":\\\"\\\"},{\\\"value\\\":\\\"20\\\"," + + "\\\"name\\\":\\\"$20\\\",\\\"description\\\":\\\"\\\"}]}', 0, 1, 0, now(), " + "${user_id}, now(), ${user_id})" }; diff --git a/src/main/java/com/featureprobe/api/service/ProjectService.java b/src/main/java/com/featureprobe/api/service/ProjectService.java index 1f4ebbc..8f778a9 100644 --- a/src/main/java/com/featureprobe/api/service/ProjectService.java +++ b/src/main/java/com/featureprobe/api/service/ProjectService.java @@ -20,6 +20,7 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.persistence.EntityManager; @@ -43,6 +44,7 @@ public class ProjectService { private static final String LIMITER_TOGGLE_KEY = "FeatureProbe_project_limiter"; @Transactional(rollbackFor = Exception.class) + @CacheEvict(value="all_sdk_key_map", allEntries=true) public ProjectResponse create(ProjectCreateRequest createRequest) { validateLimit(); return ProjectMapper.INSTANCE.entityToResponse(createProject(createRequest)); diff --git a/src/main/java/com/featureprobe/api/service/ServerService.java b/src/main/java/com/featureprobe/api/service/ServerService.java index 7ca66a9..9f1cc4f 100644 --- a/src/main/java/com/featureprobe/api/service/ServerService.java +++ b/src/main/java/com/featureprobe/api/service/ServerService.java @@ -17,6 +17,7 @@ import com.featureprobe.api.service.aspect.ExcludeTenant; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import javax.persistence.EntityManager; @@ -45,7 +46,7 @@ public class ServerService { @PersistenceContext public EntityManager entityManager; - + @Cacheable(value="all_sdk_key_map") public SdkKeyResponse queryAllSdkKeys() { SdkKeyResponse sdkKeyResponse = new SdkKeyResponse(); List environments = environmentRepository.findAll(); diff --git a/src/main/resources/config/application-online.yml b/src/main/resources/config/application-online.yml index c1a0451..a70ed9e 100644 --- a/src/main/resources/config/application-online.yml +++ b/src/main/resources/config/application-online.yml @@ -46,5 +46,7 @@ app: - /api/server/toggles - /api/server/sdk_keys - /api/server/events + - /api/v3/api-docs.yaml + - /api/actuator/health guest-disabled: true guest-default-password: Guest_12345 diff --git a/src/main/resources/db/migration/V23__midify_admin_init_toggles.sql b/src/main/resources/db/migration/V23__midify_admin_init_toggles.sql new file mode 100644 index 0000000..05c7e58 --- /dev/null +++ b/src/main/resources/db/migration/V23__midify_admin_init_toggles.sql @@ -0,0 +1,53 @@ +DELETE from `toggle` where `key` = "color_ab_test" AND organization_id=1; +DELETE from `targeting` where `toggle_key` = "color_ab_test" AND organization_id=1; +DELETE from `toggle` where `key` = "header_skin" AND organization_id=1; +DELETE from `targeting` where `toggle_key` = "header_skin" AND organization_id=1; +DELETE from `toggle` where `key` = "promotion_activity" AND organization_id=1; +DELETE from `targeting` where `toggle_key` = "promotion_activity" AND organization_id=1; +DELETE from `toggle` where `key` = "service_degrade" AND organization_id=1; +DELETE from `targeting` where `toggle_key` = "service_degrade" AND organization_id=1; + +INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature toggle01', 'feature_toggle01', '', 'boolean', 0, '[{\"value\":\"false\", \"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]', 'My_first_Project', 0, 1, 0, 1, 1, now(), now()); + +INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, `disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature_toggle01', 'online', 'My_first_Project', 1, 1, '{\"rules\":[],\"disabledServe\":{\"select\":0},\"defaultServe\":{\"select\":1},\"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 0, 1, 1, now(), now()); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle01', 'online', 1, 'true', 1, 'enabled'); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle01', 'online', 1, 'false', 0, 'disabled'); + +INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, `comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, `created_time`, `modified_by`) VALUES (1, 'My_first_Project', 'online', 'feature_toggle01', '', '{\"rules\":[],\"disabledServe\":{\"select\":0},\"defaultServe\":{\"select\":1},\"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 1, 1, 0, now(), 1, now(), 1); + + +INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature toggle02', 'feature_toggle02', '', 'boolean', 0, '[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]', 'My_first_Project', 0, 1, 0, 1, 1, now(), now()); + +INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, `disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature_toggle02', 'online', 'My_first_Project', 1, 0, '{\"rules\":[{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00001\",\"00002\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":1},\"notEmptyConditions\":true}],\"disabledServe\":{\"select\":0},\"defaultServe\":{\"select\":0},\"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 0, 1, 1, now(), now()); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle02', 'online', 1, 'true', 1, 'enabled'); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle02', 'online', 1, 'false', 0, 'disabled'); + +INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, `comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, `created_time`, `modified_by`) VALUES (1, 'My_first_Project', 'online', 'feature_toggle02', '', '{\"rules\":[{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00001\",\"00002\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":1},\"notEmptyConditions\":true}],\"disabledServe\":{\"select\":0},\"defaultServe\":{\"select\":0},\"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 0, 1, 0, now(), 1, now(), 1); + + + +INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature toggle03', 'feature_toggle03', '', 'boolean', 0, '[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]', 'My_first_Project', 0, 1, 0, 1, 1, now(), now()); + +INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, `disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature_toggle03', 'online', 'My_first_Project', 1, 0, '{\"rules\":[], \"disabledServe\":{\"select\":0},\"defaultServe\":{\"split\":[6000,4000]}, \"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 0, 1, 1, now(), now()); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle03', 'online', 1, 'true', 1, 'enabled'); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle03', 'online', 1, 'false', 0, 'disabled'); + +INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, `comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, `created_time`, `modified_by`) VALUES (1, 'My_first_Project', 'online', 'feature_toggle03', '', '{\"rules\":[],\"disabledServe\":{\"select\":0},\"defaultServe\":{\"split\":[8000,2000]},\"variations\":[{\"value\":\"false\",\"name\":\"disabled\",\"description\":\"\"},{\"value\":\"true\",\"name\":\"enabled\",\"description\":\"\"}]}', 0, 1, 0, now(), 1, now(), 1); + + + +INSERT INTO `toggle` (`organization_id`, `name`, `key`, `description`, `return_type`, `disabled_serve`, `variations`, `project_key`, `archived`, `client_availability`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature toggle04', 'feature_toggle04', '', 'number', 1, '[{\"value\":\"10\",\"name\":\"$10\",\"description\":\"\"},{\"value\":\"20\",\"name\":\"$20\",\"description\":\"\"}]', 'My_first_Project', 0, 1, 0, 1, 1, now(), now()); + +INSERT INTO `targeting` (`organization_id`, `toggle_key`, `environment_key`, `project_key`, `version`, `disabled`, `content`, `deleted`, `modified_by`, `created_by`, `created_time`, `modified_time`) VALUES (1, 'feature_toggle04', 'online', 'My_first_Project', 1, 0, '{\"rules\":[{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00001\",\"00002\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":0},\"notEmptyConditions\":true},{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00003\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":1},\"notEmptyConditions\":true}],\"disabledServe\":{\"select\":1},\"defaultServe\":{\"select\":1},\"variations\":[{\"value\":\"10\",\"name\":\"$10\",\"description\":\"\"},{\"value\":\"20\",\"name\":\"$20\",\"description\":\"\"}]}', 0, 1, 1, now(), now()); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle04', 'online', 1, '20', 1, '$20'); + +INSERT INTO `variation_history` (`organization_id`, `project_key`, `toggle_key`, `environment_key`, `toggle_version`, `value`, `value_index`, `name`) VALUES (1, 'My_first_Project', 'feature_toggle04', 'online', 1, '10', 0, '$10'); + +INSERT INTO `targeting_version` (`organization_id`, `project_key`, `environment_key`, `toggle_key`, `comment`, `content`, `disabled`, `version`, `deleted`, `modified_time`, `created_by`, `created_time`, `modified_by`) VALUES (1, 'My_first_Project', 'online', 'feature_toggle04', '', '{\"rules\":[{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00001\",\"00002\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":0},\"notEmptyConditions\":true},{\"conditions\":[{\"type\":\"string\",\"subject\":\"userId\",\"predicate\":\"is one of\",\"objects\":[\"00003\"],\"segmentType\":false,\"numberType\":false,\"datetimeType\":false,\"semVerType\":false}],\"name\":\"\",\"serve\":{\"select\":1},\"notEmptyConditions\":true}],\"disabledServe\":{\"select\":1},\"defaultServe\":{\"select\":1},\"variations\":[{\"value\":\"10\",\"name\":\"$10\",\"description\":\"\"},{\"value\":\"20\",\"name\":\"$20\",\"description\":\"\"}]}', 0, 1, 0, now(), 1, now(), 1); \ No newline at end of file