mirror of https://github.com/Squidex/squidex.git
8 changed files with 65 additions and 14 deletions
@ -0,0 +1,42 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Threading.Tasks; |
|||
using MongoDB.Bson; |
|||
using MongoDB.Driver; |
|||
using Squidex.Infrastructure.Migrations; |
|||
|
|||
namespace Migrate_01.Migrations.MongoDb |
|||
{ |
|||
public sealed class RenameAssetMetadata : IMigration |
|||
{ |
|||
private readonly IMongoDatabase database; |
|||
|
|||
public RenameAssetMetadata(IMongoDatabase database) |
|||
{ |
|||
this.database = database; |
|||
} |
|||
|
|||
public async Task UpdateAsync() |
|||
{ |
|||
var collection = database.GetCollection<BsonDocument>("States_Assets"); |
|||
|
|||
var update1 = |
|||
Builders<BsonDocument>.Update |
|||
.Set("md", new BsonDocument()); |
|||
|
|||
await collection.UpdateManyAsync(new BsonDocument(), update1); |
|||
|
|||
var update2 = |
|||
Builders<BsonDocument>.Update |
|||
.Rename("ph", "md.PixelHeight") |
|||
.Rename("pw", "md.PixelWidth"); |
|||
|
|||
await collection.UpdateManyAsync(new BsonDocument(), update2); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue