Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeGetting StartedGetting StartedInstalling DNN ...Installing DNN ...Unable to create index during upgradeUnable to create index during upgrade
Previous
 
Next
New Post
6/17/2007 4:01 AM
 

Hi,

I just upgraded to 4.5.3 and it seems to have gone well with one exception.  The database upgrade script was unable to create one of the indexes for the table dbo.Folders.  The full details from 04.05.01.log are pasted below.  I'm not too familiar with indexes in SQL Server.  How significant is this error, and if it's significant, does anybody have any suggestions on how I can fix it?

System.Data.SqlClient.SqlException: CREATE UNIQUE INDEX terminated because a duplicate key was found for object name 'dbo.Folders' and index name 'IX_FolderPath'.  The duplicate key value is (0, GuidedTours/DotNetNuke/Modules/Announcements/).
Could not create constraint. See previous errors.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL)
   at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions)

/************************************************************/
/*****              SqlDataProvider                     *****/
/*****                                                  *****/
/*****                                                  *****/
/***** Note: To manually execute this script you must   *****/
/*****       perform a search and replace operation     *****/
/*****       for dbo. and   *****/
/*****                                                  *****/
/************************************************************/


/* add unique constraint to Folders table */
IF NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'dbo.[IX_FolderPath]') and OBJECTPROPERTY(id, N'IsConstraint') = 1)
BEGIN
  declare @PortalID int
  declare @FolderPath varchar(300)
  declare @FolderID int
  declare @MinFolderID int

  select @PortalID = min(PortalID)
  from dbo.Portals
  while @PortalID is not null
  begin 
    /* check for duplicate FolderPaths */
    select @FolderPath = null
    select @FolderPath = FolderPath
    from dbo.Folders
    where PortalID = @PortalID
    group by FolderPath
    having COUNT(*) > 1
 
    /* if duplicates exist */
    if @FolderPath is not null
    begin
      /* iterate through the duplicates */
      select @FolderID = min(FolderID)
      from dbo.Folders
      where PortalID = @PortalID
      and FolderPath = @FolderPath

      /* save min FolderID */
      select @MinFolderID = @FolderID

      while @FolderID is not null
      begin
        if @FolderID <> @MinFolderID
        begin
          /* reassign FolderId to min FolderID for duplicate folders */
          update dbo.Files
          set FolderID = @MinFolderID
          where FolderID = @FolderID

          /* remove duplicate folder */
          delete
          from dbo.Folders
          where FolderID = @FolderID
        end

        select @FolderID = min(FolderID)
        from dbo.Folders
        where PortalID = @PortalID
        and FolderPath = @FolderPath
        and FolderID > @FolderID
      end
    end
 
    select @PortalID = min(PortalID)
    from dbo.Portals
    where PortalID > @PortalID
  end

  /* add unique constraint */
  ALTER TABLE dbo.Folders ADD CONSTRAINT
    IX_FolderPath UNIQUE NONCLUSTERED
    (
      PortalID,
      FolderPath
    ) ON [PRIMARY]
END


System.Data.SqlClient.SqlException: CREATE UNIQUE INDEX terminated because a duplicate key was found for object name 'dbo.Files' and index name 'IX_FileName'.  The duplicate key value is (179, admin.ascx).
Could not create constraint. See previous errors.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at DotNetNuke.Data.SqlDataProvider.ExecuteADOScript(String SQL)
   at DotNetNuke.Data.SqlDataProvider.ExecuteScript(String Script, Boolean UseTransactions)


/* add unique constraint to Files table */
IF NOT EXISTS (select * from dbo.sysobjects where id = object_id(N'dbo.[IX_FileName]') and OBJECTPROPERTY(id, N'IsConstraint') = 1)
BEGIN
  declare @FolderID int
  declare @FileName nvarchar(100)
  declare @FileID int
  declare @MinFileID int

  select @FolderID = min(FolderID)
  from dbo.Folders
  while @FolderID is not null
  begin 
    /* check for duplicate Filenames */
    select @FileName = null
    select @FileName = FileName
    from dbo.Files
    where FolderID = @FolderID
    group by FileName
    having COUNT(*) > 1
 
    /* if duplicates exist */
    if @FileName is not null
    begin
      /* iterate through the duplicates */
      select @FileID = min(FileID)
      from dbo.Files
      where FolderID = @FolderID
      and FileName = @FileName

      /* save min FileID */
      select @MinFileID = @FileID

      while @FileID is not null
      begin
        if @FileID <> @MinFileID
        begin
          /* remove duplicate file */
          delete
          from dbo.Files
          where FileID = @FileID
        end

        select @FileID = min(FileID)
        from dbo.Files
        where FolderID = @FolderID
        and FileName = @FileName
        and FileID > @FileID
      end
    end

    select @FolderID = min(FolderID)
    from dbo.Folders
    where FolderID > @FolderID
  end
  
  ALTER TABLE dbo.Files ADD CONSTRAINT
    IX_FileName UNIQUE NONCLUSTERED
    (
      FolderID,
      FileName
    ) ON [PRIMARY]
END

 

 



Shane Miller
Call Centers 24x7
 
New Post
6/17/2007 7:12 AM
 

try to delete manually in the database, tables folders the duplicate entry for folder GuidedTours/DotNetNuke/Modules/Announcements/ and from files duplicate admin.ascx. Afterwards, log in as host user, go to SQL in host menu load the script and execute it.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedInstalling DNN ...Installing DNN ...Unable to create index during upgradeUnable to create index during upgrade


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out