mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Driver;
|
|
using Squidex.Infrastructure.Migrations;
|
|
|
|
namespace Migrate_01.Migrations
|
|
{
|
|
public sealed class ConvertOldSnapshotStores : IMigration
|
|
{
|
|
private readonly IMongoDatabase database;
|
|
|
|
public ConvertOldSnapshotStores(IMongoDatabase database)
|
|
{
|
|
this.database = database;
|
|
}
|
|
|
|
public Task UpdateAsync()
|
|
{
|
|
var collections = new[]
|
|
{
|
|
"States_Apps",
|
|
"States_Rules",
|
|
"States_Schemas"
|
|
};
|
|
|
|
var update = Builders<BsonDocument>.Update.Rename("State", "Doc");
|
|
|
|
var filter = new BsonDocument();
|
|
|
|
return Task.WhenAll(
|
|
collections
|
|
.Select(x => database.GetCollection<BsonDocument>(x))
|
|
.Select(x => x.UpdateManyAsync(filter, update)));
|
|
}
|
|
}
|
|
}
|
|
|