remove unique index of TenantId and Name from Site table as site name does not need to be unique. Remove TenantId column from Site table as it is not necessary and should be obtained from the Alias.
This commit is contained in:
@@ -579,7 +579,6 @@ namespace Oqtane.Infrastructure
|
||||
|
||||
site = new Site
|
||||
{
|
||||
TenantId = tenant.TenantId,
|
||||
Name = install.SiteName,
|
||||
LogoFileId = null,
|
||||
FaviconFileId = null,
|
||||
@@ -596,7 +595,8 @@ namespace Oqtane.Infrastructure
|
||||
RenderMode = rendermode,
|
||||
Runtime = runtime,
|
||||
Prerender = (rendermode == RenderModes.Interactive),
|
||||
Hybrid = false
|
||||
Hybrid = false,
|
||||
TenantId = tenant.TenantId
|
||||
};
|
||||
site = sites.AddSite(site);
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Migrations.Tenant
|
||||
{
|
||||
[DbContext(typeof(TenantDBContext))]
|
||||
[Migration("Tenant.10.00.01.02")]
|
||||
public class RemoveSiteTenantId : MultiDatabaseMigration
|
||||
{
|
||||
public RemoveSiteTenantId(IDatabase database) : base(database)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
siteEntityBuilder.DropIndex("IX_Site"); // TenantId, Name
|
||||
siteEntityBuilder.DropColumn("TenantId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,8 @@ namespace Oqtane.Services
|
||||
|
||||
// installation date used for fingerprinting static assets
|
||||
site.Fingerprint = Utilities.GenerateSimpleHash(_configManager.GetSetting("InstallationDate", DateTime.UtcNow.ToString("yyyyMMddHHmm")));
|
||||
|
||||
site.TenantId = alias.TenantId;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -181,7 +183,7 @@ namespace Oqtane.Services
|
||||
{
|
||||
var alias = _tenantManager.GetAlias();
|
||||
var current = _sites.GetSite(site.SiteId, false);
|
||||
if (site.SiteId == alias.SiteId && site.TenantId == alias.TenantId && current != null)
|
||||
if (site.SiteId == alias.SiteId && current != null)
|
||||
{
|
||||
site = _sites.UpdateSite(site);
|
||||
_syncManager.AddSyncEvent(alias, EntityNames.Site, site.SiteId, SyncEventActions.Update);
|
||||
|
||||
Reference in New Issue
Block a user