Jump to content
Sign in to follow this  
saml

Is is possible to restore page ID succession to start by a low number when deleting pages?

Recommended Posts

I have a case where I have been troubleshooting a page import script (via commandline) by repeatedly importing a bunch of pages (a bit over a hundred), deleting them, adjusting my import process and then redoing this, over and over. The result is now that page IDs are starting to be up over 10 000. Not an actual problem of course, but it would somehow look nicer if those early pages had page IDs starting from a lower number.

Thus I was wondering if there is a way to "restore" the increasing page ID number to start by a low number, when deleting pages?

Can it be done through the API somehow, or would I need to dive in and fix the AUTO_INCREMENT value in the database, and would that risk to lead to other problems?

Share this post


Link to post
Share on other sites
Posted (edited)
52 minutes ago, saml said:

Can it be done through the API somehow,

No.

52 minutes ago, saml said:

and would that risk to lead to other problems?

It could.

52 minutes ago, saml said:

or would I need to dive in and fix the AUTO_INCREMENT value in the database

Not worth the hassle. Instead, I'd suggest you try one of the 'restore' DB modules or at 'worst', do a manual save state of DB and restore it after each of your import script tests.

Some candidates to do this:

  1. ProcessDatabaseBackups - https://modules.processwire.com/modules/process-database-backups/ (quick, in out, all or nothing)
  2. RockMigrations  - https://modules.processwire.com/modules/rock-migrations/ (if you want fine-grained control BUT I am not sure how it deals with pages )
Edited by kongondo
clarification
  • Like 3

Share this post


Link to post
Share on other sites

I also thinking about how to "reset" page ID, in my case after web development finish, there are thousand pages used while at development stage for testing, database backup module from ryan give a very convenience way to "reset/back to safe point" but it s not bulletproof solution in my case, restoring database backup will also delete all pages, templates, fields that need to used after development finished.

Now i use recycle way, i unpublished those redundant pages, and make API used them first whenever need new page until those redundant page all use up.

Share this post


Link to post
Share on other sites
On 7/27/2020 at 2:37 PM, saml said:

it would somehow look nicer if those early pages had page IDs starting from a lower number

The gain of "nicer looking" IDs is way smaller than the possible loss of consistency or risk of side effects not being aware of...

  • Like 1

Share this post


Link to post
Share on other sites

Thanks all for the input! 👍

I ended up re-creating the site from scratch and doing the (now finished) import workflow one final time (and for any subsequent updates via API made sure to just update existing pages when possible). It worked OK for me as I didn't have too much manually set up pages, so I could redo it all in under an hour anyways.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...