Hi,
I had a 4.7 version of Drupal, with CCK version 1.56.2.3. Of course with this drupal and CCK version I had custom content types with custom text fields.

I tried to upgrade drupal to 5.0. Everything worked fine, even the system update. It updated from "1000" version, don't know what it means. To do the update I deleted all the files in my drupal directory and I put the new files instead.

So I downloaded the 5.0 1.2 version of cck and I put it in all/modules folder. I then tried to launch again the update.php script. It detected that I have to do the update all the way from 7 to the last one. (1001 I think)

And so the problem occured. I had a warning,
[quote]
user warning: Table 'testing.node_content_type' doesn't exist query: SELECT type_name FROM node_content_type WHERE type_name LIKE 'content-%' in /srv/www/vhosts/mindenice.fr/subdomains/testing/httpdocs/includes/database.mysql.inc on line 167.
[/quote]

The patch number 7, 8 and 9 had no queries in them, and the patch 1001 created the good content types. But when I look at my website, I cannot see the fields. The database table node_content_article is still there (article is a name I gave to a content type) with its content, so nothing is lost, but I cannot see them.

Anybody has an idea what I can do to fix this?

Thanks

Comments

Julien PHAM’s picture

By the way, I should add I can edit story or page types, but when I try to edit an article type, it does nothing. So I guess it goes with this missing table stuff...

karens’s picture

Theoretically, this isn't possible (not that I'm trying to say it didn't happen.) I suspect you either had an incorrect schema version in your original system, or you did things out of order, like updating core and CCK at the same time.

We might be able to figure out how to clean up your tables, but it would be better to just do it over if you have a backup of both your database and the drupal folder with the 4.7 files in it. If so, put the 4.7 files back, delete your new database tables and restore the old ones, and try again.

But before you do, check the status of your system (I'm assuming you have phpmyadmin or somthing that you can use to look into your database).

1) Check the schema version of the 4.7 database by going to the 'system' table and searching for a record with the name 'content' and see what the schema version is.

2) Now look and see if you have a table called 'node_type' or a table called 'node_type_content'. If your schema version is back at 7 you should have a table called 'node_type'.

3) Browse that table and see what the content type names look like. If your database is truly at 7, they should look like 'content-type' otherwise they will look like 'content_type'.

If your schema version is 7 or less but you have a table called 'node_type_content' or your content names look like 'content_type', your schema version is wrong and needs to be reset. Come back here and describe what you have and we'll help you figure out what it really should be.

If the schema version and the table names seem to be correct, try the update again.

1) Uninstall all your non-core modules, including all CCK modules. THIS IS CRITICAL!!!!

2) Change your theme back to bluemarine.

3) remove all the files in your drupal folder and replace them with the 5.x core files. DO NOT PUT YOUR CCK FILES ON THE SERVER YET. If you uninstalled all your modules before getting to this point, you should be fine, but if you accidentally left one of them installed, your database is going to check its records and note that it is installed and try to update it when you do the core update, and we don't want that to happen.

4) Run the update.php on ONLY THE CORE FILES!!! If you uninstalled all non-core modules, this is what will happen by default.

Since you had problems the first time, stop now and take a look at your database. It should have renamed your node_type table to node_type_content, and added a new node_type table, so you should see both tables there. If you look at the records in the node_type_content table, they should be the content type(s) you created with CCK and still have the same names they had in your 4.7 version. If you don't see both tables or your don't see your content types, stop and come back here and report what you find before going any further.

5) Now add the 5.x versions of the CCK files to the server.

6) Go to the modules installation page and install them.

7) Go to update.php and run the updates for CCK.

If you do things exactly this way it should work correctly.

In case you're wondering why this is so complicated, it's because the core node module has taken over a table that CCK created, so there are extra hoops to jump through to be sure core doesn't erase CCK info and CCK doesn't undo anything core did.

RayZ’s picture

@KarenS: Thanks, this will come in handy when I go to upgrade my site. Is this procedure documented anywhere else? I didn't see it in the UPGRADE.txt file or the handbook pages. It would be good to have it there as well if it really is critical to follow all these steps.

karens’s picture

Well it's critical to figuring out where in the process he got goofed up, but it is also good procedure in any case, I guess. I could add it to the CCK handbook page on upgrading.

yched’s picture

@RayZ : the second series of steps (1 to 7) described by Karen for global site upgrade are the official recommendations you'll find on the "upgrade" section of the handbooks (http://drupal.org/upgrade/) and in the UPGRADE.txt that ships with the drupal tarball.
(After checking in update.php, though, it should be enough to disable contrib modules, without actually removing the files from the server.)
This is often overlooked (also by myself...), but is really important, especially for major version upgrades. And 4.7->5.0 is a critical upgrade as far as CCK is concerned, for the reasons Karen explained.
I'm not sure we need additional cck-specific documenation about this; Maybe a warning on the cck project page ?

The first series of steps (1 to 3 - check cck schema version, 'node_type' / 'node_type_content' stuff...) is rather asking for more info in order to debug Julien's failed upgrade. You normally should not have to bother about that.

karens’s picture

@yched, you're right except that in the 4.7 to 5.0 upgrade you remove *everything* from the server, so the only question is when in the process you put the 5.x version of CCK back on it. If someone for some reason forgot to uncheck one of the CCK modules (easy to do since they are scattered all over the place in 4.7, and I did it myself) then it is possible that if you put the CCK files back on the server before you run the upgrade that the system will say 'aha, I need to upgrade this, too'. It should not be a problem, but wouldn't be a bad procedure to follow just in case not to put them on the server until the core upgrade is done. As I said, one reason I thought of this is I just did it myself and was surprised to find I upgraded something I didn't mean to.

karens’s picture

And just so people following this thread don't get the idea that this is a really ugly upgrade, I've done a dozen or so upgrades now of sites with lots of CCK content types and only had one problem (and it was on a demo site where I had corrupted the database by monkeying around with it and was no fault of CCK). The really important thing is to run the core upgrade before you run the CCK upgrade. If you do that (however you get it done) you should be OK.

Julien PHAM’s picture

@KarenS
No problem, I'm doing the upgrade stuff on a copy of my original drupal installation, to be sure I'll not have any problem, so I can start again the update from scratch.

So I went to the system table, and the scheme_version of my "content" module is displayed as 6. And my tables look like node_content_articles for instance... So there's a problem with the version they say I have?

And I have a table named node_type. But I have no node_type_content table, the content is in node_content_articles.

And my table node_type has a record in it : content-article.

So according to what I say, could I try the update again, or should I wait?

Thanks

karens’s picture

That all looks consistent with version 6, so I think your schema is right. Go ahead and try the update again, but be sure to uninstall all CCK modules first and don't install them again after upgrading to 5.0. Stop after upgrading core and check to see what tables you have before installing CCK.

Julien PHAM’s picture

Finally I have decided to upgrade the core and database to the latest drupal version. I'll try this afternoon upgrading to 5.0 version to see what it does...

Julien PHAM’s picture

Ok, so I did the update of only core files.
Now I'm checking the database...

Indeed now I have both node_type and node_type_content tables.
And the content of node_type_content table seems ok.

Now I'm adding CCK modules to server if "default" folder... ok
I'm installing'em in module section... ok
And I'm trying the update again... content module is at 7 version according to the dialog box, and all cck modules are up to date...

And I have the same error : Table 'testing.node_content_type' doesn't exist

Normal, as the table is named node_type_content, and not node_content_type. Is it because the updater for cck is not accurate? Is it because I have not the good cck version? I downloaded the version on drupal website, in the module tabs.

Julien PHAM’s picture

I think the issue is in the content.install file.
There is a function named content_update_7.

And in this function we find something like : if the table node_type_content does not exist, then update the table node_type, else update the table node_content_type.

But the table node_type DOES exist, so it tries to update the table node_content_type, which does not exist...

Any idea somebody?
Thanks

Julien PHAM’s picture

btw it seems there is some issue between the core update and the cck one. With 4.7 version I did a core update. Then I tried to put the latest 4.7 cck version in, and did an update. And then I had an error like "table node_type already exists", or something like that.

As if the cck updater tried to do something the core system already did...

karens’s picture

Status: Active » Fixed

Bah! It's a mistake in the .install file - the content type name is wrong. I just committed a fix to HEAD and the 5.x branch.

Thanks for all your help debugging this!!

fractile81’s picture

