Mackski Posted February 13, 2017 Share Posted February 13, 2017 Don't ask how, but it's happened, my templates tables has been deleted by a third party working on the site. No backup, nada. Is there ANY way to recreate this table using existing / code / schema / data? I feel sick Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2017 Share Posted February 13, 2017 Do you still have the fieldgroups table? So long as you don't have any unusual settings where a template is using an alternate fieldgroup, you can probably build this back up again with relative ease. I would start with a templates table from another install and delete all the templates which aren't relevant to the problem site. Then use the fieldgroups table to get the names of the templates and the fieldgroups_id value for that column in the templates table. Once you have rebuilt all the rows in the templates table, I would manually add back the template access / family settings etc. Hope that makes sense and helps. Good luck! Link to comment Share on other sites More sharing options...
Mackski Posted February 13, 2017 Author Share Posted February 13, 2017 Hey Adrian, yes the only table deleted was templates. I have everything else. I'm still crying on the inside. I'll give it a shot and see what I can come up with. Anyone looking for some extra work Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2017 Share Posted February 13, 2017 29 minutes ago, Mackski said: Anyone looking for some extra work I can help out if you want, but I would have a go at it yourself first. The part that I could do really shouldn't take that long via PHPMyAdmin or some other MySQL GUI. The time consuming bit will be the template access/family settings which I wouldn't know how you would want configured anyway. Link to comment Share on other sites More sharing options...
Mackski Posted February 13, 2017 Author Share Posted February 13, 2017 39 minutes ago, adrian said: Do you still have the fieldgroups table? So long as you don't have any unusual settings where a template is using an alternate fieldgroup, you can probably build this back up again with relative ease. I would start with a templates table from another install and delete all the templates which aren't relevant to the problem site. Then use the fieldgroups table to get the names of the templates and the fieldgroups_id value for that column in the templates table. Once you have rebuilt all the rows in the templates table, I would manually add back the template access / family settings etc. Hope that makes sense and helps. Good luck! Ok, so the fieldgroups_id in templates corresponds to the id in fieldgroups? I can see some templates have a flag column, set to 8 for repeaters. Link to comment Share on other sites More sharing options...
Robin S Posted February 13, 2017 Share Posted February 13, 2017 If you have ever updated the PW version using the Upgrades module you probably will have created a DB backup then. Is there anything in /site/assets/backups/database/ ? For the future: http://modules.processwire.com/modules/cronjob-database-backup/ 1 Link to comment Share on other sites More sharing options...
Mackski Posted February 13, 2017 Author Share Posted February 13, 2017 Unfortunately not Robin. Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2017 Share Posted February 13, 2017 28 minutes ago, Mackski said: Ok, so the fieldgroups_id in templates corresponds to the id in fieldgroups? I can see some templates have a flag column, set to 8 for repeaters. Yes - that's right in both cases! Let us know how you it goes. Link to comment Share on other sites More sharing options...
Mackski Posted February 13, 2017 Author Share Posted February 13, 2017 2 minutes ago, adrian said: Yes - that's right in both cases! Let us know how you it goes. How would I then ensure the pages are still linked to the correct template? Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2017 Share Posted February 13, 2017 Just now, Mackski said: How would I then ensure the pages are still linked to the correct template? Ah yes, the next step in the puzzle. This is where you'll need to match the id of each row in the templates table to the appropriate "templates_id" field in the Pages table. No magic here, just careful manual matching. I wouldn't touch the Pages table at all though - be sure to change the id in the templates table. Link to comment Share on other sites More sharing options...
Mackski Posted February 13, 2017 Author Share Posted February 13, 2017 Off topic, how does PW handle PDO inserts? Cant find any examples, plenty of SELECT statement examples. Link to comment Share on other sites More sharing options...
adrian Posted February 13, 2017 Share Posted February 13, 2017 Here's one example: https://github.com/processwire/processwire/blob/50f2834a0ae2a9f9f2ac53439184ebdc04db2f54/wire/modules/PagePaths.module#L216-L222 Link to comment Share on other sites More sharing options...
Mackski Posted February 14, 2017 Author Share Posted February 14, 2017 For the most part I've restored my templates, except repeaters seem to be broken. Not showing fields. Also the system seems to be re-adding repeaters in the templates table; eg:repeater_draw_nomination_repeater1 If I delete this entry, the next page refresh will add:repeater_draw_nomination_repeater2 Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2017 Share Posted February 14, 2017 Did you check the template id of the repeater template against the template_id specified in the data column in the "fields" table for the repeater field? And of course remember that repeater templates are named: repeater_repeaterfieldname 1 Link to comment Share on other sites More sharing options...
Mackski Posted February 14, 2017 Author Share Posted February 14, 2017 32 minutes ago, adrian said: Did you check the template id of the repeater template against the template_id specified in the data column in the "fields" table for the repeater field? And of course remember that repeater templates are named: repeater_repeaterfieldname That did the trick, the ID's were different in the serialized data. I changed them and they now work. Now to just restoring template settings and permissions. Thanks for you help Adrian! 1 Link to comment Share on other sites More sharing options...
Mackski Posted February 14, 2017 Author Share Posted February 14, 2017 I still get an error/warning, which doesnt seem to effect anything so far: You must assign a template to the page before setting custom field values (title__data) [pageClass=Page, template=] Link to comment Share on other sites More sharing options...
adrian Posted February 14, 2017 Share Posted February 14, 2017 9 minutes ago, Mackski said: I still get an error/warning, which doesnt seem to effect anything so far: You must assign a template to the page before setting custom field values (title__data) [pageClass=Page, template=] Any chance there is a page that is assigned to a template_id that doesn't exist? 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