mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding upgrade steps for Orchard.Taxonomies
--HG-- branch : 1.x
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Upgrade.Controllers {
|
||||
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to migrate Orchard.ContentPicker.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
try {
|
||||
_upgradeService.CopyTable("Navigation_ContentMenuItemPartRecord", "Orchard_ContentPicker_ContentMenuItemPartRecord");
|
||||
_upgradeService.CopyTable("Navigation_ContentMenuItemPartRecord", "Orchard_ContentPicker_ContentMenuItemPartRecord", new string[0]);
|
||||
|
||||
_orchardServices.Notifier.Information(T("Content Picker menu items were migrated successfully."));
|
||||
}
|
||||
|
||||
@@ -49,7 +49,11 @@ namespace Upgrade.Controllers {
|
||||
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to migrate Contrib.Taxonomies.")))
|
||||
return new HttpUnauthorizedResult();
|
||||
try {
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TermPartRecord", "Orchard_Taxonomies_TermPartRecord");
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TaxonomyPartRecord", "Orchard_Taxonomies_TaxonomyPartRecord", new string[0]);
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TermContentItem", "Orchard_Taxonomies_TermContentItem", new [] { "Id" });
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TermPartRecord", "Orchard_Taxonomies_TermPartRecord", new string[0]);
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TermsPartRecord", "Orchard_Taxonomies_TermsPartRecord", new string[0]);
|
||||
_upgradeService.CopyTable("Contrib_Taxonomies_TermWidgetPartRecord", "Orchard_Taxonomies_TermWidgetPartRecord", new string[0]);
|
||||
|
||||
_orchardServices.Notifier.Information(T("Taxonomies were migrated successfully."));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using Orchard;
|
||||
|
||||
namespace Upgrade.Services {
|
||||
public interface IUpgradeService : IDependency {
|
||||
void CopyTable(string fromTableName, string toTableName);
|
||||
void CopyTable(string fromTableName, string toTableName, string[] ignoreColumns);
|
||||
void ExecuteReader(string sqlStatement, Action<IDataReader, IDbConnection> action);
|
||||
string GetPrefixedTableName(string tableName);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Transactions;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Logging;
|
||||
@@ -20,7 +19,7 @@ namespace Upgrade.Services {
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public void CopyTable(string fromTableName, string toTableName) {
|
||||
public void CopyTable(string fromTableName, string toTableName, string[] ignoreColumns) {
|
||||
var fromPrefixedTableName = GetPrefixedTableName(fromTableName);
|
||||
var toPrefixedTableName = GetPrefixedTableName(toTableName);
|
||||
|
||||
@@ -47,6 +46,10 @@ namespace Upgrade.Services {
|
||||
var statement = String.Format("INSERT INTO {0} (", toPrefixedTableName);
|
||||
|
||||
foreach (var keyValuePair in record) {
|
||||
if (ignoreColumns.Contains(keyValuePair.Key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
statement += keyValuePair.Key;
|
||||
if (keyValuePair.Key != record.Last().Key) {
|
||||
statement += ", ";
|
||||
@@ -56,6 +59,9 @@ namespace Upgrade.Services {
|
||||
statement += ") VALUES ( ";
|
||||
|
||||
foreach (var keyValuePair in record) {
|
||||
if (ignoreColumns.Contains(keyValuePair.Key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var parameter = command.CreateParameter();
|
||||
parameter.ParameterName = "@" + keyValuePair.Key;
|
||||
|
||||
Reference in New Issue
Block a user