refactoring the code.
This commit is contained in:
@ -2,25 +2,26 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchDocumentEntityBuilder : AuditableBaseEntityBuilder<SearchDocumentEntityBuilder>
|
||||
public class SearchContentEntityBuilder : AuditableBaseEntityBuilder<SearchContentEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchDocument";
|
||||
private readonly PrimaryKey<SearchDocumentEntityBuilder> _primaryKey = new("PK_SearchDocument", x => x.SearchDocumentId);
|
||||
private const string _entityTableName = "SearchContent";
|
||||
private readonly PrimaryKey<SearchContentEntityBuilder> _primaryKey = new("PK_SearchContent", x => x.SearchContentId);
|
||||
|
||||
public SearchDocumentEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
public SearchContentEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
}
|
||||
|
||||
protected override SearchDocumentEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
protected override SearchContentEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
SearchDocumentId = AddAutoIncrementColumn(table, "SearchDocumentId");
|
||||
EntryId = AddIntegerColumn(table, "EntryId");
|
||||
IndexerName = AddStringColumn(table, "IndexerName", 50);
|
||||
SearchContentId = AddAutoIncrementColumn(table, "SearchContentId");
|
||||
EntityName = AddStringColumn(table, "EntityName", 50);
|
||||
EntityId = AddIntegerColumn(table, "EntityId");
|
||||
SiteId = AddIntegerColumn(table, "SiteId");
|
||||
Title = AddStringColumn(table, "Title", 255);
|
||||
Description = AddMaxStringColumn(table, "Description");
|
||||
@ -29,18 +30,17 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
ModifiedTime = AddDateTimeColumn(table, "ModifiedTime");
|
||||
IsActive = AddBooleanColumn(table, "IsActive");
|
||||
AdditionalContent = AddMaxStringColumn(table, "AdditionalContent");
|
||||
LanguageCode = AddStringColumn(table, "LanguageCode", 20);
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SearchDocumentId { get; private set; }
|
||||
public OperationBuilder<AddColumnOperation> SearchContentId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> EntryId { get; private set; }
|
||||
public OperationBuilder<AddColumnOperation> EntityName { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> IndexerName { get; private set; }
|
||||
public OperationBuilder<AddColumnOperation> EntityId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SiteId { get; private set; }
|
||||
|
||||
@ -57,8 +57,5 @@ namespace Oqtane.Migrations.EntityBuilders
|
||||
public OperationBuilder<AddColumnOperation> IsActive { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> AdditionalContent { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> LanguageCode { get; private set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchContentPropertyEntityBuilder : BaseEntityBuilder<SearchContentPropertyEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchContentProperty";
|
||||
private readonly PrimaryKey<SearchContentPropertyEntityBuilder> _primaryKey = new("PK_SearchContentProperty", x => x.PropertyId);
|
||||
private readonly ForeignKey<SearchContentPropertyEntityBuilder> _searchContentForeignKey = new("FK_SearchContentProperty_SearchContent", x => x.SearchContentId, "SearchContent", "SearchContentId", ReferentialAction.Cascade);
|
||||
|
||||
public SearchContentPropertyEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
|
||||
ForeignKeys.Add(_searchContentForeignKey);
|
||||
}
|
||||
|
||||
protected override SearchContentPropertyEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PropertyId = AddAutoIncrementColumn(table, "PropertyId");
|
||||
SearchContentId = AddIntegerColumn(table, "SearchContentId");
|
||||
Name = AddStringColumn(table, "Name", 50);
|
||||
Value = AddStringColumn(table, "Value", 50);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> PropertyId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SearchContentId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Value { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchContentWordsEntityBuilder : BaseEntityBuilder<SearchContentWordsEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchContentWords";
|
||||
private readonly PrimaryKey<SearchContentWordsEntityBuilder> _primaryKey = new("PK_SearchContentWords", x => x.WordId);
|
||||
private readonly ForeignKey<SearchContentWordsEntityBuilder> _searchContentForeignKey = new("FK_SearchContentWords_SearchContent", x => x.SearchContentId, "SearchContent", "SearchContentId", ReferentialAction.Cascade);
|
||||
private readonly ForeignKey<SearchContentWordsEntityBuilder> _wordSourceForeignKey = new("FK_SearchContentWords_WordSource", x => x.WordSourceId, "SearchContentWordSource", "WordSourceId", ReferentialAction.Cascade);
|
||||
|
||||
public SearchContentWordsEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
|
||||
ForeignKeys.Add(_searchContentForeignKey);
|
||||
ForeignKeys.Add(_wordSourceForeignKey);
|
||||
}
|
||||
|
||||
protected override SearchContentWordsEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
WordId = AddAutoIncrementColumn(table, "WordId");
|
||||
SearchContentId = AddIntegerColumn(table, "SearchContentId");
|
||||
WordSourceId = AddIntegerColumn(table, "WordSourceId");
|
||||
Count = AddIntegerColumn(table, "Count");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> WordId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SearchContentId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> WordSourceId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Count { get; private set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchContentWordSourceEntityBuilder : BaseEntityBuilder<SearchContentWordSourceEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchContentWordSource";
|
||||
private readonly PrimaryKey<SearchContentWordSourceEntityBuilder> _primaryKey = new("PK_SearchContentWordSource", x => x.WordSourceId);
|
||||
|
||||
public SearchContentWordSourceEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
}
|
||||
|
||||
protected override SearchContentWordSourceEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
WordSourceId = AddAutoIncrementColumn(table, "WordSourceId");
|
||||
Word = AddStringColumn(table, "Word", 255);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> WordSourceId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Word { get; private set; }
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchDocumentPropertyEntityBuilder : BaseEntityBuilder<SearchDocumentPropertyEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchDocumentProperty";
|
||||
private readonly PrimaryKey<SearchDocumentPropertyEntityBuilder> _primaryKey = new("PK_SearchDocumentProperty", x => x.PropertyId);
|
||||
private readonly ForeignKey<SearchDocumentPropertyEntityBuilder> _searchDocumentForeignKey = new("FK_SearchDocumentProperty_SearchDocument", x => x.SearchDocumentId, "SearchDocument", "SearchDocumentId", ReferentialAction.Cascade);
|
||||
|
||||
public SearchDocumentPropertyEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
|
||||
ForeignKeys.Add(_searchDocumentForeignKey);
|
||||
}
|
||||
|
||||
protected override SearchDocumentPropertyEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
PropertyId = AddAutoIncrementColumn(table, "PropertyId");
|
||||
SearchDocumentId = AddIntegerColumn(table, "SearchDocumentId");
|
||||
Name = AddStringColumn(table, "Name", 50);
|
||||
Value = AddStringColumn(table, "Value", 50);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> PropertyId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SearchDocumentId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Value { get; private set; }
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Databases.Interfaces;
|
||||
|
||||
namespace Oqtane.Migrations.EntityBuilders
|
||||
{
|
||||
public class SearchDocumentTagEntityBuilder : BaseEntityBuilder<SearchDocumentTagEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "SearchDocumentTag";
|
||||
private readonly PrimaryKey<SearchDocumentTagEntityBuilder> _primaryKey = new("PK_SearchDocumentTag", x => x.TagId);
|
||||
private readonly ForeignKey<SearchDocumentTagEntityBuilder> _searchDocumentForeignKey = new("FK_SearchDocumentTag_SearchDocument", x => x.SearchDocumentId, "SearchDocument", "SearchDocumentId", ReferentialAction.Cascade);
|
||||
|
||||
public SearchDocumentTagEntityBuilder(MigrationBuilder migrationBuilder, IDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
|
||||
ForeignKeys.Add(_searchDocumentForeignKey);
|
||||
}
|
||||
|
||||
protected override SearchDocumentTagEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
TagId = AddAutoIncrementColumn(table, "TagId");
|
||||
SearchDocumentId = AddIntegerColumn(table, "SearchDocumentId");
|
||||
Tag = AddStringColumn(table, "Tag", 50);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> TagId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> SearchDocumentId { get; private set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Tag { get; private set; }
|
||||
}
|
||||
}
|
@ -17,26 +17,34 @@ namespace Oqtane.Migrations.Tenant
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var searchDocumentEntityBuilder = new SearchDocumentEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentEntityBuilder.Create();
|
||||
var searchContentEntityBuilder = new SearchContentEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentEntityBuilder.Create();
|
||||
|
||||
var searchDocumentPropertyEntityBuilder = new SearchDocumentPropertyEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentPropertyEntityBuilder.Create();
|
||||
var searchContentPropertyEntityBuilder = new SearchContentPropertyEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentPropertyEntityBuilder.Create();
|
||||
|
||||
var searchDocumentTagEntityBuilder = new SearchDocumentTagEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentTagEntityBuilder.Create();
|
||||
var searchContentWordSourceEntityBuilder = new SearchContentWordSourceEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentWordSourceEntityBuilder.Create();
|
||||
searchContentWordSourceEntityBuilder.AddIndex("IX_SearchContentWordSource", "Word", true);
|
||||
|
||||
var searchContentWordsEntityBuilder = new SearchContentWordsEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentWordsEntityBuilder.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
var searchDocumentPropertyEntityBuilder = new SearchDocumentPropertyEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentPropertyEntityBuilder.Drop();
|
||||
var searchContentWordsEntityBuilder = new SearchContentWordsEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentWordsEntityBuilder.Drop();
|
||||
|
||||
var searchDocumentTagEntityBuilder = new SearchDocumentTagEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentTagEntityBuilder.Drop();
|
||||
var searchContentWordSourceEntityBuilder = new SearchContentWordSourceEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentWordSourceEntityBuilder.DropIndex("IX_SearchContentWordSource");
|
||||
searchContentWordSourceEntityBuilder.Drop();
|
||||
|
||||
var searchDocumentEntityBuilder = new SearchDocumentEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchDocumentEntityBuilder.Drop();
|
||||
var searchContentPropertyEntityBuilder = new SearchContentPropertyEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentPropertyEntityBuilder.Drop();
|
||||
|
||||
var searchContentEntityBuilder = new SearchContentEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
searchContentEntityBuilder.Drop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user