mirror of https://github.com/Squidex/squidex.git
49 changed files with 291 additions and 241 deletions
@ -0,0 +1,50 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using System.Threading.Tasks.Dataflow; |
|||
using Squidex.Domain.Apps.Entities.Contents.State; |
|||
using Squidex.Domain.Apps.Entities.Contents.Text; |
|||
using Squidex.Infrastructure.Migrations; |
|||
using Squidex.Infrastructure.States; |
|||
|
|||
namespace Migrate_01.Migrations |
|||
{ |
|||
public sealed class BuildFullTextIndices : IMigration |
|||
{ |
|||
private readonly ITextIndexer textIndexer; |
|||
private readonly IStore<Guid> store; |
|||
|
|||
public BuildFullTextIndices(ITextIndexer textIndexer, IStore<Guid> store) |
|||
{ |
|||
this.textIndexer = textIndexer; |
|||
|
|||
this.store = store; |
|||
} |
|||
|
|||
public async Task UpdateAsync() |
|||
{ |
|||
var snapshotStore = store.GetSnapshotStore<ContentState>(); |
|||
|
|||
var worker = new ActionBlock<ContentState>(state => |
|||
{ |
|||
return textIndexer.IndexAsync(state.SchemaId.Id, state.Id, state.Data, state.DataDraft); |
|||
}, |
|||
new ExecutionDataflowBlockOptions |
|||
{ |
|||
MaxDegreeOfParallelism = Environment.ProcessorCount * 2 |
|||
}); |
|||
|
|||
await snapshotStore.ReadAllAsync((state, version) => worker.SendAsync(state)); |
|||
|
|||
worker.Complete(); |
|||
|
|||
await worker.Completion; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// ==========================================================================
|
|||
// 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; |
|||
using Squidex.Infrastructure.MongoDb; |
|||
|
|||
namespace Migrate_01.Migrations.MongoDb |
|||
{ |
|||
public sealed class RestructureContentCollection : IMigration |
|||
{ |
|||
private readonly IMongoDatabase contentDatabase; |
|||
|
|||
public RestructureContentCollection(IMongoDatabase contentDatabase) |
|||
{ |
|||
this.contentDatabase = contentDatabase; |
|||
} |
|||
|
|||
public async Task UpdateAsync() |
|||
{ |
|||
if (await contentDatabase.CollectionExistsAsync("State_Content_Draft")) |
|||
{ |
|||
await contentDatabase.DropCollectionAsync("State_Contents"); |
|||
await contentDatabase.DropCollectionAsync("State_Content_Published"); |
|||
await contentDatabase.RenameCollectionAsync("State_Content_Draft", "State_Contents"); |
|||
|
|||
var collection = contentDatabase.GetCollection<BsonDocument>("State_Content"); |
|||
|
|||
await collection.UpdateManyAsync(new BsonDocument(), Builders<BsonDocument>.Update.Unset("dt")); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue