Jump to content
joe_g

Change fieldname in db

Recommended Posts

Hi,

I have an old site that is using the field name 'start'. This is now a reserved word, so I cant update without error. I also can't run the site since its too old.

Is there a way I can rename the field in the database so I can upgrade the site?

thanks!

Share this post


Link to post
Share on other sites

How old is the site in terms of ProcessWire version?

Share this post


Link to post
Share on other sites

I think there are only two things you'll need to change.

1) The name of the table "field_start"

2) The "name" field/column for the field's row in the "fields" table.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for your help. The version is ProcessWire 3.0.36 © 2020, so perhaps not mega old.

Looks like I have other problems than just the field name. It's more some server compatibility thing, I think.

I tried again to copy the site to my dev server getting a similar result as before: Setup -> fields -> FIELD result in a blank page, where you only see the the processwire header and footer. The white part where you are supposed to edit the field is blank. It's the same for modules and templates. The pages tree works as normal but I cant edit templates, fields or modules. Weird 🙂

I get this error when trying to look at the modules page:

Warning: count(): Parameter must be an array or an object that implements Countable in [...]/InputfieldFile.module on line 441

 

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, joe_g said:

ProcessWire 3.0.36

If you had at least 3.0.148 you could have used this method (@note: I am not sure when this method was introduced though)

$field->setName($name);

https://processwire.com/api/ref/field/set-name/

1 hour ago, joe_g said:

The white part where you are supposed to edit the field is blank.

There's a host of reasons why this could be happening (judging by similar issues previously reported in the forums). It's hard to tell what could be the cause. Maybe going through this will shed some light?

https://processwire.com/docs/start/install/troubleshooting/

1 hour ago, joe_g said:

It's more some server compatibility thing

Maybe. What's your server details? (Apache, PHP, etc...)

  • Have you tried upgrading your ProcessWire version?
  • Is this a multilingual site?
  • Is this a multisite?
  • is mod_security running on the server?
Edited by kongondo
clarification

Share this post


Link to post
Share on other sites
11 hours ago, joe_g said:

The version is ProcessWire 3.0.36 © 2020, so perhaps not mega old.

Release date: 7 October 2016
https://processwire.com/blog/posts/processwire-3.0.36-and-looking-forward/

11 hours ago, joe_g said:

I get this error when trying to look at the modules page:


Warning: count(): Parameter must be an array or an object that implements Countable in [...]/InputfieldFile.module on line 441

This warning started in PHP 7.2, release date: 30 November 2017
https://en.wikipedia.org/wiki/PHP#Release_history

PHP is adding and deprecating features all the time. Not just a ProcessWire thing, but in general you don't want to run PHP software on a PHP version that didn't exist when that software was released.

  • Like 2

Share this post


Link to post
Share on other sites

I managed to get this to work by instead upgrading the site on the live server. I still got the 'start is reserved word' error, but the trick from @adrian worked in this case. I just renamed the table field_start -> field_start2, then in the fields table as well. I change the code accordingly. Worked really well.

To answer @kongondo: No its' not multilingual, nor multisite. Also not running mod_security.

Not sure why this update wouldn't work on my dev server. Both servers are running php 7.3. I suspect I had some other issue with permissions and template caching on my server, possibly unrelated to the above.

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...