Skip to content

TASK: Remove outdated columns from activeforums_Forums table #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Dnn.CommunityForums/DnnCommunityForums.dnn
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,15 @@
<name>09.00.00.SqlDataProvider</name>
<version>09.00.00</version>
</script>
<script type="Install">
<path>sql</path>
<name>09.01.00.SqlDataProvider</name>
<version>09.01.00</version>
</script>
<script type="UnInstall">
<path>sql</path>
<name>Uninstall.SqlDataProvider</name>
<version>09.00.00</version>
<version>09.01.00</version>
</script>
</scripts>
</component>
Expand Down
19 changes: 10 additions & 9 deletions Dnn.CommunityForums/Entities/ForumInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public string LastPostTopicUrl
[IgnoreColumn]
public bool LastPostIsTopic => this.LastReplyId == 0;

[IgnoreColumn]
public string LastPostSubject
{
get
Expand Down Expand Up @@ -222,15 +223,15 @@ internal DotNetNuke.Modules.ActiveForums.Entities.IPostInfo LoadLastPost()

// return this.lastPostInfo = this.LastReplyId == 0 ? (DotNetNuke.Modules.ActiveForums.Entities.IPostInfo)new DotNetNuke.Modules.ActiveForums.Controllers.TopicController(this.ModuleId).GetById(this.LastTopicId) : new DotNetNuke.Modules.ActiveForums.Controllers.ReplyController(this.ModuleId).GetById(this.LastReplyId);
}

[ColumnName("LastPostAuthorName")]
public string LastPostUserName { get; set; }

[ColumnName("LastPostAuthorId")]
public int LastPostUserID { get; set; }

[ColumnName("LastPostDate")]
public DateTime? LastPostDateTime { get; set; }
[IgnoreColumn]
public string LastPostUserName => this.LastPost != null && this.LastPost.Content != null ? this.LastPost.Content.AuthorName : string.Empty;
[IgnoreColumn]
public int LastPostUserID => this.LastPost != null && this.LastPost.Content != null ? this.LastPost.Content.AuthorId : DotNetNuke.Common.Utilities.Null.NullInteger;
[IgnoreColumn]
public DateTime? LastPostDateTime => this.LastPost != null && this.LastPost.Content != null ? (DateTime)this.LastPost.Content.DateUpdated : DotNetNuke.Common.Utilities.Null.NullDate;

public int PermissionsId { get; set; }

Expand Down
31 changes: 31 additions & 0 deletions Dnn.CommunityForums/sql/09.01.00.SqlDataProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SET NOCOUNT ON
GO

/* issue 792 begin - activeforums_Forums -- remove columns no longer used */

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_{objectQualifier}activeforums_Forums_LastPostId]') AND type = 'D')
ALTER TABLE {databaseOwner}{objectQualifier}activeforums_Forums DROP CONSTRAINT DF_{objectQualifier}activeforums_Forums_LastPostId
GO
IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'LastPostId' AND [object_id] = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums]'))
ALTER TABLE {databaseOwner}[{objectQualifier}activeforums_Forums] DROP COLUMN LastPostId
GO
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_{objectQualifier}activeforums_Forums_LastPostAuthorId]') AND type = 'D')
ALTER TABLE {databaseOwner}{objectQualifier}activeforums_Forums DROP CONSTRAINT DF_{objectQualifier}activeforums_Forums_LastPostAuthorId
GO
IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'LastPostAuthorId' AND [object_id] = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums]'))
ALTER TABLE {databaseOwner}[{objectQualifier}activeforums_Forums] DROP COLUMN LastPostAuthorId
GO
IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'LastPostAuthorName' AND [object_id] = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums]'))
ALTER TABLE {databaseOwner}[{objectQualifier}activeforums_Forums] DROP COLUMN LastPostAuthorName
GO
IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'LastPostSubject' AND [object_id] = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums]'))
ALTER TABLE {databaseOwner}[{objectQualifier}activeforums_Forums] DROP COLUMN LastPostSubject
GO
IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'LastPostDate' AND [object_id] = OBJECT_ID(N'{databaseOwner}[{objectQualifier}activeforums_Forums]'))
ALTER TABLE {databaseOwner}[{objectQualifier}activeforums_Forums] DROP COLUMN LastPostDate
GO

/* issue 792 end - activeforums_Forums -- remove columns no longer used */

/* --------------------- */