allow modules to be able to specify the databases they support
This commit is contained in:
@ -476,7 +476,7 @@ namespace Oqtane.Infrastructure
|
|||||||
{
|
{
|
||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
if (index != (versions.Length - 1))
|
if (index != (versions.Length - 1) && ModuleSupportsDatabase(moduleDefinition.Databases, tenant.DBType))
|
||||||
{
|
{
|
||||||
for (var i = (index + 1); i < versions.Length; i++)
|
for (var i = (index + 1); i < versions.Length; i++)
|
||||||
{
|
{
|
||||||
@ -789,5 +789,21 @@ namespace Oqtane.Infrastructure
|
|||||||
_configManager.AddOrUpdateSetting(SettingKeys.AvailableDatabasesSection, databases, true);
|
_configManager.AddOrUpdateSetting(SettingKeys.AvailableDatabasesSection, databases, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool ModuleSupportsDatabase(string databases, string dbtype)
|
||||||
|
{
|
||||||
|
// check if module supports tenant database
|
||||||
|
if (!string.IsNullOrEmpty(databases))
|
||||||
|
{
|
||||||
|
foreach (var database in databases.Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (dbtype.ToLower().Contains(database.ToLower()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.IsNullOrEmpty(databases);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,7 @@ namespace Oqtane.Repository
|
|||||||
if (siteId != -1)
|
if (siteId != -1)
|
||||||
{
|
{
|
||||||
var siteKey = _tenants.GetAlias().SiteKey;
|
var siteKey = _tenants.GetAlias().SiteKey;
|
||||||
|
var dbType = _tenants.GetTenant().DBType;
|
||||||
var assemblies = new List<string>();
|
var assemblies = new List<string>();
|
||||||
|
|
||||||
// get all module definition permissions for site
|
// get all module definition permissions for site
|
||||||
@ -219,6 +220,22 @@ namespace Oqtane.Repository
|
|||||||
moduledefinition.IsEnabled = moduledefinition.IsAutoEnabled;
|
moduledefinition.IsEnabled = moduledefinition.IsAutoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if module supports tenant database
|
||||||
|
if (moduledefinition.IsEnabled)
|
||||||
|
{
|
||||||
|
moduledefinition.IsEnabled = string.IsNullOrEmpty(moduledefinition.Databases);
|
||||||
|
if (!string.IsNullOrEmpty(moduledefinition.Databases))
|
||||||
|
{
|
||||||
|
foreach (var database in moduledefinition.Databases.Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (dbType.ToLower().Contains(database.ToLower()))
|
||||||
|
{
|
||||||
|
moduledefinition.IsEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (moduledefinition.IsEnabled)
|
if (moduledefinition.IsEnabled)
|
||||||
{
|
{
|
||||||
// build list of assemblies for site
|
// build list of assemblies for site
|
||||||
|
@ -33,6 +33,7 @@ namespace Oqtane.Models
|
|||||||
SettingsType = "";
|
SettingsType = "";
|
||||||
PackageName = "";
|
PackageName = "";
|
||||||
Runtimes = "";
|
Runtimes = "";
|
||||||
|
Databases = "";
|
||||||
Template = "";
|
Template = "";
|
||||||
Resources = null;
|
Resources = null;
|
||||||
IsAutoEnabled = true;
|
IsAutoEnabled = true;
|
||||||
@ -83,7 +84,10 @@ namespace Oqtane.Models
|
|||||||
public string License { get; set; }
|
public string License { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Runtimes { get; set; }
|
public string Runtimes { get; set; } // comma-delimited list of runtimes ie. Server, WebAssembly
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public string Databases { get; set; } // comma-delimited list of database names ie. SQLServer, SQLite
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Dependencies { get; set; }
|
public string Dependencies { get; set; }
|
||||||
|
Reference in New Issue
Block a user