Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_schema.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_schema.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_schema.twig
new file mode 100644 (file)
index 0000000..4ac78da
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Implements hook_field_schema().
+ */
+function {{ machine_name }}_field_schema($field) {
+  if ($field['type'] == 'text_long') {
+    $columns = array(
+      'value' => array(
+        'type' => 'text',
+        'size' => 'big',
+        'not null' => FALSE,
+      ),
+    );
+  }
+  else {
+    $columns = array(
+      'value' => array(
+        'type' => 'varchar',
+        'length' => $field['settings']['max_length'],
+        'not null' => FALSE,
+      ),
+    );
+  }
+  $columns += array(
+    'format' => array(
+      'type' => 'varchar',
+      'length' => 255,
+      'not null' => FALSE,
+    ),
+  );
+  return array(
+    'columns' => $columns,
+    'indexes' => array(
+      'format' => array('format'),
+    ),
+    'foreign keys' => array(
+      'format' => array(
+        'table' => 'filter_format',
+        'columns' => array('format' => 'format'),
+      ),
+    ),
+  );
+}