--- /dev/null
+<?php
+
+/**
+ * @file
+ * Update hooks and schema definition for the update_test_schema module.
+ */
+
+/**
+ * Implements hook_schema().
+ *
+ * The schema defined here will vary on state to allow for update hook testing.
+ */
+function update_test_schema_schema() {
+ $schema_version = \Drupal::state()->get('update_test_schema_version', 8000);
+ $table = [
+ 'fields' => [
+ 'a' => ['type' => 'int', 'not null' => TRUE],
+ 'b' => ['type' => 'blob', 'not null' => FALSE],
+ ],
+ ];
+ switch ($schema_version) {
+ case 8001:
+ // Add the index.
+ $table['indexes']['test'] = ['a'];
+ break;
+ }
+ return ['update_test_schema_table' => $table];
+}
+
+// Update hooks are defined depending on state as well.
+$schema_version = \Drupal::state()->get('update_test_schema_version', 8000);
+
+if ($schema_version >= 8001) {
+ /**
+ * Schema version 8001.
+ */
+ function update_test_schema_update_8001() {
+ $table = [
+ 'fields' => [
+ 'a' => ['type' => 'int', 'not null' => TRUE],
+ 'b' => ['type' => 'blob', 'not null' => FALSE],
+ ],
+ ];
+
+ // Add a column.
+ db_add_index('update_test_schema_table', 'test', ['a'], $table);
+ }
+}