Answers.Body: <p>As it turned out, database tables on this Craft project were missing foreign key constraints, and since Craft relies on the CASCADING DELETE/UPDATE functionality of these foreign keys, it was not deleting all associated rows across tables for a deleted entry. This can happen when migrating a database backup to a server that only supports MyISAM and not InnoDB because MyISAM will silently drop the foreign key constraints. </p>
  
  <p>If this happens, you can use the <a href="https://github.com/pixelandtonic/craft-fixfks" rel="nofollow">Craft Foreign Key Restoration Tool</a> to try and restore the missing foreign keys.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-30T20:44:43.230Z
Answers.LastActivityDate: 2015-09-30T21:08:03.697Z
Answers.LastEditDate: 2015-09-30T21:08:03.697Z
Answers.UserDisplayName: Aaron Berkowitz
Body: <p>We're having a bit of a problem with the unique URL system in Craft. An entry was deleted, and a new one has been created to replace it. However the new entry should have the same URL as the old removed one, but Craft is insisting on appending -2, -3, etc to the entry URL.</p>
  
  <p>Is this a bug? There is currently no way to recover a deleted page in the CMS, and I can't find a way to purge previously deleted entry URLs without editing the database directly.</p>
  
  <p>Has anyone got any idea? Is this a bug, or is there a solution? Obviously when handed over to a client I can't ask them to just pop into MySQL and remove old entries.</p>
  
  <p>Thanks,
  Ian</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-30T14:28:48.877Z
Comments.Text: Hey Ian - Just tried this on my local machine and was able to create a new entry with an old URL without any issue. Are you using a channel, structure, or single for this section?
Comments.UserDisplayName: Aaron Berkowitz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-30T14:31:28.240Z
Comments.Text: Hi Aaron, I've not noticed this problem before either. Not sure why it's behaving like this now. I'm guessing it's a bug of some kind. It's a structure item.
Comments.UserDisplayName: Ian Nebbiolo
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-30T14:35:44.220Z
Comments.Text: Can you submit a ticket through the control panel so I can take a closer look at your logs and database?
Comments.UserDisplayName: Aaron Berkowitz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-30T14:41:16.927Z
Comments.Text: I've submitted a ticket. This seems to be occurring on three of our current builds all running 2.4.2691. They were all created from the same Craft build we use as a starting point. I'm not getting that error on a client site built from scratch (now running 2.4.2684).
Comments.UserDisplayName: Ian Nebbiolo
Tags: <entries><url>
Title: Deleted page URLs
ThreadText: # Deleted page URLs
  
  (Asked by: username_0 on 2015-09-30)
  
  We're having a bit of a problem with the unique URL system in Craft. An entry was deleted, and a new one has been created to replace it. However the new entry should have the same URL as the old removed one, but Craft is insisting on appending -2, -3, etc to the entry URL.
  
  Is this a bug? There is currently no way to recover a deleted page in the CMS, and I can't find a way to purge previously deleted entry URLs without editing the database directly.
  
  Has anyone got any idea? Is this a bug, or is there a solution? Obviously when handed over to a client I can't ask them to just pop into MySQL and remove old entries.
  
  Thanks,
  Ian
  
  **Tags:** entries, url
  
  > **Comments:**
  > **username_1**: Hey Ian - Just tried this on my local machine and was able to create a new entry with an old URL without any issue. Are you using a channel, structure, or single for this section?  
  > **username_0**: Hi username_1, I've not noticed this problem before either. Not sure why it's behaving like this now. I'm guessing it's a bug of some kind. It's a structure item.  
  > **username_1**: Can you submit a ticket through the control panel so I can take a closer look at your logs and database?  
  > **username_0**: I've submitted a ticket. This seems to be occurring on three of our current builds all running 2.4.2691. They were all created from the same Craft build we use as a starting point. I'm not getting that error on a client site built from scratch (now running 2.4.2684).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-09-30. Score: 2 | Accepted answer
  
  As it turned out, database tables on this Craft project were missing foreign key constraints, and since Craft relies on the CASCADING DELETE/UPDATE functionality of these foreign keys, it was not deleting all associated rows across tables for a deleted entry. This can happen when migrating a database backup to a server that only supports MyISAM and not InnoDB because MyISAM will silently drop the foreign key constraints.
  
  If this happens, you can use the [Craft Foreign Key Restoration Tool](https://github.com/pixelandtonic/craft-fixfks) to try and restore the missing foreign keys.
  
  
  ---
  
  