Skip to content

Instantly share code, notes, and snippets.

@sumanthkumarc
Created September 20, 2017 15:16
Show Gist options
  • Select an option

  • Save sumanthkumarc/d5c575378a16c5105fa7c82fe6fd4229 to your computer and use it in GitHub Desktop.

Select an option

Save sumanthkumarc/d5c575378a16c5105fa7c82fe6fd4229 to your computer and use it in GitHub Desktop.
Drupal 8: get and set schema version numbers in database.
<?php
// All these are found in core/includes/schema.inc
// Get schema version for your module.
drupal_get_installed_schema_version('MY_MODULE');
// schema version number is N in hook_update_N
drupal_set_installed_schema_version('MY_MODULE', 'Schema_version_number');
// Get all schema versions for all modules.
$versions = \Drupal::keyValue('system.schema')->getAll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment