Added support for MySQL and ProgreSQL and AddSite/Tenant
This commit is contained in:
parent
2fb63e8117
commit
e6530ee127
@ -1,4 +1,5 @@
|
||||
@namespace Oqtane.Modules.Admin.Sites
|
||||
@using Oqtane.Interfaces
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ITenantService TenantService
|
||||
@ -9,6 +10,7 @@
|
||||
@inject IUserService UserService
|
||||
@inject IInstallationService InstallationService
|
||||
@inject IStringLocalizer<Add> Localizer
|
||||
@inject IEnumerable<IOqtaneDatabase> Databases
|
||||
|
||||
@if (_tenants == null)
|
||||
{
|
||||
@ -122,7 +124,7 @@ else
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@if (_tenantid == "+")
|
||||
@if (_tenantId == "+")
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@ -134,7 +136,7 @@ else
|
||||
<Label For="name" HelpText="Enter the name for the tenant" ResourceKey="TenantName">Tenant Name: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="name" class="form-control" @bind="@_tenantname" />
|
||||
<input id="name" class="form-control" @bind="@_tenantName" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -142,64 +144,67 @@ else
|
||||
<Label For="databaseType" HelpText="Select the database type for the tenant" ResourceKey="DatabaseType">Database Type: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="databaseType" class="custom-select" @bind="@_databasetype">
|
||||
<option value="LocalDB">@Localizer["Local Database"]</option>
|
||||
<option value="SQLServer">@Localizer["SQL Server"]</option>
|
||||
<select id="databaseType" class="custom-select" @bind="@_databaseType">
|
||||
@{
|
||||
foreach (var database in Databases)
|
||||
{
|
||||
<option value="@database.Name">@Localizer[@database.FriendlyName]</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="server" HelpText="Enter the server for the tenant" ResourceKey="DatabaseServer">Server: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="server" type="text" class="form-control" @bind="@_server" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="database" HelpText="Enter the database for the tenant" ResourceKey="Database">Database: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="database" type="text" class="form-control" @bind="@_database" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="integratedSecurity" HelpText="Select if you want integrated security or not" ResourceKey="IntegratedSecurity">Integrated Security: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="integratedSecurity" class="custom-select" @onchange="SetIntegratedSecurity">
|
||||
<option value="true" selected>@Localizer["True"]</option>
|
||||
<option value="false">@Localizer["False"]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@if (!_integratedsecurity)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="username" HelpText="Enter the username for the integrated security" ResourceKey="DatabaseUsername">Database Username: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="username" type="text" class="form-control" @bind="@_username" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="password" HelpText="Enter the password for the integrated security" ResourceKey="DatabasePassword">Database Password: </Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="password" type="password" class="form-control" @bind="@_password" />
|
||||
</td>
|
||||
</tr>
|
||||
_selectedDatabase = Databases.Single(d => d.Name == _databaseType);
|
||||
foreach (var field in _selectedDatabase.ConnectionStringFields)
|
||||
{
|
||||
var fieldId = field.Name.ToLowerInvariant();
|
||||
if (field.Name != "IntegratedSecurity")
|
||||
{
|
||||
var isVisible = "";
|
||||
var fieldType = (field.Name == "Pwd") ? "password" : "text";
|
||||
if ((field.Name == "Uid" || field.Name == "Pwd") && _selectedDatabase.Name != "MySQL" )
|
||||
{
|
||||
var intSecurityField = _selectedDatabase.ConnectionStringFields.Single(f => f.Name == "IntegratedSecurity");
|
||||
if (intSecurityField != null)
|
||||
{
|
||||
isVisible = (Convert.ToBoolean(intSecurityField.Value)) ? "display: none;" : "";
|
||||
}
|
||||
}
|
||||
|
||||
field.Value = field.Value.Replace("{{Date}}", DateTime.UtcNow.ToString("yyyyMMddHHmm"));
|
||||
|
||||
<tr style="@isVisible">
|
||||
<td>
|
||||
<Label For="@fieldId" HelpText="@field.HelpText" ResourceKey="@field.Name">@Localizer[$"{field.FriendlyName}:"]</Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="@fieldId" type="@fieldType" class="form-control" @bind="@field.Value" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="@fieldId" HelpText="@field.HelpText" ResourceKey="@field.Name">@Localizer[$"{field.FriendlyName}:"]</Label>
|
||||
</td>
|
||||
<td>
|
||||
<select id="@fieldId" class="custom-select" @bind="@field.Value">
|
||||
<option value="true" selected>@Localizer["True"]</option>
|
||||
<option value="false">@Localizer["False"]</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
}
|
||||
<tr>
|
||||
<td>
|
||||
<Label For="hostUsername" HelpText="Enter the username of the host for this site" ResourceKey="HostUsername">Host Username:</Label>
|
||||
</td>
|
||||
<td>
|
||||
<input id="hostUsername" class="form-control" @bind="@_hostusername" readonly />
|
||||
<input id="hostUsername" class="form-control" @bind="@_hostUserName" readonly />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -223,16 +228,13 @@ else
|
||||
private List<ThemeControl> _containers = new List<ThemeControl>();
|
||||
private List<SiteTemplate> _siteTemplates;
|
||||
private List<Tenant> _tenants;
|
||||
private string _tenantid = "-";
|
||||
private string _tenantId = "-";
|
||||
|
||||
private string _tenantname = string.Empty;
|
||||
private string _databasetype = "LocalDB";
|
||||
private string _server = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string _database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string _username = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
private bool _integratedsecurity = true;
|
||||
private string _hostusername = UserNames.Host;
|
||||
private string _tenantName = string.Empty;
|
||||
private IOqtaneDatabase _selectedDatabase;
|
||||
private string _databaseType = "LocalDB";
|
||||
|
||||
private string _hostUserName = UserNames.Host;
|
||||
private string _hostpassword = string.Empty;
|
||||
|
||||
private string _name = string.Empty;
|
||||
@ -256,23 +258,10 @@ else
|
||||
|
||||
private void TenantChanged(ChangeEventArgs e)
|
||||
{
|
||||
_tenantid = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(_tenantname))
|
||||
_tenantId = (string)e.Value;
|
||||
if (string.IsNullOrEmpty(_tenantName))
|
||||
{
|
||||
_tenantname = _name;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SetIntegratedSecurity(ChangeEventArgs e)
|
||||
{
|
||||
if (Convert.ToBoolean((string)e.Value))
|
||||
{
|
||||
_integratedsecurity = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_integratedsecurity = false;
|
||||
_tenantName = _name;
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
@ -306,7 +295,7 @@ else
|
||||
|
||||
private async Task SaveSite()
|
||||
{
|
||||
if (_tenantid != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-")
|
||||
if (_tenantId != "-" && _name != string.Empty && _urls != string.Empty && _themetype != "-" && (_layouts.Count == 0 || _layouttype != "-") && _containertype != "-" && _sitetemplatetype != "-")
|
||||
{
|
||||
var duplicates = new List<string>();
|
||||
var aliases = await AliasService.GetAliasesAsync();
|
||||
@ -322,9 +311,9 @@ else
|
||||
{
|
||||
InstallConfig config = new InstallConfig();
|
||||
|
||||
if (_tenantid == "+")
|
||||
if (_tenantId == "+")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_tenantname) && _tenants.FirstOrDefault(item => item.Name == _tenantname) == null)
|
||||
if (!string.IsNullOrEmpty(_tenantName) && _tenants.FirstOrDefault(item => item.Name == _tenantName) == null)
|
||||
{
|
||||
// validate host credentials
|
||||
var user = new User();
|
||||
@ -334,32 +323,14 @@ else
|
||||
user = await UserService.LoginUserAsync(user, false, false);
|
||||
if (user.IsAuthenticated)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_server) && !string.IsNullOrEmpty(_database))
|
||||
var connectionString = _selectedDatabase.BuildConnectionString();
|
||||
if (connectionString != "")
|
||||
{
|
||||
var connectionString = string.Empty;
|
||||
if (_databasetype == "LocalDB")
|
||||
{
|
||||
connectionString = "Data Source=" + _server + ";AttachDbFilename=|DataDirectory|\\" + _database + ".mdf;Initial Catalog=" + _database + ";Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionString = "Data Source=" + _server + ";Initial Catalog=" + _database + ";";
|
||||
|
||||
if (_integratedsecurity)
|
||||
{
|
||||
connectionString += "Integrated Security=SSPI;";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionString += "User ID=" + _username + ";Password=" + _password;
|
||||
}
|
||||
}
|
||||
|
||||
config.ConnectionString = connectionString;
|
||||
config.HostPassword = _hostpassword;
|
||||
config.HostEmail = user.Email;
|
||||
config.HostName = user.DisplayName;
|
||||
config.TenantName = _tenantname;
|
||||
config.TenantName = _tenantName;
|
||||
config.IsNewTenant = true;
|
||||
}
|
||||
else
|
||||
@ -379,7 +350,7 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantid));
|
||||
var tenant = _tenants.FirstOrDefault(item => item.TenantId == int.Parse(_tenantId));
|
||||
if (tenant != null)
|
||||
{
|
||||
config.TenantName = tenant.Name;
|
||||
|
@ -80,7 +80,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
htmltext = new HtmlTextInfo();
|
||||
htmltext = new HtmlText();
|
||||
htmltext.ModuleId = ModuleState.ModuleId;
|
||||
htmltext.Content = content;
|
||||
await HtmlTextService.AddHtmlTextAsync(htmltext);
|
||||
|
@ -19,18 +19,18 @@ namespace Oqtane.Modules.HtmlText.Services
|
||||
|
||||
private string ApiUrl => CreateApiUrl(_siteState.Alias, "HtmlText");
|
||||
|
||||
public async Task<HtmlTextInfo> GetHtmlTextAsync(int moduleId)
|
||||
public async Task<Models.HtmlText> GetHtmlTextAsync(int moduleId)
|
||||
{
|
||||
var htmltext = await GetJsonAsync<List<HtmlTextInfo>>(CreateAuthorizationPolicyUrl($"{ApiUrl}/{moduleId}", moduleId));
|
||||
var htmltext = await GetJsonAsync<List<Models.HtmlText>>(CreateAuthorizationPolicyUrl($"{ApiUrl}/{moduleId}", moduleId));
|
||||
return htmltext.FirstOrDefault();
|
||||
}
|
||||
|
||||
public async Task AddHtmlTextAsync(HtmlTextInfo htmlText)
|
||||
public async Task AddHtmlTextAsync(Models.HtmlText htmlText)
|
||||
{
|
||||
await PostJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}", htmlText.ModuleId), htmlText);
|
||||
}
|
||||
|
||||
public async Task UpdateHtmlTextAsync(HtmlTextInfo htmlText)
|
||||
public async Task UpdateHtmlTextAsync(Models.HtmlText htmlText)
|
||||
{
|
||||
await PutJsonAsync(CreateAuthorizationPolicyUrl($"{ApiUrl}/{htmlText.HtmlTextId}", htmlText.ModuleId), htmlText);
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ namespace Oqtane.Modules.HtmlText.Services
|
||||
{
|
||||
public interface IHtmlTextService
|
||||
{
|
||||
Task<HtmlTextInfo> GetHtmlTextAsync(int ModuleId);
|
||||
Task<Models.HtmlText> GetHtmlTextAsync(int ModuleId);
|
||||
|
||||
Task AddHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
Task AddHtmlTextAsync(Models.HtmlText htmltext);
|
||||
|
||||
Task UpdateHtmlTextAsync(HtmlTextInfo htmltext);
|
||||
Task UpdateHtmlTextAsync(Models.HtmlText htmltext);
|
||||
|
||||
Task DeleteHtmlTextAsync(int ModuleId);
|
||||
}
|
||||
|
@ -4,39 +4,36 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using MySql.EntityFrameworkCore.Metadata;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Database.MySQL
|
||||
{
|
||||
public class MySQLDatabase : IOqtaneDatabase
|
||||
public class MySQLDatabase : OqtaneDatabaseBase
|
||||
{
|
||||
public MySQLDatabase()
|
||||
private static string _friendlyName => "MySQL";
|
||||
|
||||
private static string _name => "MySQL";
|
||||
|
||||
private static readonly List<ConnectionStringField> _connectionStringFields = new()
|
||||
{
|
||||
ConnectionStringFields = new List<ConnectionStringField>()
|
||||
{
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "127.0.0.1"},
|
||||
new() {Name = "Port", FriendlyName = "Port", Value = "3306"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = ""},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = ""}
|
||||
};
|
||||
}
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "127.0.0.1", HelpText="Enter the database server"},
|
||||
new() {Name = "Port", FriendlyName = "Port", Value = "3306", HelpText="Enter the port used to connect to the server"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = "", HelpText="Enter the username to use for the database"},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = "", HelpText="Enter the password to use for the database"}
|
||||
};
|
||||
|
||||
public string FriendlyName => Name;
|
||||
public MySQLDatabase() :base(_name, _friendlyName, _connectionStringFields) { }
|
||||
|
||||
public string Name => "MySQL";
|
||||
public override string Provider => "MySql.EntityFrameworkCore";
|
||||
|
||||
public string Provider => "MySql.EntityFrameworkCore";
|
||||
|
||||
public List<ConnectionStringField> ConnectionStringFields { get; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
public override OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
{
|
||||
return table.Column<int>(name: name, nullable: false).Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn);
|
||||
}
|
||||
|
||||
public string BuildConnectionString()
|
||||
public override string BuildConnectionString()
|
||||
{
|
||||
var connectionString = String.Empty;
|
||||
|
||||
@ -58,7 +55,25 @@ namespace Oqtane.Database.MySQL
|
||||
return connectionString;
|
||||
}
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
public override string ConcatenateSql(params string[] values)
|
||||
{
|
||||
var returnValue = "CONCAT(";
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
returnValue += ",";
|
||||
}
|
||||
returnValue += values[i];
|
||||
}
|
||||
|
||||
returnValue += ")";
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
{
|
||||
return optionsBuilder.UseMySQL(connectionString);
|
||||
}
|
||||
|
@ -1,44 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using EFCore.NamingConventions.Internal;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Models;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Database.PostgreSQL
|
||||
{
|
||||
public class PostgreSQLDatabase : IOqtaneDatabase
|
||||
public class PostgreSQLDatabase : OqtaneDatabaseBase
|
||||
{
|
||||
private static string _friendlyName => "PostgreSQL";
|
||||
|
||||
public PostgreSQLDatabase()
|
||||
private static string _name => "PostgreSQL";
|
||||
|
||||
private readonly INameRewriter _rewriter;
|
||||
|
||||
private static readonly List<ConnectionStringField> _connectionStringFields = new()
|
||||
{
|
||||
ConnectionStringFields = new List<ConnectionStringField>()
|
||||
{
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "127.0.0.1"},
|
||||
new() {Name = "Port", FriendlyName = "Port", Value = "5432"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}"},
|
||||
new() {Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = ""},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = ""}
|
||||
};
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "127.0.0.1", HelpText="Enter the database server"},
|
||||
new() {Name = "Port", FriendlyName = "Port", Value = "5432", HelpText="Enter the port used to connect to the server"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"},
|
||||
new() {Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true", HelpText="Select if you want integrated security or not"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = "", HelpText="Enter the username to use for the database"},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = "", HelpText="Enter the password to use for the database"}
|
||||
};
|
||||
|
||||
public PostgreSQLDatabase() : base(_name, _friendlyName, _connectionStringFields)
|
||||
{
|
||||
_rewriter = new SnakeCaseNameRewriter(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public string FriendlyName => Name;
|
||||
public override string Provider => "Npgsql.EntityFrameworkCore.PostgreSQL";
|
||||
|
||||
public string Name => "PostgreSQL";
|
||||
|
||||
public string Provider => "Npgsql.EntityFrameworkCore.PostgreSQL";
|
||||
|
||||
public List<ConnectionStringField> ConnectionStringFields { get; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
public override OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
{
|
||||
return table.Column<int>(name: name, nullable: false).Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn);
|
||||
}
|
||||
|
||||
public string BuildConnectionString()
|
||||
public override string BuildConnectionString()
|
||||
{
|
||||
var connectionString = String.Empty;
|
||||
|
||||
@ -73,7 +77,56 @@ namespace Oqtane.Database.PostgreSQL
|
||||
return connectionString;
|
||||
}
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
public override string ConcatenateSql(params string[] values)
|
||||
{
|
||||
var returnValue = String.Empty;
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
returnValue += " || ";
|
||||
}
|
||||
returnValue += values[i];
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public override string RewriteName(string name)
|
||||
{
|
||||
return _rewriter.RewriteName(name);
|
||||
}
|
||||
|
||||
public override void UpdateIdentityStoreTableNames(ModelBuilder builder)
|
||||
{
|
||||
foreach(var entity in builder.Model.GetEntityTypes())
|
||||
{
|
||||
var tableName = entity.GetTableName();
|
||||
if (tableName.StartsWith("AspNetUser"))
|
||||
{
|
||||
// Replace table names
|
||||
entity.SetTableName(RewriteName(entity.GetTableName()));
|
||||
|
||||
// Replace column names
|
||||
foreach(var property in entity.GetProperties())
|
||||
{
|
||||
property.SetColumnName(RewriteName(property.GetColumnName()));
|
||||
}
|
||||
|
||||
foreach(var key in entity.GetKeys())
|
||||
{
|
||||
key.SetName(RewriteName(key.GetName()));
|
||||
}
|
||||
|
||||
foreach(var index in entity.GetIndexes())
|
||||
{
|
||||
index.SetName(RewriteName(index.GetName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
{
|
||||
return optionsBuilder.UseNpgsql(connectionString).UseSnakeCaseNamingConvention();
|
||||
}
|
||||
|
@ -1,38 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Repository.Databases
|
||||
{
|
||||
public class SqliteDatabase : IOqtaneDatabase
|
||||
public class SqliteDatabase : OqtaneDatabaseBase
|
||||
{
|
||||
public SqliteDatabase()
|
||||
private static string _friendlyName => "Sqlite";
|
||||
|
||||
private static string _name => "Sqlite";
|
||||
|
||||
private static readonly List<ConnectionStringField> _connectionStringFields = new()
|
||||
{
|
||||
ConnectionStringFields = new List<ConnectionStringField>()
|
||||
{
|
||||
new() {Name = "Server", FriendlyName = "File Name", Value = "Oqtane-{{Date}}.db"}
|
||||
};
|
||||
}
|
||||
new() {Name = "Server", FriendlyName = "File Name", Value = "Oqtane-{{Date}}.db", HelpText="Enter the file name to use for the database"}
|
||||
};
|
||||
|
||||
public string FriendlyName => Name;
|
||||
public SqliteDatabase() :base(_name, _friendlyName, _connectionStringFields) { }
|
||||
|
||||
public string Name => "Sqlite";
|
||||
public override string Provider => "Microsoft.EntityFrameworkCore.Sqlite";
|
||||
|
||||
public string Provider => "Microsoft.EntityFrameworkCore.Sqlite";
|
||||
|
||||
public List<ConnectionStringField> ConnectionStringFields { get; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
public override OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
{
|
||||
return table.Column<int>(name: name, nullable: false).Annotation("Sqlite:Autoincrement", true);
|
||||
}
|
||||
|
||||
public string BuildConnectionString()
|
||||
public override string BuildConnectionString()
|
||||
{
|
||||
var connectionstring = String.Empty;
|
||||
|
||||
@ -46,7 +42,22 @@ namespace Oqtane.Repository.Databases
|
||||
return connectionstring;
|
||||
}
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
public override string ConcatenateSql(params string[] values)
|
||||
{
|
||||
var returnValue = String.Empty;
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
returnValue += " || ";
|
||||
}
|
||||
returnValue += values[i];
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
{
|
||||
return optionsBuilder.UseSqlite(connectionString);
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ namespace Oqtane.Databases
|
||||
|
||||
private static readonly List<ConnectionStringField> _connectionStringFields = new()
|
||||
{
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "(LocalDb)\\MSSQLLocalDB"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}"}
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "(LocalDb)\\MSSQLLocalDB", HelpText="Enter the database server"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"}
|
||||
};
|
||||
|
||||
public LocalDbDatabase() :base(_name, _friendlyName, _connectionStringFields) { }
|
||||
|
@ -10,15 +10,16 @@ namespace Oqtane.Databases
|
||||
public class SqlServerDatabase : SqlServerDatabaseBase
|
||||
{
|
||||
private static string _friendlyName => "SQL Server";
|
||||
|
||||
private static string _name => "SqlServer";
|
||||
|
||||
private static readonly List<ConnectionStringField> _connectionStringFields = new()
|
||||
{
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = "."},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}"},
|
||||
new() {Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = ""},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = ""}
|
||||
new() {Name = "Server", FriendlyName = "Server", Value = ".", HelpText="Enter the database server"},
|
||||
new() {Name = "Database", FriendlyName = "Database", Value = "Oqtane-{{Date}}", HelpText="Enter the name of the database"},
|
||||
new() {Name = "IntegratedSecurity", FriendlyName = "Integrated Security", Value = "true", HelpText="Select if you want integrated security or not"},
|
||||
new() {Name = "Uid", FriendlyName = "User Id", Value = "", HelpText="Enter the username to use for the database"},
|
||||
new() {Name = "Pwd", FriendlyName = "Password", Value = "", HelpText="Enter the password to use for the database"}
|
||||
};
|
||||
|
||||
public SqlServerDatabase() :base(_name, _friendlyName, _connectionStringFields) { }
|
||||
|
@ -2,36 +2,27 @@ using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Repository.Databases
|
||||
{
|
||||
public abstract class SqlServerDatabaseBase : IOqtaneDatabase
|
||||
public abstract class SqlServerDatabaseBase : OqtaneDatabaseBase
|
||||
{
|
||||
protected SqlServerDatabaseBase(string name, string friendlyName, List<ConnectionStringField> connectionStringFields)
|
||||
protected SqlServerDatabaseBase(string name, string friendlyName, List<ConnectionStringField> connectionStringFields) : base(name, friendlyName, connectionStringFields)
|
||||
{
|
||||
Name = name;
|
||||
FriendlyName = friendlyName;
|
||||
ConnectionStringFields = connectionStringFields;
|
||||
}
|
||||
|
||||
public string FriendlyName { get; }
|
||||
public override string Provider => "Microsoft.EntityFrameworkCore.SqlServer";
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public string Provider => "Microsoft.EntityFrameworkCore.SqlServer";
|
||||
|
||||
public List<ConnectionStringField> ConnectionStringFields { get; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
public override OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
{
|
||||
return table.Column<int>(name: name, nullable: false).Annotation("SqlServer:Identity", "1, 1");
|
||||
}
|
||||
|
||||
public abstract string BuildConnectionString();
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
public override DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||
{
|
||||
return optionsBuilder.UseSqlServer(connectionString);
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Migrations
|
||||
|
@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Migrations
|
||||
|
@ -21,12 +21,8 @@ namespace Oqtane.Migrations
|
||||
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
notificationEntityBuilder.AddDateTimeColumn("SendOn", true);
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"
|
||||
UPDATE Notification
|
||||
SET SendOn = CreatedOn
|
||||
WHERE SendOn IS NULL;
|
||||
");
|
||||
//Update new Column
|
||||
notificationEntityBuilder.UpdateColumn("SendOn", $"{ActiveDatabase.RewriteName("CreatedOn")}", $"{ActiveDatabase.RewriteName("SendOn")} IS NULL");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
|
@ -21,11 +21,8 @@ namespace Oqtane.Migrations
|
||||
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
profileEntityBuilder.AddStringColumn("Options", 2000, true);
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"
|
||||
UPDATE Profile
|
||||
SET Options = ''
|
||||
");
|
||||
//Update new column
|
||||
profileEntityBuilder.UpdateColumn("Options", "''");
|
||||
|
||||
//Alter Column in Page table for Sql Server
|
||||
if (ActiveDatabase.Name == "SqlServer" || ActiveDatabase.Name == "LocalDB")
|
||||
|
@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Migrations
|
||||
@ -17,12 +18,9 @@ namespace Oqtane.Migrations
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
///Update Icon Field in Page
|
||||
migrationBuilder.Sql(
|
||||
@"
|
||||
UPDATE Page
|
||||
SET Icon = 'oi oi-' + Icon
|
||||
WHERE Icon <> ''
|
||||
");
|
||||
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
var updateSql = ActiveDatabase.ConcatenateSql("'oi oi-'", $"{ActiveDatabase.RewriteName("Icon")}");
|
||||
pageEntityBuilder.UpdateColumn("Icon", updateSql, $"{ActiveDatabase.RewriteName("Icon")} <> ''" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,19 +22,12 @@ namespace Oqtane.Migrations
|
||||
siteEntityBuilder.AddStringColumn("AdminContainerType", 200, true);
|
||||
|
||||
//Update new column
|
||||
migrationBuilder.Sql(
|
||||
@"
|
||||
UPDATE Site
|
||||
SET AdminContainerType = ''
|
||||
");
|
||||
siteEntityBuilder.UpdateColumn("AdminContainerType", "''");
|
||||
|
||||
|
||||
//Delete records from Page
|
||||
migrationBuilder.Sql(
|
||||
@"
|
||||
DELETE FROM Page
|
||||
WHERE Path = 'admin/tenants'
|
||||
");
|
||||
|
||||
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
pageEntityBuilder.DeleteFromTable($"{ActiveDatabase.RewriteName("Path")} = 'admin/tenants'");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
|
@ -24,13 +24,8 @@ namespace Oqtane.Migrations
|
||||
//Update new column if SqlServer (Other Databases will not have any records yet)
|
||||
if (ActiveDatabase.Name == "SqlServer" || ActiveDatabase.Name == "LocalDB")
|
||||
{
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE Tenant
|
||||
SET DBType = 'SqlServer'
|
||||
");
|
||||
|
||||
tenantEntityBuilder.UpdateColumn("DBType", "'SqlServer'");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,10 +23,10 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override AliasEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
AliasId = ActiveDatabase.AddAutoIncrementColumn(table,"AliasId");
|
||||
Name = table.AddStringColumn("Name", 200);
|
||||
TenantId = table.AddIntegerColumn("TenantId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
AliasId = AddAutoIncrementColumn(table,"AliasId");
|
||||
Name = AddStringColumn(table, "Name", 200);
|
||||
TenantId = AddIntegerColumn(table, "TenantId");
|
||||
SiteId = AddIntegerColumn(table, "SiteId");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,10 +23,10 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override AspNetUserClaimsEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
Id = ActiveDatabase.AddAutoIncrementColumn(table,"Id");
|
||||
UserId = table.AddStringColumn("UserId", 450);
|
||||
ClaimType = table.AddMaxStringColumn("ClaimType", true);
|
||||
ClaimValue = table.AddMaxStringColumn("ClaimValue", true);
|
||||
Id = AddAutoIncrementColumn(table,"Id");
|
||||
UserId = AddStringColumn(table,"UserId", 450);
|
||||
ClaimType = AddMaxStringColumn(table,"ClaimType", true);
|
||||
ClaimValue = AddMaxStringColumn(table,"ClaimValue", true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,21 +21,21 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override AspNetUsersEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
Id = table.AddStringColumn("Id", 450);
|
||||
UserName = table.AddStringColumn("Username", 256, true);
|
||||
NormalizedUserName = table.AddStringColumn("NormalizedUserName", 256, true);
|
||||
Email = table.AddStringColumn("Email", 256, true);
|
||||
NormalizedEmail = table.AddStringColumn("NormalizedEmail", 256, true);
|
||||
EmailConfirmed = table.AddBooleanColumn("EmailConfirmed");
|
||||
PasswordHash = table.AddMaxStringColumn("PasswordHash", true);
|
||||
SecurityStamp = table.AddMaxStringColumn("SecurityStamp", true);
|
||||
ConcurrencyStamp = table.AddMaxStringColumn("ConcurrencyStamp", true);
|
||||
PhoneNumber = table.AddMaxStringColumn("PhoneNumber", true);
|
||||
PhoneNumberConfirmed = table.AddBooleanColumn("PhoneNumberConfirmed");
|
||||
TwoFactorEnabled = table.AddBooleanColumn("TwoFactorEnabled");
|
||||
LockoutEnd = table.AddDateTimeOffsetColumn("LockoutEnd", true);
|
||||
LockoutEnabled = table.AddBooleanColumn("LockoutEnabled");
|
||||
AccessFailedCount = table.AddIntegerColumn("AccessFailedCount");
|
||||
Id = AddStringColumn(table,"Id", 450);
|
||||
UserName = AddStringColumn(table,"UserName", 256, true);
|
||||
NormalizedUserName = AddStringColumn(table,"NormalizedUserName", 256, true);
|
||||
Email = AddStringColumn(table,"Email", 256, true);
|
||||
NormalizedEmail = AddStringColumn(table,"NormalizedEmail", 256, true);
|
||||
EmailConfirmed = AddBooleanColumn(table,"EmailConfirmed");
|
||||
PasswordHash = AddMaxStringColumn(table,"PasswordHash", true);
|
||||
SecurityStamp = AddMaxStringColumn(table,"SecurityStamp", true);
|
||||
ConcurrencyStamp = AddMaxStringColumn(table,"ConcurrencyStamp", true);
|
||||
PhoneNumber = AddMaxStringColumn(table,"PhoneNumber", true);
|
||||
PhoneNumberConfirmed = AddBooleanColumn(table,"PhoneNumberConfirmed");
|
||||
TwoFactorEnabled = AddBooleanColumn(table,"TwoFactorEnabled");
|
||||
LockoutEnd = AddDateTimeOffsetColumn(table,"LockoutEnd", true);
|
||||
LockoutEnabled = AddBooleanColumn(table,"LockoutEnabled");
|
||||
AccessFailedCount = AddIntegerColumn(table,"AccessFailedCount");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
@ -17,10 +16,10 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected void AddAuditableColumns(ColumnsBuilder table)
|
||||
{
|
||||
CreatedBy = table.AddStringColumn("CreatedBy", 256);
|
||||
CreatedOn = table.AddDateTimeColumn("CreatedOn");
|
||||
ModifiedBy = table.AddStringColumn("ModifiedBy", 256);
|
||||
ModifiedOn = table.AddDateTimeColumn("ModifiedOn");
|
||||
CreatedBy = AddStringColumn(table,"CreatedBy", 256);
|
||||
CreatedOn = AddDateTimeColumn(table,"CreatedOn");
|
||||
ModifiedBy = AddStringColumn(table,"ModifiedBy", 256);
|
||||
ModifiedOn = AddDateTimeColumn(table,"ModifiedOn");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
// ReSharper disable BuiltInTypeReferenceStyleForMemberAccess
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
@ -18,15 +20,6 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
ForeignKeys = new List<ForeignKey<TEntityBuilder>>();
|
||||
}
|
||||
|
||||
private void AddKeys(CreateTableBuilder<TEntityBuilder> table)
|
||||
{
|
||||
table.AddPrimaryKey(PrimaryKey);
|
||||
foreach (var foreignKey in ForeignKeys)
|
||||
{
|
||||
table.AddForeignKey(foreignKey);
|
||||
}
|
||||
}
|
||||
|
||||
protected IOqtaneDatabase ActiveDatabase { get; }
|
||||
|
||||
protected abstract TEntityBuilder BuildTable(ColumnsBuilder table);
|
||||
@ -37,16 +30,92 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected List<ForeignKey<TEntityBuilder>> ForeignKeys { get; }
|
||||
|
||||
private string RewriteName(string name)
|
||||
{
|
||||
return ActiveDatabase.RewriteName(name);
|
||||
}
|
||||
|
||||
|
||||
// Column Operations
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name)
|
||||
{
|
||||
return ActiveDatabase.AddAutoIncrementColumn(table, RewriteName(name));
|
||||
}
|
||||
|
||||
public void AddBooleanColumn(string name)
|
||||
{
|
||||
_migrationBuilder.AddColumn<bool>(name, EntityTableName);
|
||||
_migrationBuilder.AddColumn<bool>(RewriteName(name), RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddBooleanColumn(ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<bool>(name: RewriteName(name), nullable: nullable);
|
||||
}
|
||||
|
||||
public void AddDateTimeColumn(string name, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<DateTime>(name, EntityTableName, nullable: nullable);
|
||||
_migrationBuilder.AddColumn<DateTime>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddDateTimeColumn(ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<DateTime>(name: RewriteName(name), nullable: nullable);
|
||||
}
|
||||
|
||||
public void AddDateTimeOffsetColumn(string name, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<DateTimeOffset>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddDateTimeOffsetColumn(ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<DateTimeOffset>(name: RewriteName(name), nullable: nullable);
|
||||
}
|
||||
|
||||
public void AddIntegerColumn(string name, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<int>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddIntegerColumn(ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<int>(name: RewriteName(name), nullable: nullable);
|
||||
}
|
||||
|
||||
public void AddMaxStringColumn(string name, int length, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddMaxStringColumn(ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<string>(name: RewriteName(name), nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
public void AddStringColumn(string name, int length, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
protected OperationBuilder<AddColumnOperation> AddStringColumn(ColumnsBuilder table, string name, int length, bool nullable = false)
|
||||
{
|
||||
return table.Column<string>(name: RewriteName(name), maxLength: length, nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
public void AlterStringColumn(string name, int length, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AlterColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable);
|
||||
}
|
||||
|
||||
public void DropColumn(string name)
|
||||
{
|
||||
_migrationBuilder.DropColumn(RewriteName(name), RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
|
||||
//Index Operations
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to add an Index to the Entity (table)
|
||||
/// </summary>
|
||||
@ -56,9 +125,9 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
public virtual void AddIndex(string indexName, string columnName, bool isUnique = false)
|
||||
{
|
||||
_migrationBuilder.CreateIndex(
|
||||
name: indexName,
|
||||
table: EntityTableName,
|
||||
column: columnName,
|
||||
name: RewriteName(indexName),
|
||||
table: RewriteName(EntityTableName),
|
||||
column: RewriteName(columnName),
|
||||
unique: isUnique);
|
||||
}
|
||||
|
||||
@ -66,55 +135,107 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
/// Creates a Migration to add an Index to the Entity (table)
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the Index to create</param>
|
||||
/// <param name="columnName">The names of the columns to add to the index</param>
|
||||
/// <param name="columnNames">The names of the columns to add to the index</param>
|
||||
/// <param name="isUnique">A flag that determines if the Index should be Unique</param>
|
||||
public virtual void AddIndex(string indexName, string[] columnNames, bool isUnique = false)
|
||||
{
|
||||
_migrationBuilder.CreateIndex(
|
||||
name: indexName,
|
||||
table: EntityTableName,
|
||||
columns: columnNames,
|
||||
name: RewriteName(indexName),
|
||||
table: RewriteName(EntityTableName),
|
||||
columns: columnNames.Select(RewriteName).ToArray(),
|
||||
unique: isUnique);
|
||||
}
|
||||
|
||||
public void AddStringColumn(string name, int length, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AddColumn<string>(name, EntityTableName, maxLength: length, nullable: nullable);
|
||||
}
|
||||
|
||||
public void AlterStringColumn(string name, int length, bool nullable = false)
|
||||
{
|
||||
_migrationBuilder.AlterColumn<string>(name, EntityTableName, maxLength: length, nullable: nullable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to Create the Entity (table)
|
||||
/// </summary>
|
||||
public void Create()
|
||||
{
|
||||
_migrationBuilder.CreateTable(EntityTableName, BuildTable, null, AddKeys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to Drop the Entity (table)
|
||||
/// </summary>
|
||||
public void Drop()
|
||||
{
|
||||
_migrationBuilder.DropTable(EntityTableName);
|
||||
}
|
||||
|
||||
public void DropColumn(string name)
|
||||
{
|
||||
_migrationBuilder.DropColumn(name, EntityTableName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to drop an Index from the Entity (table)
|
||||
/// </summary>
|
||||
/// <param name="indexName">The name of the Index to drop</param>
|
||||
public virtual void DropIndex(string indexName)
|
||||
{
|
||||
_migrationBuilder.DropIndex(indexName, EntityTableName);
|
||||
_migrationBuilder.DropIndex(RewriteName(indexName), RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
|
||||
// Key Operations
|
||||
|
||||
private void AddKeys(CreateTableBuilder<TEntityBuilder> table)
|
||||
{
|
||||
AddPrimaryKey(table, PrimaryKey);
|
||||
foreach (var foreignKey in ForeignKeys)
|
||||
{
|
||||
AddForeignKey(table, foreignKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPrimaryKey(CreateTableBuilder<TEntityBuilder> table, PrimaryKey<TEntityBuilder> primaryKey)
|
||||
{
|
||||
table.PrimaryKey(RewriteName(primaryKey.Name), primaryKey.Columns);
|
||||
}
|
||||
|
||||
public void AddForeignKey(CreateTableBuilder<TEntityBuilder> table, ForeignKey<TEntityBuilder> foreignKey)
|
||||
{
|
||||
table.ForeignKey(
|
||||
name: RewriteName(foreignKey.Name),
|
||||
column: foreignKey.Column,
|
||||
principalTable: RewriteName(foreignKey.PrincipalTable),
|
||||
principalColumn: RewriteName(foreignKey.PrincipalColumn),
|
||||
onDelete: foreignKey.OnDeleteAction);
|
||||
}
|
||||
|
||||
public void DropForeignKey(ForeignKey<TEntityBuilder> foreignKey)
|
||||
{
|
||||
DropForeignKey(RewriteName(foreignKey.Name));
|
||||
}
|
||||
|
||||
public void DropForeignKey(string keyName)
|
||||
{
|
||||
_migrationBuilder.DropForeignKey(RewriteName(keyName), RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
|
||||
// Table Operations
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to Create the Entity (table)
|
||||
/// </summary>
|
||||
public void Create()
|
||||
{
|
||||
_migrationBuilder.CreateTable(RewriteName(EntityTableName), BuildTable, null, AddKeys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Migration to Drop the Entity (table)
|
||||
/// </summary>
|
||||
public void Drop()
|
||||
{
|
||||
_migrationBuilder.DropTable(RewriteName(EntityTableName));
|
||||
}
|
||||
|
||||
|
||||
//Sql Operations
|
||||
|
||||
public void DeleteFromTable(string condition = "")
|
||||
{
|
||||
var deleteSql = $"DELETE FROM {RewriteName(EntityTableName)} ";
|
||||
|
||||
if(!string.IsNullOrEmpty(condition))
|
||||
{
|
||||
deleteSql += $"WHERE {condition}";
|
||||
}
|
||||
_migrationBuilder.Sql(deleteSql);
|
||||
}
|
||||
|
||||
public void UpdateColumn(string columnName, string value, string condition = "")
|
||||
{
|
||||
var updateValue = value;
|
||||
|
||||
var updateSql = $"UPDATE {RewriteName(EntityTableName)} SET {RewriteName(columnName)} = {value} ";
|
||||
|
||||
if(!string.IsNullOrEmpty(condition))
|
||||
{
|
||||
updateSql += $"WHERE {condition}";
|
||||
}
|
||||
_migrationBuilder.Sql(updateSql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
@ -17,9 +16,9 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected void AddDeletableColumns(ColumnsBuilder table)
|
||||
{
|
||||
DeletedBy = table.AddStringColumn("DeletedBy", 256, true);
|
||||
DeletedOn = table.AddDateTimeColumn("DeletedOn", true);
|
||||
IsDeleted = table.AddBooleanColumn("IsDeleted");
|
||||
DeletedBy = AddStringColumn(table,"DeletedBy", 256, true);
|
||||
DeletedOn = AddDateTimeColumn(table,"DeletedOn", true);
|
||||
IsDeleted = AddBooleanColumn(table,"IsDeleted");
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> DeletedBy { get; private set; }
|
||||
|
@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
@ -17,9 +16,9 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected void AddDeletableColumns(ColumnsBuilder table)
|
||||
{
|
||||
DeletedBy = table.AddStringColumn("DeletedBy", 256, true);
|
||||
DeletedOn = table.AddDateTimeColumn("DeletedOn", true);
|
||||
IsDeleted = table.AddBooleanColumn("IsDeleted");
|
||||
DeletedBy = AddStringColumn(table,"DeletedBy", 256, true);
|
||||
DeletedOn = AddDateTimeColumn(table,"DeletedOn", true);
|
||||
IsDeleted = AddBooleanColumn(table,"IsDeleted");
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> DeletedBy { get; private set; }
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,13 +23,13 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override FileEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
FileId = ActiveDatabase.AddAutoIncrementColumn(table,"FileId");
|
||||
FolderId = table.AddIntegerColumn("FolderId");
|
||||
Name = table.AddStringColumn("Name", 50);
|
||||
Extension = table.AddStringColumn("Extension", 50);
|
||||
Size = table.AddIntegerColumn("Size");
|
||||
ImageHeight = table.AddIntegerColumn("ImageHeight");
|
||||
ImageWidth = table.AddIntegerColumn("ImageWidth");
|
||||
FileId = AddAutoIncrementColumn(table,"FileId");
|
||||
FolderId = AddIntegerColumn(table,"FolderId");
|
||||
Name = AddStringColumn(table,"Name", 50);
|
||||
Extension = AddStringColumn(table,"Extension", 50);
|
||||
Size = AddIntegerColumn(table,"Size");
|
||||
ImageHeight = AddIntegerColumn(table,"ImageHeight");
|
||||
ImageWidth = AddIntegerColumn(table,"ImageWidth");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,13 +23,13 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override FolderEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
FolderId = ActiveDatabase.AddAutoIncrementColumn(table,"FolderId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||
Name = table.AddStringColumn("Name", 50);
|
||||
Path = table.AddStringColumn("Path", 50);
|
||||
Order = table.AddIntegerColumn("Order");
|
||||
IsSystem = table.AddBooleanColumn("IsSystem");
|
||||
FolderId = AddAutoIncrementColumn(table,"FolderId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
ParentId = AddIntegerColumn(table,"ParentId", true);
|
||||
Name = AddStringColumn(table,"Name", 50);
|
||||
Path = AddStringColumn(table,"Path", 50);
|
||||
Order = AddIntegerColumn(table,"Order");
|
||||
IsSystem = AddBooleanColumn(table,"IsSystem");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,18 +21,18 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override JobEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
JobId = ActiveDatabase.AddAutoIncrementColumn(table,"JobId");
|
||||
Name = table.AddStringColumn("Name", 200);
|
||||
JobType = table.AddStringColumn("JobType", 200);
|
||||
Frequency = table.AddStringColumn("Frequency", 1);
|
||||
Interval = table.AddIntegerColumn("Interval");
|
||||
StartDate = table.AddDateTimeColumn("StartDate", true);
|
||||
EndDate = table.AddDateTimeColumn("EndDate", true);
|
||||
IsEnabled = table.AddBooleanColumn("IsEnabled");
|
||||
IsStarted = table.AddBooleanColumn("IsStarted");
|
||||
IsExecuting = table.AddBooleanColumn("IsExecuting");
|
||||
NextExecution = table.AddDateTimeColumn("NextExecution", true);
|
||||
RetentionHistory = table.AddIntegerColumn("RetentionHistory");
|
||||
JobId = AddAutoIncrementColumn(table,"JobId");
|
||||
Name = AddStringColumn(table,"Name", 200);
|
||||
JobType = AddStringColumn(table,"JobType", 200);
|
||||
Frequency = AddStringColumn(table,"Frequency", 1);
|
||||
Interval = AddIntegerColumn(table,"Interval");
|
||||
StartDate = AddDateTimeColumn(table,"StartDate", true);
|
||||
EndDate = AddDateTimeColumn(table,"EndDate", true);
|
||||
IsEnabled = AddBooleanColumn(table,"IsEnabled");
|
||||
IsStarted = AddBooleanColumn(table,"IsStarted");
|
||||
IsExecuting = AddBooleanColumn(table,"IsExecuting");
|
||||
NextExecution = AddDateTimeColumn(table,"NextExecution", true);
|
||||
RetentionHistory = AddIntegerColumn(table,"RetentionHistory");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
@ -23,12 +23,12 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override JobLogEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
JobLogId = ActiveDatabase.AddAutoIncrementColumn(table,"JobLogId");
|
||||
JobId = table.AddIntegerColumn("JobId");
|
||||
StartDate = table.AddDateTimeColumn("StartDate");
|
||||
FinishDate = table.AddDateTimeColumn("FinishDate", true);
|
||||
Succeeded = table.AddBooleanColumn("Succeeded", true);
|
||||
Notes = table.AddMaxStringColumn("Notes", true);
|
||||
JobLogId = AddAutoIncrementColumn(table,"JobLogId");
|
||||
JobId = AddIntegerColumn(table,"JobId");
|
||||
StartDate = AddDateTimeColumn(table,"StartDate");
|
||||
FinishDate = AddDateTimeColumn(table,"FinishDate", true);
|
||||
Succeeded = AddBooleanColumn(table,"Succeeded", true);
|
||||
Notes = AddMaxStringColumn(table,"Notes", true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,11 +23,11 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override LanguageEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
LanguageId = ActiveDatabase.AddAutoIncrementColumn(table,"LanguageId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
Name = table.AddStringColumn("Name", 100);
|
||||
Code = table.AddStringColumn("Code", 10);
|
||||
IsDefault = table.AddBooleanColumn("IsDefault");
|
||||
LanguageId = AddAutoIncrementColumn(table,"LanguageId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
Name = AddStringColumn(table,"Name", 100);
|
||||
Code = AddStringColumn(table,"Code", 10);
|
||||
IsDefault = AddBooleanColumn(table,"IsDefault");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,22 +23,22 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override LogEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
LogId = ActiveDatabase.AddAutoIncrementColumn(table,"LogId");
|
||||
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||
LogDate = table.AddDateTimeColumn("LogDate");
|
||||
PageId = table.AddIntegerColumn("PageId", true);
|
||||
ModuleId = table.AddIntegerColumn("ModuleId", true);
|
||||
UserId = table.AddIntegerColumn("UserId", true);
|
||||
Url = table.AddStringColumn("Url", 2048);
|
||||
Server = table.AddStringColumn("Server", 200);
|
||||
Category = table.AddStringColumn("Category", 200);
|
||||
Feature = table.AddStringColumn("Feature", 200);
|
||||
Function = table.AddStringColumn("Function", 20);
|
||||
Level = table.AddStringColumn("Level", 20);
|
||||
Message = table.AddMaxStringColumn("Message");
|
||||
MessageTemplate = table.AddMaxStringColumn("MessageTemplate");
|
||||
Exception = table.AddMaxStringColumn("Exception", true);
|
||||
Properties = table.AddMaxStringColumn("Properties", true);
|
||||
LogId = AddAutoIncrementColumn(table,"LogId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId", true);
|
||||
LogDate = AddDateTimeColumn(table,"LogDate");
|
||||
PageId = AddIntegerColumn(table,"PageId", true);
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId", true);
|
||||
UserId = AddIntegerColumn(table,"UserId", true);
|
||||
Url = AddStringColumn(table,"Url", 2048);
|
||||
Server = AddStringColumn(table,"Server", 200);
|
||||
Category = AddStringColumn(table,"Category", 200);
|
||||
Feature = AddStringColumn(table,"Feature", 200);
|
||||
Function = AddStringColumn(table,"Function", 20);
|
||||
Level = AddStringColumn(table,"Level", 20);
|
||||
Message = AddMaxStringColumn(table,"Message");
|
||||
MessageTemplate = AddMaxStringColumn(table,"MessageTemplate");
|
||||
Exception = AddMaxStringColumn(table,"Exception", true);
|
||||
Properties = AddMaxStringColumn(table,"Properties", true);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,12 +21,12 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override ModuleDefinitionsEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
ModuleDefinitionId = ActiveDatabase.AddAutoIncrementColumn(table,"ModuleDefinitionId");
|
||||
ModuleDefinitionName = table.AddStringColumn("ModuleDefinitionName", 200);
|
||||
Name = table.AddStringColumn("Name", 200, true);
|
||||
Description = table.AddStringColumn("Description", 2000, true);
|
||||
Categories = table.AddStringColumn("Categories", 200, true);
|
||||
Version = table.AddStringColumn("Version", 50, true);
|
||||
ModuleDefinitionId = AddAutoIncrementColumn(table,"ModuleDefinitionId");
|
||||
ModuleDefinitionName = AddStringColumn(table,"ModuleDefinitionName", 200);
|
||||
Name = AddStringColumn(table,"Name", 200, true);
|
||||
Description = AddStringColumn(table,"Description", 2000, true);
|
||||
Categories = AddStringColumn(table,"Categories", 200, true);
|
||||
Version = AddStringColumn(table,"Version", 50, true);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,10 +23,10 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override ModuleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
ModuleId = ActiveDatabase.AddAutoIncrementColumn(table,"ModuleId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
ModuleDefinitionName = table.AddStringColumn("ModuleDefinitionName", 200);
|
||||
AllPages = table.AddBooleanColumn("AllPages");
|
||||
ModuleId = AddAutoIncrementColumn(table,"ModuleId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
ModuleDefinitionName = AddStringColumn(table,"ModuleDefinitionName", 200);
|
||||
AllPages = AddBooleanColumn(table,"AllPages");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,17 +23,17 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override NotificationEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
NotificationId = ActiveDatabase.AddAutoIncrementColumn(table,"NotificationId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
FromUserId = table.AddIntegerColumn("FromUserId", true);
|
||||
ToUserId = table.AddIntegerColumn("ToUserId", true);
|
||||
ToEmail = table.AddStringColumn("ToEmail", 256);
|
||||
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||
Subject = table.AddStringColumn("Subject", 256);
|
||||
Body = table.AddMaxStringColumn("Body");
|
||||
CreatedOn = table.AddDateTimeColumn("CreatedOn");
|
||||
IsDelivered = table.AddBooleanColumn("IsDelivered");
|
||||
DeliveredOn = table.AddDateTimeColumn("DeliveredOn", true);
|
||||
NotificationId = AddAutoIncrementColumn(table,"NotificationId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
FromUserId = AddIntegerColumn(table,"FromUserId", true);
|
||||
ToUserId = AddIntegerColumn(table,"ToUserId", true);
|
||||
ToEmail = AddStringColumn(table,"ToEmail", 256);
|
||||
ParentId = AddIntegerColumn(table,"ParentId", true);
|
||||
Subject = AddStringColumn(table,"Subject", 256);
|
||||
Body = AddMaxStringColumn(table,"Body");
|
||||
CreatedOn = AddDateTimeColumn(table,"CreatedOn");
|
||||
IsDelivered = AddBooleanColumn(table,"IsDelivered");
|
||||
DeliveredOn = AddDateTimeColumn(table,"DeliveredOn", true);
|
||||
|
||||
AddDeletableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,28 +23,28 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override PageEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PageId = ActiveDatabase.AddAutoIncrementColumn(table,"PageId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
PageId = AddAutoIncrementColumn(table,"PageId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
if (ActiveDatabase.Name == "SqlServer" || ActiveDatabase.Name == "LocalDB")
|
||||
{
|
||||
Path = table.AddStringColumn("Path", 50);
|
||||
Path = AddStringColumn(table,"Path", 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
Path = table.AddStringColumn("Path", 256);
|
||||
Path = AddStringColumn(table,"Path", 256);
|
||||
}
|
||||
Name = table.AddStringColumn("Name", 50);
|
||||
Title = table.AddStringColumn("Title", 200, true);
|
||||
ThemeType = table.AddStringColumn("ThemeType", 200, true);
|
||||
Icon = table.AddStringColumn("Icon", 50);
|
||||
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||
Order = table.AddIntegerColumn("Order");
|
||||
IsNavigation = table.AddBooleanColumn("IsNavigation");
|
||||
Url = table.AddStringColumn("Url", 500, true);
|
||||
LayoutType = table.AddStringColumn("LayoutType", 200);
|
||||
UserId = table.AddIntegerColumn("UserId", true);
|
||||
IsPersonalizable = table.AddBooleanColumn("IsPersonalizable");
|
||||
DefaultContainerType = table.AddStringColumn("DefaultContainerType", 200, true);
|
||||
Name = AddStringColumn(table,"Name", 50);
|
||||
Title = AddStringColumn(table,"Title", 200, true);
|
||||
ThemeType = AddStringColumn(table,"ThemeType", 200, true);
|
||||
Icon = AddStringColumn(table,"Icon", 50);
|
||||
ParentId = AddIntegerColumn(table,"ParentId", true);
|
||||
Order = AddIntegerColumn(table,"Order");
|
||||
IsNavigation = AddBooleanColumn(table,"IsNavigation");
|
||||
Url = AddStringColumn(table,"Url", 500, true);
|
||||
LayoutType = AddStringColumn(table,"LayoutType", 200);
|
||||
UserId = AddIntegerColumn(table,"UserId", true);
|
||||
IsPersonalizable = AddBooleanColumn(table,"IsPersonalizable");
|
||||
DefaultContainerType = AddStringColumn(table,"DefaultContainerType", 200, true);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -26,13 +25,13 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override PageModuleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PageModuleId = ActiveDatabase.AddAutoIncrementColumn(table,"PageModuleId");
|
||||
PageId = table.AddIntegerColumn("PageId");
|
||||
ModuleId = table.AddIntegerColumn("ModuleId");
|
||||
Title = table.AddStringColumn("Title", 200);
|
||||
Pane = table.AddStringColumn("Pane", 50);
|
||||
Order = table.AddIntegerColumn("Order");
|
||||
ContainerType = table.AddStringColumn("ContainerType", 200);
|
||||
PageModuleId = AddAutoIncrementColumn(table,"PageModuleId");
|
||||
PageId = AddIntegerColumn(table,"PageId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Title = AddStringColumn(table,"Title", 200);
|
||||
Pane = AddStringColumn(table,"Pane", 50);
|
||||
Order = AddIntegerColumn(table,"Order");
|
||||
ContainerType = AddStringColumn(table,"ContainerType", 200);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -28,14 +27,14 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override PermissionEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PermissionId = ActiveDatabase.AddAutoIncrementColumn(table,"PermissionId");
|
||||
SiteId = table.AddIntegerColumn("SiteId");
|
||||
EntityName = table.AddStringColumn("EntityName", 50);
|
||||
EntityId = table.AddIntegerColumn("EntityId");
|
||||
PermissionName = table.AddStringColumn("PermissionName", 50);
|
||||
RoleId = table.AddIntegerColumn("RoleId", true);
|
||||
UserId = table.AddIntegerColumn("UserId", true);
|
||||
IsAuthorized = table.AddBooleanColumn("IsAuthorized");
|
||||
PermissionId = AddAutoIncrementColumn(table,"PermissionId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId");
|
||||
EntityName = AddStringColumn(table,"EntityName", 50);
|
||||
EntityId = AddIntegerColumn(table,"EntityId");
|
||||
PermissionName = AddStringColumn(table,"PermissionName", 50);
|
||||
RoleId = AddIntegerColumn(table,"RoleId", true);
|
||||
UserId = AddIntegerColumn(table,"UserId", true);
|
||||
IsAuthorized = AddBooleanColumn(table,"IsAuthorized");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,17 +23,17 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override ProfileEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
ProfileId = ActiveDatabase.AddAutoIncrementColumn(table,"ProfileId");
|
||||
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||
Name = table.AddStringColumn("Name", 50);
|
||||
Title = table.AddStringColumn("Title", 50);
|
||||
Description = table.AddStringColumn("Description", 256, true);
|
||||
Category = table.AddStringColumn("Category", 50);
|
||||
ViewOrder = table.AddIntegerColumn("ViewOrder");
|
||||
MaxLength = table.AddIntegerColumn("MaxLength");
|
||||
DefaultValue = table.AddStringColumn("DefaultValue", 2000, true);
|
||||
IsRequired = table.AddBooleanColumn("IsRequired");
|
||||
IsPrivate = table.AddBooleanColumn("IsPrivate");
|
||||
ProfileId = AddAutoIncrementColumn(table,"ProfileId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId", true);
|
||||
Name = AddStringColumn(table,"Name", 50);
|
||||
Title = AddStringColumn(table,"Title", 50);
|
||||
Description = AddStringColumn(table,"Description", 256, true);
|
||||
Category = AddStringColumn(table,"Category", 50);
|
||||
ViewOrder = AddIntegerColumn(table,"ViewOrder");
|
||||
MaxLength = AddIntegerColumn(table,"MaxLength");
|
||||
DefaultValue = AddStringColumn(table,"DefaultValue", 2000, true);
|
||||
IsRequired = AddBooleanColumn(table,"IsRequired");
|
||||
IsPrivate = AddBooleanColumn(table,"IsPrivate");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -24,12 +23,12 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override RoleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
RoleId = ActiveDatabase.AddAutoIncrementColumn(table,"RoleId");
|
||||
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||
Name = table.AddStringColumn("Name", 256);
|
||||
Description = table.AddStringColumn("Description", 256);
|
||||
IsAutoAssigned = table.AddBooleanColumn("IsAutoAssigned");
|
||||
IsSystem = table.AddBooleanColumn("IsSystem");
|
||||
RoleId = AddAutoIncrementColumn(table,"RoleId");
|
||||
SiteId = AddIntegerColumn(table,"SiteId", true);
|
||||
Name = AddStringColumn(table,"Name", 256);
|
||||
Description = AddStringColumn(table,"Description", 256);
|
||||
IsAutoAssigned = AddBooleanColumn(table,"IsAutoAssigned");
|
||||
IsSystem = AddBooleanColumn(table,"IsSystem");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,11 +21,11 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override SettingEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
SettingId = ActiveDatabase.AddAutoIncrementColumn(table,"SettingId");
|
||||
EntityName = table.AddStringColumn("EntityName", 50);
|
||||
EntityId = table.AddIntegerColumn("EntityId");
|
||||
SettingName = table.AddStringColumn("SettingName", 50);
|
||||
SettingValue = table.AddMaxStringColumn("SettingValue");
|
||||
SettingId = AddAutoIncrementColumn(table,"SettingId");
|
||||
EntityName = AddStringColumn(table,"EntityName", 50);
|
||||
EntityId = AddIntegerColumn(table,"EntityId");
|
||||
SettingName = AddStringColumn(table,"SettingName", 50);
|
||||
SettingValue = AddMaxStringColumn(table,"SettingValue");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,18 +21,18 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override SiteEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
SiteId = ActiveDatabase.AddAutoIncrementColumn(table,"SiteId");
|
||||
TenantId = table.AddIntegerColumn("TenantId");
|
||||
Name = table.AddStringColumn("Name", 200);
|
||||
LogoFileId = table.AddIntegerColumn("LogoFileId", true);
|
||||
FaviconFileId = table.AddIntegerColumn("FaviconFileId", true);
|
||||
DefaultThemeType = table.AddStringColumn("DefaultThemeType", 200);
|
||||
DefaultLayoutType = table.AddStringColumn("DefaultLayoutType", 200);
|
||||
DefaultContainerType = table.AddStringColumn("DefaultContainerType", 200);
|
||||
PwaIsEnabled = table.AddBooleanColumn("PwaIsEnabled");
|
||||
PwaAppIconFileId = table.AddIntegerColumn("PwaAppIconFileId", true);
|
||||
PwaSplashIconFileId = table.AddIntegerColumn("PwaSplashIconFileId", true);
|
||||
AllowRegistration = table.AddBooleanColumn("AllowRegistration");
|
||||
SiteId = AddAutoIncrementColumn(table,"SiteId");
|
||||
TenantId = AddIntegerColumn(table,"TenantId");
|
||||
Name = AddStringColumn(table,"Name", 200);
|
||||
LogoFileId = AddIntegerColumn(table,"LogoFileId", true);
|
||||
FaviconFileId = AddIntegerColumn(table,"FaviconFileId", true);
|
||||
DefaultThemeType = AddStringColumn(table,"DefaultThemeType", 200);
|
||||
DefaultLayoutType = AddStringColumn(table,"DefaultLayoutType", 200);
|
||||
DefaultContainerType = AddStringColumn(table,"DefaultContainerType", 200);
|
||||
PwaIsEnabled = AddBooleanColumn(table,"PwaIsEnabled");
|
||||
PwaAppIconFileId = AddIntegerColumn(table,"PwaAppIconFileId", true);
|
||||
PwaSplashIconFileId = AddIntegerColumn(table,"PwaSplashIconFileId", true);
|
||||
AllowRegistration = AddBooleanColumn(table,"AllowRegistration");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,10 +21,10 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override TenantEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
TenantId = ActiveDatabase.AddAutoIncrementColumn(table,"TenantId");
|
||||
Name = table.AddStringColumn("Name", 100);
|
||||
DBConnectionString = table.AddStringColumn("DBConnectionString", 1024);
|
||||
Version = table.AddStringColumn("Version", 50, true);
|
||||
TenantId = AddAutoIncrementColumn(table,"TenantId");
|
||||
Name = AddStringColumn(table,"Name", 100);
|
||||
DBConnectionString = AddStringColumn(table,"DBConnectionString", 1024);
|
||||
Version = AddStringColumn(table,"Version", 50, true);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -22,13 +21,13 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override UserEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
UserId = ActiveDatabase.AddAutoIncrementColumn(table,"UserId");
|
||||
Username = table.AddStringColumn("Username", 256);
|
||||
DisplayName = table.AddStringColumn("DisplayName", 50);
|
||||
Email = table.AddStringColumn("Email", 256);
|
||||
PhotoFileId = table.AddIntegerColumn("PhotoFileId", true);
|
||||
LastLoginOn = table.AddDateTimeColumn("LastLoginOn", true);
|
||||
LastIPAddress = table.AddStringColumn("LastIpAddress", 50);
|
||||
UserId = AddAutoIncrementColumn(table,"UserId");
|
||||
Username = AddStringColumn(table,"Username", 256);
|
||||
DisplayName = AddStringColumn(table,"DisplayName", 50);
|
||||
Email = AddStringColumn(table,"Email", 256);
|
||||
PhotoFileId = AddIntegerColumn(table,"PhotoFileId", true);
|
||||
LastLoginOn = AddDateTimeColumn(table,"LastLoginOn", true);
|
||||
LastIPAddress = AddStringColumn(table,"LastIpAddress", 50);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
AddDeletableColumns(table);
|
||||
|
@ -2,7 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -26,11 +25,11 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
|
||||
protected override UserRoleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
UserRoleId = ActiveDatabase.AddAutoIncrementColumn(table,"UserRoleId");
|
||||
UserId = table.AddIntegerColumn("UserId");
|
||||
RoleId = table.AddIntegerColumn("RoleId");
|
||||
EffectiveDate = table.AddDateTimeColumn("EffectiveDate", true);
|
||||
ExpiryDate = table.AddDateTimeColumn("ExpiryDate", true);
|
||||
UserRoleId = AddAutoIncrementColumn(table,"UserRoleId");
|
||||
UserId = AddIntegerColumn(table,"UserId");
|
||||
RoleId = AddIntegerColumn(table,"RoleId");
|
||||
EffectiveDate = AddDateTimeColumn(table,"EffectiveDate", true);
|
||||
ExpiryDate = AddDateTimeColumn(table,"ExpiryDate", true);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
|
||||
namespace Oqtane.Migrations.Extensions
|
||||
{
|
||||
public static class ColumnsBuilderExtensions
|
||||
{
|
||||
public static OperationBuilder<AddColumnOperation> AddBooleanColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<bool>(name: name, nullable: nullable);
|
||||
}
|
||||
|
||||
public static OperationBuilder<AddColumnOperation> AddDateTimeColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<DateTime>(name: name, nullable: nullable);
|
||||
}
|
||||
|
||||
public static OperationBuilder<AddColumnOperation> AddDateTimeOffsetColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<DateTimeOffset>(name: name, nullable: nullable);
|
||||
}
|
||||
|
||||
public static OperationBuilder<AddColumnOperation> AddIntegerColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<int>(name: name, nullable: nullable);
|
||||
}
|
||||
|
||||
public static OperationBuilder<AddColumnOperation> AddMaxStringColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||
{
|
||||
return table.Column<string>(name: name, nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
public static OperationBuilder<AddColumnOperation> AddStringColumn(this ColumnsBuilder table, string name, int length, bool nullable = false)
|
||||
{
|
||||
return table.Column<string>(name: name, maxLength: length, nullable: nullable, unicode: true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
|
||||
namespace Oqtane.Migrations.Extensions
|
||||
{
|
||||
public static class CreateTableBuilderExtensions
|
||||
{
|
||||
public static void AddForeignKey<TEntityBuilder>(this CreateTableBuilder<TEntityBuilder> table, ForeignKey<TEntityBuilder> foreignKey) where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||
{
|
||||
table.ForeignKey(
|
||||
name: foreignKey.Name,
|
||||
column: foreignKey.Column,
|
||||
principalTable: foreignKey.PrincipalTable,
|
||||
principalColumn: foreignKey.PrincipalColumn,
|
||||
onDelete: foreignKey.OnDeleteAction);
|
||||
}
|
||||
|
||||
public static void AddPrimaryKey<TEntityBuilder>(this CreateTableBuilder<TEntityBuilder> table, PrimaryKey<TEntityBuilder> primaryKey) where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||
{
|
||||
table.PrimaryKey(primaryKey.Name, primaryKey.Columns);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
|
||||
namespace Oqtane.Migrations
|
||||
|
@ -25,12 +25,12 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
// GET api/<controller>/5
|
||||
[HttpGet("{id}")]
|
||||
[Authorize(Policy = PolicyNames.ViewModule)]
|
||||
public List<HtmlTextInfo> Get(int id)
|
||||
public List<Models.HtmlText> Get(int id)
|
||||
{
|
||||
var list = new List<HtmlTextInfo>();
|
||||
var list = new List<Models.HtmlText>();
|
||||
try
|
||||
{
|
||||
HtmlTextInfo htmlText = null;
|
||||
Models.HtmlText htmlText = null;
|
||||
if (_entityId == id)
|
||||
{
|
||||
htmlText = _htmlText.GetHtmlText(id);
|
||||
@ -48,7 +48,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
// POST api/<controller>
|
||||
[HttpPost]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public HtmlTextInfo Post([FromBody] HtmlTextInfo htmlText)
|
||||
public Models.HtmlText Post([FromBody] Models.HtmlText htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace Oqtane.Modules.HtmlText.Controllers
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Policy = PolicyNames.EditModule)]
|
||||
public HtmlTextInfo Put(int id, [FromBody] HtmlTextInfo htmlText)
|
||||
public Models.HtmlText Put(int id, [FromBody] Models.HtmlText htmlText)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ namespace Oqtane.Modules.HtmlText.Manager
|
||||
}
|
||||
else
|
||||
{
|
||||
htmlText = new HtmlTextInfo();
|
||||
htmlText = new Models.HtmlText();
|
||||
htmlText.ModuleId = module.ModuleId;
|
||||
htmlText.Content = content;
|
||||
_htmlText.AddHtmlText(htmlText);
|
||||
|
@ -4,7 +4,6 @@ using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
@ -26,9 +25,9 @@ namespace Oqtane.Modules.HtmlText.Migrations.EntityBuilders
|
||||
|
||||
protected override HtmlTextEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
HtmlTextId = ActiveDatabase.AddAutoIncrementColumn(table,"HtmlTextId");
|
||||
ModuleId = table.AddIntegerColumn("ModuleId");
|
||||
Content = table.AddMaxStringColumn("Content");
|
||||
HtmlTextId = AddAutoIncrementColumn(table,"HtmlTextId");
|
||||
ModuleId = AddIntegerColumn(table,"ModuleId");
|
||||
Content = AddMaxStringColumn(table,"Content");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
|
@ -16,6 +16,6 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<HtmlTextInfo> HtmlText { get; set; }
|
||||
public virtual DbSet<Models.HtmlText> HtmlText { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,20 +13,20 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public HtmlTextInfo GetHtmlText(int moduleId)
|
||||
public Models.HtmlText GetHtmlText(int moduleId)
|
||||
{
|
||||
return _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
|
||||
}
|
||||
|
||||
|
||||
public HtmlTextInfo AddHtmlText(HtmlTextInfo htmlText)
|
||||
public Models.HtmlText AddHtmlText(Models.HtmlText htmlText)
|
||||
{
|
||||
_db.HtmlText.Add(htmlText);
|
||||
_db.SaveChanges();
|
||||
return htmlText;
|
||||
}
|
||||
|
||||
public HtmlTextInfo UpdateHtmlText(HtmlTextInfo htmlText)
|
||||
public Models.HtmlText UpdateHtmlText(Models.HtmlText htmlText)
|
||||
{
|
||||
_db.Entry(htmlText).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
@ -35,7 +35,7 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
|
||||
public void DeleteHtmlText(int moduleId)
|
||||
{
|
||||
HtmlTextInfo htmlText = _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
|
||||
Models.HtmlText htmlText = _db.HtmlText.FirstOrDefault(item => item.ModuleId == moduleId);
|
||||
if (htmlText != null) _db.HtmlText.Remove(htmlText);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
public interface IHtmlTextRepository
|
||||
{
|
||||
HtmlTextInfo GetHtmlText(int moduleId);
|
||||
HtmlTextInfo AddHtmlText(HtmlTextInfo htmlText);
|
||||
HtmlTextInfo UpdateHtmlText(HtmlTextInfo htmlText);
|
||||
Models.HtmlText GetHtmlText(int moduleId);
|
||||
Models.HtmlText AddHtmlText(Models.HtmlText htmlText);
|
||||
Models.HtmlText UpdateHtmlText(Models.HtmlText htmlText);
|
||||
void DeleteHtmlText(int moduleId);
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,19 @@ namespace Oqtane.Repository
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
if (Databases != null)
|
||||
{
|
||||
var database = Databases.Single(d => d.Name == _databaseType);
|
||||
|
||||
database.UpdateIdentityStoreTableNames(builder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override int SaveChanges()
|
||||
{
|
||||
DbContextUtils.SaveChanges(this, _accessor);
|
||||
|
@ -20,6 +20,12 @@ namespace Oqtane.Interfaces
|
||||
|
||||
public string BuildConnectionString();
|
||||
|
||||
public string ConcatenateSql(params string[] values);
|
||||
|
||||
public string RewriteName(string name);
|
||||
|
||||
public void UpdateIdentityStoreTableNames(ModelBuilder builder);
|
||||
|
||||
public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ namespace Oqtane.Models
|
||||
{
|
||||
public string FriendlyName { get; set; }
|
||||
|
||||
public string HelpText { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
@ -5,8 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Models
|
||||
{
|
||||
[Table("HtmlText")]
|
||||
public class HtmlTextInfo : IAuditable
|
||||
public class HtmlText : IAuditable
|
||||
{
|
||||
[Key]
|
||||
public int HtmlTextId { get; set; }
|
59
Oqtane.Shared/Shared/OqtaneDatabaseBase.cs
Normal file
59
Oqtane.Shared/Shared/OqtaneDatabaseBase.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Shared
|
||||
{
|
||||
public abstract class OqtaneDatabaseBase : IOqtaneDatabase
|
||||
{
|
||||
protected OqtaneDatabaseBase(string name, string friendlyName, List<ConnectionStringField> connectionStringFields)
|
||||
{
|
||||
Name = name;
|
||||
FriendlyName = friendlyName;
|
||||
ConnectionStringFields = connectionStringFields;
|
||||
}
|
||||
|
||||
public string FriendlyName { get; }
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public abstract string Provider { get; }
|
||||
|
||||
public List<ConnectionStringField> ConnectionStringFields { get; }
|
||||
|
||||
public abstract OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name);
|
||||
|
||||
public abstract string BuildConnectionString();
|
||||
|
||||
public virtual string ConcatenateSql(params string[] values)
|
||||
{
|
||||
var returnValue = String.Empty;
|
||||
for (var i = 0; i < values.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
returnValue += " + ";
|
||||
}
|
||||
returnValue += values[i];
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public virtual string RewriteName(string name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public virtual void UpdateIdentityStoreTableNames(ModelBuilder builder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user