1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

Added archivedAt to feature toggle.

Added archived_at to db
This commit is contained in:
andreas-unleash 2022-06-03 12:00:19 +03:00
parent 937ba922e0
commit c14e2d17b0
3 changed files with 17 additions and 3 deletions

View File

@ -17,6 +17,8 @@ const FEATURE_COLUMNS = [
'created_at', 'created_at',
'impression_data', 'impression_data',
'last_seen_at', 'last_seen_at',
'archived',
'archived_at',
]; ];
export interface FeaturesTable { export interface FeaturesTable {
@ -29,6 +31,8 @@ export interface FeaturesTable {
last_seen_at?: Date; last_seen_at?: Date;
created_at?: Date; created_at?: Date;
impression_data: boolean; impression_data: boolean;
archived?: boolean;
archived_at?: Date;
} }
const TABLE = 'features'; const TABLE = 'features';
@ -227,9 +231,10 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
} }
async archive(name: string): Promise<FeatureToggle> { async archive(name: string): Promise<FeatureToggle> {
const now = new Date();
const row = await this.db(TABLE) const row = await this.db(TABLE)
.where({ name }) .where({ name })
.update({ archived: true }) .update({ archived: true, archived_at: now })
.returning(FEATURE_COLUMNS); .returning(FEATURE_COLUMNS);
return this.rowToFeature(row[0]); return this.rowToFeature(row[0]);
} }
@ -243,7 +248,7 @@ export default class FeatureToggleStore implements IFeatureToggleStore {
async revive(name: string): Promise<FeatureToggle> { async revive(name: string): Promise<FeatureToggle> {
const row = await this.db(TABLE) const row = await this.db(TABLE)
.where({ name }) .where({ name })
.update({ archived: false }) .update({ archived: false, archived_at: null })
.returning(FEATURE_COLUMNS); .returning(FEATURE_COLUMNS);
return this.rowToFeature(row[0]); return this.rowToFeature(row[0]);
} }

View File

@ -45,6 +45,7 @@ export interface FeatureToggleDTO {
type?: string; type?: string;
stale?: boolean; stale?: boolean;
archived?: boolean; archived?: boolean;
archivedAt?: Date;
createdAt?: Date; createdAt?: Date;
impressionData?: boolean; impressionData?: boolean;
} }
@ -52,7 +53,6 @@ export interface FeatureToggleDTO {
export interface FeatureToggle extends FeatureToggleDTO { export interface FeatureToggle extends FeatureToggleDTO {
project: string; project: string;
lastSeenAt?: Date; lastSeenAt?: Date;
createdAt?: Date;
variants?: IVariant[]; variants?: IVariant[];
} }

View File

@ -0,0 +1,9 @@
'use strict';
exports.up = function (db, callback) {
db.runSql('ALTER TABLE features ADD "archived_at" date;', callback);
};
exports.down = function (db, callback) {
db.runSql('ALTER TABLE features DROP COLUMN "archived_at";', callback);
};