I've recently had a lot of trouble, self-inflicted I will admit, with my Drupal 7 website and as a result have had to restore my database from a backup several times. In doing so, the structure of most of the tables does not seem to have restored quite correctly for some reason and I'm getting a lot of errors to say that there are no default values for fields (that are always primary keys). The solution to this has been to make the field auto increment, but is there a way to do this without looking at the structure of each table one by one.

Is there some kind of script that looks at the structure of the tables and repairs them automatically as my website is considerably large and has many tables so going through them by hand would be a lengthy process.

Thanks in advance

  • SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: name` -- -- -------------------------------------------------------- -- -- Table structure for table actions -- CREATE TABLE IF NOT EXISTS actions ( aid varchar(255) NOT NULL DEFAULT '0' COMMENT 'Primary Key: Unique actions ID.', type varchar(32) NOT NULL DEFAULT '' C` – Andy Dec 27 '14 at 15:37
  • I used phpMyAdmin to create the backup file in a .SQL format – Andy Dec 27 '14 at 15:38
  • +1 AyeshK. A restore should maintain all of the structure of your database. Do you have any backups that were kept by your host and not exported through phpMyAdmin? – webkenny Dec 27 '14 at 19:13
  • @webkenny Yes I think I may have one backup that was made by my host, although content has been added to the database since then I believe. Is there any way to just restore the structure or combine the two etc.? – Andy Dec 27 '14 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.