2024-10-02 05:32:13 -04:00
|
|
|
const tags = ['saas']
|
2022-02-28 07:57:41 -05:00
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const migrate = async client => {
|
2022-02-28 07:57:41 -05:00
|
|
|
const { db } = client
|
|
|
|
await db.splittests.updateMany(
|
|
|
|
{},
|
|
|
|
{ $set: { 'versions.$[version].analyticsEnabled': true } },
|
|
|
|
{
|
|
|
|
arrayFilters: [
|
|
|
|
{
|
|
|
|
'version.active': true,
|
|
|
|
'version.analyticsEnabled': { $exists: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
await db.splittests.updateMany(
|
|
|
|
{},
|
|
|
|
{ $set: { 'versions.$[version].analyticsEnabled': false } },
|
|
|
|
{
|
|
|
|
arrayFilters: [
|
|
|
|
{
|
|
|
|
'version.active': false,
|
|
|
|
'version.analyticsEnabled': { $exists: false },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-02 05:32:13 -04:00
|
|
|
const rollback = async client => {
|
2022-02-28 07:57:41 -05:00
|
|
|
const { db } = client
|
|
|
|
await db.splittests.updateMany(
|
|
|
|
{},
|
|
|
|
{ $unset: { 'versions.$[version].analyticsEnabled': 1 } },
|
|
|
|
{
|
|
|
|
arrayFilters: [
|
|
|
|
{ 'version.active': true, 'version.analyticsEnabled': true },
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
await db.splittests.updateMany(
|
|
|
|
{},
|
|
|
|
{ $unset: { 'versions.$[version].analyticsEnabled': 1 } },
|
|
|
|
{
|
|
|
|
arrayFilters: [
|
|
|
|
{ 'version.active': false, 'version.analyticsEnabled': false },
|
|
|
|
],
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2024-10-02 05:32:13 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
tags,
|
|
|
|
migrate,
|
|
|
|
rollback,
|
|
|
|
}
|