How to reproduce
* Update from 1.x to 2.x - everything fine
* Create a new rule

Result:
General error: 1364 Field 'rule_themes' doesn't have a default value: INSERT INTO {css_injector_rule} (name, admin_description, css, media, preprocess, inline, page_visibility, page_visibility_pages) VALUES

Analysis:
Obviously some fields are leftover that are not part of the new schema. These are:
* enabled
* rule_type
* rule_themes
* rule_conditions

The simplest solution would be to add a new update function like so

/**
 * Drop legacy fields
 */
function css_injector_update_7206(&$sandbox) {
  db_drop_field('css_injector_rule','enabled');
  db_drop_field('css_injector_rule','rule_type');
  db_drop_field('css_injector_rule','rule_themes');
  db_drop_field('css_injector_rule','rule_conditions');
}

but i'm a bit puzzled by this:

/**
 * remove NOT NULL requirement on rule_conditions field
 */
function css_injector_update_7205(&$sandbox) {
  if (db_field_exists('css_injector_rule', 'rule_conditions')) {
    db_change_field('css_injector_rule', 'rule_conditions', 'rule_conditions', array(
      'description' => 'LEGACY data to evaluate when determining if the CSS should be injected',
      'type' => 'text',
      'not null' => FALSE,
    ));
  }
}

do we want to keep this legacy data that we can't edit anymore??

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geek-merlin’s picture

Status: Active » Needs review
FileSize
9.65 KB

Yes those fields must die and so can a zombie file.

Patch flying in.

geek-merlin’s picture

Worksforme.

AlfTheCat’s picture

Patch #1 applied cleanly and the error went away, am now able to save new css rules perfectly :)

Thanks so much!

jhereck’s picture

Same problem here, and the patch above does not solve it.

Help pls !

Edit : found the problem : i had to fully uninstall the old module before reinstalling the 2.dev version, and problem gone !

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community

RTBC as of #3