Jump to content
alan

Cleaning out my database

Recommended Posts

I have setup a simple tagging facility.

Afterwards I saw Nico's BundleBlog and noted it uses /tags/.

So I decided to change my setup from references to fields, templates, etc that were 'tags' to 'tagging'.

I used 'Edit field: tags > Duplicate/clone this field'. That gave me 'tags_1'.

I then edited 'tags_1' and went to rename it to 'tagging' and hit an error, PW said this name already existed. It seems from my trial/error/learn process I have ended up with at least two fields in my database (seen via MySQL) that aren't listed under Amin > Setup > Fields and one of those is called 'tagging'.

What is the best way to clear old/unused things, or, is this an edge case and it's only my trial and error steps that have led to this odd situation and ought I do make a new PW install and manually copy settings over. I don't mind doing that at all, my only concern is that I'd like to learn from this so were this a larger site I could perhaps recover in a more subtle (and quicker) way.

Thanks in advance for any pointers.

PS: The error is Table 'tmp_field_tagging' already exists

PPS: I've got around this by using the new name of 'tagged' instead of 'tagging', but I'd love to learn if defunct bits of my database can be safely cleared out somehow, e.g. I now have these four fields and yet only one will be used.

PPPS: Thinking about this, I will need to learn how to clear out old unused db items as I will be using Nico's Blog Module and that will need 'tags' to be gone. On reflection I think I was caught out by this/surprised as I assumed deleting a field would delete part fo the db that had been created to represent that field.

Edited by alan

Share this post


Link to post
Share on other sites

Could it be that the field is system thus not visible by default. Try setting the filter to show system fields too.

Share this post


Link to post
Share on other sites

Thanks for the suggest Soma, I tried that already and it is still not shown. I edited my post above and added "...I assumed deleting a field would delete the part of the db that had been created to represent that field..." and as well as the specific problem/clean-up I need to do, generally, is it normal/safe (I have no clue) for tables to be left behind? E.g. in MySQL I can see:

field_tagged

field_tagging

field_tags_alan

and in the Admin as I read down it goes:

sidebar

summary

tagged

title

?

Share this post


Link to post
Share on other sites

NO it's not :) Most likely it's due to some excessive trying... If you delete a field the table will get deleted too.

Share this post


Link to post
Share on other sites

Excessive trying, that sounds like me ;) One day I hope to upgrade to excessive succeeding...

Btw, those things called:

field_tagged

field_tagging

field_tags_alan

are, I believe, MySQL tables not fields (PW naming convention).

Share this post


Link to post
Share on other sites

What "flags" do they have that don't show in the admin field list? Are they used in any fieldgroup?

You can delete them manually, in the tables fieldgroup_fields first (look for id) and fields table, then the table of the field itself field_x.

Edit:

Though I also after excessive coding, trying got this issue ones, I delete the table and it's references manually.

BUt maybe would be good to know what the problem could be that this happens.

Share this post


Link to post
Share on other sites
What "flags" do they have that don't show in the admin field list? Are they used in any fieldgroup?

You can delete them manually, in the tables fieldgroup_fields first (look for id) and fields table, then the table of the field itself field_x.

I don't see any references to "flags"? I'm using Navicat.app GUI which shows me this, and if I understand it correctly if I can't work out if they appear in fieldgroup_fields then I can't safely delete them do you think?

BUt maybe would be good to know what the problem could be that this happens.

Yes, I think so.

Share this post


Link to post
Share on other sites

This is just the data table of the field. field_x table. The fields table holds the information (title etc) of the field and has flags column.

If the field is not attached to any template there will be no relation entry in the fieldgroups_fields. So you could next go to the fields table and delete the field you want to delete. Then the data table of the field itself (field_xxx).

Share this post


Link to post
Share on other sites

Thanks Soma, I found both the tables I thought I didn't need or want were indeed not listed by name etc in table fields and so I went ahead and deleted both tables. All still working AOK.

Thanks very much for your help. I don't know if a database administrator would worry about old tables getting left behind or not, if they would then perhaps this ought to be added somehow as a 'todo' on github passed to Ryan to decide on priority etc? If there's anything I can do to help (I doubt it as I have too few synapses ;) then I'd be happy to, I could at least test new builds to see if I can break them :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DooM
      Hello guys,
      I'm trying to figure out how to sync fields and templates between staging and production environments.
      I've found Migrations module by Lostkobrakai, but with use of it all the fields and templates must be created by API, which is kind of uncomfortable.
      I also tried ProcessDatabaseBackups module which can export only certain tables, but I don't think it's the best practice to do that.
      How do you guys solve this problem? It's very annoying to setup everything three times (dev, staging, production).
      Thanks a lot :)
    • By iipa
      Hi everybody!
      I have been reading about Multisite, but it kinda bugs me that every topic talks about having both admin and database same for multiple sites.
      I have a project where customer tests it by adding content to the site, while I still need to do some changes here and there in code, maybe some in database. If something crashes for a while, customer can't keep testing, which is a bit problematic.
      Is there any way that I could have two separate versions of one site ("production" and development) that share the same database, but are otherwise independent? Just the thought of having to migrate database every time I want to show client something new gives me anxiety 😁
    • By Falk
      Hi!
      After temporarily using Module Image Extra, which I completely removed, I had some troubles with my imagefield (unused table columns).
      So I just imported a previous version of this column via PHPmyAdmin, which worked pretty well.
      Anyways, in Processwire Backend all image tags are gone, although they are OK in the database.
      Other image related things work (thumbnail, title etc are OK).
      Is there any way to recreate all the images or something? Or may this be an cache-related issue?
       
      Thanks in advance 😃
       
    • By anttila
      We have many booking calendars made with ProcessWire (own databases) and I want to do a web app (SQL) which allows user to log in. First, the user chooses the right calendar and then (s)he have to log in. The user can be from any of those calendars and the app is not running on ProcessWire (it can if necessary). So if there any way to make sure that the user has rights to the calendar (s)he tries to log in and if the password is correct.
      Is there any better way to do this? I could also use PIN codes or something, but those need to be encrypted too.
      Multiple ProcessWires A lot of users per ProcessWire Everyone can log in to the web app (when using right calendar)
×
×
  • Create New...