saml Posted July 27, 2020 Share Posted July 27, 2020 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? Link to comment Share on other sites More sharing options...
kongondo Posted July 27, 2020 Share Posted July 27, 2020 (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: ProcessDatabaseBackups - https://modules.processwire.com/modules/process-database-backups/ (quick, in out, all or nothing) 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 July 27, 2020 by kongondo clarification 3 Link to comment Share on other sites More sharing options...
saml Posted July 27, 2020 Author Share Posted July 27, 2020 Thanks for the quick reply @kongondo! Link to comment Share on other sites More sharing options...
pwfans Posted July 30, 2020 Share Posted July 30, 2020 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. Link to comment Share on other sites More sharing options...
ottogal Posted July 30, 2020 Share Posted July 30, 2020 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... 1 Link to comment Share on other sites More sharing options...
saml Posted August 1, 2020 Author Share Posted August 1, 2020 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now