2017-01-14 00:02:25 +08:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.Data.Migration;
|
|
|
|
|
using Orchard.OutputCache.Models;
|
2015-12-14 05:21:02 +08:00
|
|
|
|
|
|
|
|
|
namespace Orchard.OutputCache {
|
|
|
|
|
public class Migrations : DataMigrationImpl {
|
2017-01-14 00:02:25 +08:00
|
|
|
|
|
|
|
|
|
private readonly IOrchardServices _orchardServices;
|
|
|
|
|
|
|
|
|
|
public Migrations(IOrchardServices orchardServices) {
|
|
|
|
|
_orchardServices = orchardServices;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 05:21:02 +08:00
|
|
|
|
public int Create() {
|
|
|
|
|
|
|
|
|
|
SchemaBuilder.CreateTable("CacheParameterRecord",
|
|
|
|
|
table => table
|
|
|
|
|
.Column<int>("Id", c => c.PrimaryKey().Identity())
|
|
|
|
|
.Column<int>("Duration")
|
|
|
|
|
.Column<int>("GraceTime")
|
|
|
|
|
.Column<string>("RouteKey", c => c.WithLength(255))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return 7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom1() {
|
|
|
|
|
SchemaBuilder.CreateTable("CacheParameterRecord",
|
|
|
|
|
table => table
|
|
|
|
|
.Column<int>("Id", c => c.PrimaryKey().Identity())
|
|
|
|
|
.Column<int>("Duration")
|
|
|
|
|
.Column<string>("RouteKey", c => c.WithLength(255))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom2() {
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom3() {
|
|
|
|
|
SchemaBuilder.AlterTable("CacheParameterRecord",
|
|
|
|
|
table => table
|
|
|
|
|
.AddColumn<int>("MaxAge")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom4() {
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom5() {
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int UpdateFrom6() {
|
|
|
|
|
SchemaBuilder.AlterTable("CacheParameterRecord",
|
|
|
|
|
table => {
|
|
|
|
|
table.DropColumn("MaxAge");
|
|
|
|
|
table.AddColumn<int>("GraceTime");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return 7;
|
|
|
|
|
}
|
2017-01-14 00:02:25 +08:00
|
|
|
|
|
|
|
|
|
public int UpdateFrom7() {
|
|
|
|
|
var cacheSettings = _orchardServices.WorkContext.CurrentSite.As<CacheSettingsPart>();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(cacheSettings.VaryByQueryStringParameters)) {
|
|
|
|
|
// Prevent behavior from changing if vary on querystring was used prior to introduction of exclusive mode
|
|
|
|
|
cacheSettings.VaryByQueryStringIsExclusive = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
cacheSettings.VaryByQueryStringIsExclusive = true; // Default mode
|
|
|
|
|
};
|
|
|
|
|
return 8;
|
|
|
|
|
}
|
2015-12-14 05:21:02 +08:00
|
|
|
|
}
|
2013-05-25 08:16:57 +08:00
|
|
|
|
}
|