mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
fix: import should not drop built-in strategies
This commit is contained in:
parent
9e1686edab
commit
56cd0d6912
@ -155,13 +155,10 @@ export default class StrategyStore implements IStrategyStore {
|
||||
await this.db(TABLE).insert(rowData).onConflict(['name']).merge();
|
||||
}
|
||||
|
||||
async dropStrategies(): Promise<void> {
|
||||
async dropCustomStrategies(): Promise<void> {
|
||||
await this.db(TABLE)
|
||||
.where({ built_in: 0 }) // eslint-disable-line
|
||||
.delete()
|
||||
.catch((err) =>
|
||||
this.logger.error('Could not drop strategies, error: ', err),
|
||||
);
|
||||
.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ export default class StateService {
|
||||
|
||||
if (dropBeforeImport) {
|
||||
this.logger.info('Dropping existing strategies');
|
||||
await this.strategyStore.deleteAll();
|
||||
await this.strategyStore.dropCustomStrategies();
|
||||
await this.eventStore.store({
|
||||
type: DROP_STRATEGIES,
|
||||
createdBy: userName,
|
||||
|
@ -37,4 +37,5 @@ export interface IStrategyStore extends Store<IStrategy, string> {
|
||||
deprecateStrategy({ name }: Pick<IStrategy, 'name'>): Promise<void>;
|
||||
reactivateStrategy({ name }: Pick<IStrategy, 'name'>): Promise<void>;
|
||||
importStrategy(data: IMinimalStrategy): Promise<void>;
|
||||
dropCustomStrategies(): Promise<void>;
|
||||
}
|
||||
|
8
src/test/fixtures/fake-strategies-store.ts
vendored
8
src/test/fixtures/fake-strategies-store.ts
vendored
@ -64,10 +64,6 @@ export default class FakeStrategiesStore implements IStrategyStore {
|
||||
|
||||
destroy(): void {}
|
||||
|
||||
async dropStrategies(): Promise<void> {
|
||||
return this.deleteAll();
|
||||
}
|
||||
|
||||
async exists(key: string): Promise<boolean> {
|
||||
return this.strategies.some((s) => s.name === key && !s.deprecated);
|
||||
}
|
||||
@ -119,4 +115,8 @@ export default class FakeStrategiesStore implements IStrategyStore {
|
||||
await this.delete(update.name);
|
||||
return this.createStrategy(update);
|
||||
}
|
||||
|
||||
async dropCustomStrategies(): Promise<void> {
|
||||
return this.deleteAll();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user