Field values added programmatically dispear after a certain time I created a module that creates a block to show a schedule information. I need taxonomy terms to configure the block. I want that those terms are filled with preconfigured values when I install the module.

I have in my config/install folder the definition of my taxonomy:

core.entity_form_display.taxonomy_term.schedule_channels.default.yml
core.entity_view_display.taxonomy_term.schedule_channels.default.yml
field.field.taxonomy_term.schedule_channels.field_channel_id.yml
field.storage.taxonomy_term.field_channel_id.yml
taxonomy.vocabulary.schedule_channels.yml


Here the content of the file field.storage.taxonomy_term.field_channel_id.yml:

langcode: en
status: true
dependencies:
  module:
    - taxonomy
id: taxonomy_term.field_channel_id
field_name: field_channel_id
entity_type: taxonomy_term
type: string
settings:
  max_length: 50
  is_ascii: false
  case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false


Also in my schedule_block.install I have:



class schedule_block_class{

  const schedule_block_channels_terms = array(
    array(
      'name' =&gt; 'Brava',
      'field_channel_id' =&gt; 'BRA001'
    ),
    array(
      'name' =&gt; 'DJazz',
      'field_channel_id' =&gt; 'DJA001'
    ));
  const schedule_block_channels_vid = 'schedule_channels';
}

function schedule_block_install(){
  $schedule_block_terms = schedule_block_class::schedule_block_channels_terms;
  $schedule_block_vid = schedule_block_class::schedule_block_channels_vid;
  foreach($schedule_block_terms as $schedule_block_term){
    $term = Term::create(array(
      'name' =&gt; $schedule_block_term['name'],
      'field_channel_id' =&gt; $schedule_block_term['field_channel_id'],
      'description' =&gt; '',
      'parent' =&gt; array(0),
      'vid' =&gt; $schedule_block_vid
    ));
    $term-&gt;save();
  }
}

function schedule_block_uninstall(){

  $schedule_block_terms = schedule_block_class::schedule_block_channels_terms;
  $schedule_block_vid = schedule_block_class::schedule_block_channels_vid;
  $terms = array();
  foreach($schedule_block_terms as $schedule_block_term){
    if($terms_name = taxonomy_term_load_multiple_by_name($schedule_block_term['name'], $schedule_block_vid)){
      $terms = array_merge($terms, $terms_name);
    }
  }
  foreach($terms as $term){
    $term-&gt;delete();
  }
  $taxo = \Drupal\taxonomy\Entity\Vocabulary::load(schedule_block_class::schedule_block_channels_vid);
  if(!is_null($taxo)){
    $taxo-&gt;delete();
  }
}


When I install my module, my taxonomy vocabulary is created and my terms are loaded with my values

... BUT ... 

After about 24h the values have disappeared. Checking in the table taxonomy_term__field_channel_id confirms that there is no more any values. I still have my taxo vocab, and all the needed tables are present.

Why the values are not permanent?
(Re comments)

That's the reason then. Those fields being in state, which means drupal thinks they were deleted and is trying to delete conent in them.

Remove them from there. Probably OK to drop the whole rows, check all the other fields in there. You might have some deleted field tables that you need to clean up manually.

I've seen someone else have this problem, what we couldn't figure out is how it happened. Please open a core issue (probably critical) and try to describe what you did.. delete fields, config import, create through manual config import. Anything you can think of that might have caused this.