0
  1. If I install all updates from site_name/update.php, and after change the system.schema_version from 7005 to 7003 using (to reinstall updates 7004 and 7005)

    UPDATE system SET schema_version = 7003 WHERE name = 'test';

  2. I then try to run site_name/update.php but it not run because the fields that hook_update_N() adds already exists. And I see when access update.php after error that 2 updates exists.

  3. After I restore system.schema_version to its initially value (7005)

Are the updates 7004 and 7005 now installed or not?

2 Answers 2

2

Are the updates 7004 and 7005 now installed or not?

Were they both installed prior to your intentionally trying to break it?

If so, then yes.

If not, then no.

4
  • It was installed, and after i change the system.schema_version from 7005 to 7003 to reinstall it, but I forgot that the fields will remain and I can't reinstall until I not drop that fields from DB.
    – Michael
    Sep 5, 2016 at 8:17
  • I can install from few only one update by it number from drush for example?
    – Michael
    Sep 5, 2016 at 8:18
  • 2
    Nope, if you're trying to install/update modules like that you've done something wrong on the way. An update is only to take an old version of a module up to its current state. There's no reinstalling of updates as you put it. If you make a mistake in one update, you'll need another update to rectify that mistake (unless the operation you performed first time round happened to be one that can just be run again with no other interference; obviously creating a field doesn't apply)
    – Clive
    Sep 5, 2016 at 8:21
  • 1
    For fields though, you can wrap the creation code in if (!field_info_field('field_foo')) { and same for the instance. You should only, ideally, be messing with this stuff if you're confident of what you're doing...mistakes in update hooks can end up being difficult to recover from
    – Clive
    Sep 5, 2016 at 8:24
2

What are you trying to do, and why are you trying to do this? To be honest, it makes no sense. First off, schema numbers should start at 7000 (in Drupal 7), and you should never be resetting them, particularly within hook_update_N(), as you're just going to cause the same code to be run every time the update process is run.

3
  • it start with 7000 and end with 7212, I simplify example. Ok I change
    – Michael
    Sep 5, 2016 at 8:11
  • 1
    Ok, your initial post was a little confusing. But I understand what you are saying no1. After step 1: At this point, the updates in 7004 and 7005 are installed. However, Drupal thinks they are not, since you have set the version to earlier than these two updates. After step 2: The updates are still installed. However, Drupal will not be able to perform updates because there will be errors due to the fields already existing. After step 3: The updates in 7004 and 7005 are installed.
    – Jaypan
    Sep 5, 2016 at 8:29
  • 1
    If you want to re-run updates, you shouldn't actually re-run them. What you should do add more updates to reverse what you have previously done. Example: hook_update_7006() { // Remove the fields you created in 7004 and 7005 } hook_update_7007() { // Add your fields again // Do whatever it is you forgot. }
    – Jaypan
    Sep 5, 2016 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.