mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-06-28 15:34:39 +08:00
Adding migration step to upgrade from using the ContainsAnyIfProvided operator in StringFilterForm
This commit is contained in:
parent
9481a66fbf
commit
f3732f98ba
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.ContentManagement;
|
|
||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.Core.Common.Models;
|
using Orchard.Core.Common.Models;
|
||||||
using Orchard.Core.Contents.Extensions;
|
using Orchard.Core.Contents.Extensions;
|
||||||
@ -15,13 +14,16 @@ namespace Orchard.Projections {
|
|||||||
public class Migrations : DataMigrationImpl {
|
public class Migrations : DataMigrationImpl {
|
||||||
private readonly IRepository<MemberBindingRecord> _memberBindingRepository;
|
private readonly IRepository<MemberBindingRecord> _memberBindingRepository;
|
||||||
private readonly IRepository<LayoutRecord> _layoutRepository;
|
private readonly IRepository<LayoutRecord> _layoutRepository;
|
||||||
|
private readonly IRepository<FilterRecord> _filterRepository;
|
||||||
|
|
||||||
public Migrations(
|
public Migrations(
|
||||||
IRepository<MemberBindingRecord> memberBindingRepository,
|
IRepository<MemberBindingRecord> memberBindingRepository,
|
||||||
IRepository<LayoutRecord> layoutRepository) {
|
IRepository<LayoutRecord> layoutRepository,
|
||||||
|
IRepository<FilterRecord> filterRepository) {
|
||||||
_memberBindingRepository = memberBindingRepository;
|
_memberBindingRepository = memberBindingRepository;
|
||||||
_layoutRepository = layoutRepository;
|
_layoutRepository = layoutRepository;
|
||||||
|
_filterRepository = filterRepository;
|
||||||
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,8 +361,8 @@ namespace Orchard.Projections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateFrom5() {
|
public int UpdateFrom5() {
|
||||||
SchemaBuilder.AlterTable("LayoutRecord", t => t.AddColumn<string>("GUIdentifier",
|
SchemaBuilder.AlterTable("LayoutRecord", t => t
|
||||||
column => column.WithLength(68)));
|
.AddColumn<string>("GUIdentifier", column => column.WithLength(68)));
|
||||||
|
|
||||||
var layoutRecords = _layoutRepository.Table.Where(l => l.GUIdentifier == null || l.GUIdentifier == "").ToList();
|
var layoutRecords = _layoutRepository.Table.Where(l => l.GUIdentifier == null || l.GUIdentifier == "").ToList();
|
||||||
foreach (var layout in layoutRecords) {
|
foreach (var layout in layoutRecords) {
|
||||||
@ -369,5 +371,20 @@ namespace Orchard.Projections {
|
|||||||
|
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int UpdateFrom6() {
|
||||||
|
// This casts a somewhat wide net, but filters can't be queried by the form they are using and different
|
||||||
|
// types of filters can (and do) use StringFilterForm. However, the "Operator" parameter's value being
|
||||||
|
// "ContainsAnyIfProvided" is very specific.
|
||||||
|
var formStateToReplace = "<Operator>ContainsAnyIfProvided</Operator>";
|
||||||
|
var filterRecordsToUpdate = _filterRepository.Table.Where(f => f.State.Contains(formStateToReplace)).ToList();
|
||||||
|
foreach (var filter in filterRecordsToUpdate) {
|
||||||
|
filter.State = filter.State.Replace(
|
||||||
|
formStateToReplace,
|
||||||
|
"<Operator>ContainsAny</Operator><IgnoreFilterIfValueIsEmpty>true</IgnoreFilterIfValueIsEmpty>");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user