I've done the upgrade process as outlined above (mostly), and I'm still having problems with my migrated content types. When I click on a content type that I've added, the link looks right, but I just get a identical listing of all content types.

I know I'm upgrading from schema 6 on Drupal 4.7 to 5.0. I've tried this on both CCK 1.2 and CCK HEAD, both with the same problem. Any ideas?

yched’s picture

fractile81 : that sounds strange.
Have you tried emptying your site's cache ? (using devel.module's empty cache feature, or manually emptying the datablase 'cache' table)

I assume you're on the 'admin/content/types' page, trying to click a link in the 'Name' Column ?
You say the link looks OK - what's the url ?

fractile81’s picture

Yes on all accounts: I've cleared the cache, and I'm at /admin/content/types. Here's the link I'm being sent to:

/admin/content/types/content-organic-tab

On this link, the page is the exact same as /admin/content/types EXCEPT that the help text at the top is not being displayed. Otherwise, all links appear to work (except for this content type I'm having a problem with).

Just to be sure, I'm going to try upgrading CCK in my 4.7 build to the most current schema before I upgrade to Drupal 5.0 and see if that makes a difference. Any other ideas would be appreciated.

fractile81’s picture

Interestingly enough, upgrading to CCK 4.7-1.2 before I upgrade to Drupal 5.0 + CCK 5.x-1.2 appears to have fixed the problem. Clicking the link now takes me to a proper form for the CCK content type.

hyperlogos’s picture

Nothing really worked automatically for me. I tried upgrading to 4.7-1.2 but there was no joy. I got the upgrade to work by disabling ALL modules (including core) and doing the upgrade. Then I had to MANUALLY remove the node_type table and recreate. I used the failure message in the guide as an example. I couldn't simply copy and paste it to mysql (command line client) though. I ended up using MySQL Administrator to create the table. Then I installed cck and ran the update as normal. Everything worked great. Hope this workaround helps someone. I do have pre and post db upgrade sql dumps if they will help someone, but I'm not posting a full dump here for obvious reasons. I can look things up in the dumps though.

Anonymous’s picture

Status: Fixed » Closed (fixed)
dgtlmoon’s picture

Priority: Normal » Critical
Status: Closed (fixed) » Active

Hey

I had a similar error that caused drupal to not generate all of my content tables in content_update_1003(), this function was calling $types = content_types() which referred to _content_type_info() to obtain a list of content types - except for some reason my 4.x contained a broken list of cached data (even tho the site was functioning 100% fine) , which caused the content_update_1003() to not be aware of all the content tables that needed updating.

It turned out it is absolutely critical for this cache to be cleared in two places (1) after you have turned off all your modules and are about to run update 1000 of system.module, and (2) after you have run all the updates for system.module but before you have turned on any of your contrib modules (such as CCK)

My recommendation is that content_update_1003() should be flushing this cache prior to content_types() call, and/or content_types() should accept a bool flag to tell content_types() to flush the cache.

otherwise you can just do this before and after each update submit

delete from cache_content;

hope this helps, have bumped the status of this bug because i think its critical that the update for content.module does not rely on cached info.

dgtlmoon’s picture

Actually, cache_content wont exist in 4.7 so this needs to be run at the 5.x stage

dgtlmoon’s picture

Status: Active » Closed (fixed)
burnbright’s picture

While I know it's been a very long time since this CCK issue has been closed, I am currently upgrading an old 4.7 site to 5 to eventually upgrade to the current Drupal version.

I have now tried this upgrade three times, and every time I get these errors mentioned above related to the CCK module:

user warning: Table 'databaseX.content_type_content_blah doesn't exist query: ALTER TABLE content_type_content_blah CHANGE field_blah_value field_blah_value longtext in /var/www/vhosts/website.com/httpdocs/includes/database.mysql.inc on line 174.

This is repeated for every content type.

I have both the node_type table and the node_type_content table after I run update.php on the 5.2x install. But after I install the CCK module and run update.php again, the node_type_content table is gone, though all of my content is indeed sitting in tables called node_content_contenttypename.

I have confirmed that the version of the CCK running on the 4.7 website is CCK4.7 1.6.1, which appears to the be the most up to date version.

I would appreciate any insight into this upgrade.

Thanks for your help in advance.

DG