The Schema API allows modules to declare their database tables in a structured array (similar to the Form API). If your question is about the database API, and not the schema API, use "db-api."

learn more… | top users | synonyms

0
votes
0answers
11 views

Changing tables layout when data is already there

According to this article: The default storage supports four different shared table layouts depending on whether the entity type is translatable and/or revisionable: (...) The SQL ...
1
vote
1answer
34 views

How can I remove a property from an entity in Drupal 7

I have a custom entity that was create a long time ago. Now we want to update the schema to remove a property (not a field) that was defined in the original schema. I've reviewed the Drupal API for ...
5
votes
2answers
60 views

Why is hook_schema() called twice?

I'm working with entities and, in trying to troubleshoot another issue, I noticed that hook_schema() is called twice each time the module is installed. This happened even with a bare bones test module ...
0
votes
1answer
16 views

Adding a new NOT NULL field to a table causes an error

When attempting to add a new column to a table within an update hook, the error Null value not allowed: 1138 Invalid use of NULL value occurred, the definition was changed to allow NULL, and the value ...
2
votes
1answer
75 views

How do I change the type of a field attached to a content entity?

So I've been banging my head against this for a few hours, and I'm probably going to give up and just uninstall/reinstall the module (and update the View that relies on the old entity_reference field ...
0
votes
0answers
20 views

Create Multiple Custom Modules - Not Working

I have written this schema for creating 2 tables in my custom module.install <?php function my_registration_form_schema() { $schema = array(); $schema['myuser'] = array ( ...
1
vote
1answer
38 views

How to fix the PDOException shown after upgrading to Drupal 7

I upgraded Drupal 6 to Drupal 7. The following updates returned messages: node module Update #7006 taxonomy module Update #7005 search module Update #7000 I updated the ...
0
votes
1answer
66 views

How can I use different database backend for certain tables?

What do I need to do in order to serve config entities from Mongo and cache from Redis database backends? So basically: a) how do I tell Drupal that I want to use different db backend for certain ...
0
votes
2answers
25 views

how to uninstall custom database table in drupal 6

I want to create custom table for my custom module "custom_module_table" /** * Implements hook_install(). */ function custom_module_install() { drupal_install_schema('custom_module'); } ...
1
vote
2answers
139 views

How to create table column type as TEXT in drupal custom module?

I try to create table column type as TEXT, i just can't find in Google, here's the code: function _mymodule_installed_fields() { return array( 'mymodule_summary' ...
0
votes
1answer
34 views

Tables are not creating with hook_schema

I need to create a module to save data of term page visits. <?php function term_count_schema() { $schema['term_search'] = array( 'description' => 'Stores timestamp range..', 'fields' => ...
0
votes
1answer
21 views

How to upgrade module table scheme for entity

I've written a module that uses entities functionality. It has the following table scheme in .install file: $schema['transaction'] = array( //fields 'fields' => array( 'id' => ...
0
votes
0answers
34 views

My fields don't appear in views after doing mymodule_views_data()

I've created a table in mymodule .install file. function secciones_schema() { $schema['seccion_empresa_contenido'] = array( 'description' => 'Contenido de la seccion de tipo "Categoría de ...
0
votes
0answers
61 views

Update failed - table doesn't exist

I'm running a D7 core update and all but one database updates pass. The one that doesn't pass gives me the following error message: Failed: DatabaseSchemaObjectDoesNotExistException: Cannot add field ...
1
vote
0answers
62 views

EntityMetadataWrapperException when updating Open Atrium

I've taken over management of a site using Open Atrium on the Pantheon hosting platform. The upstream repository was originally set incorrectly to Drupal 7 instead of Open Atrium. What this means is ...
0
votes
3answers
101 views

Add foreign key to schema using hook_update_N

I've written a module that establishes a child/parent relation ship between magazine issues and the articles in each issue. The idea is that by associating articles with magazine issues they can all ...
1
vote
1answer
77 views

Adding a new column to users table: db_drop_field errror

I'm trying to add a column to the 'users' table. When I install my module, the column gets created and when I uninstall it gets deleted. The issue is that after I uninstalled, I run a 'drush cc all' ...
0
votes
1answer
60 views

Can't create table when installing module

I have a simple 'form_example' module and I want to add a database table when instaling module. I created this form_example.install file: <?php function form_example_schema() { ...
0
votes
1answer
69 views

how to update my custom table after execution of rules

i have created a table as follow <?php /** * @file * Implements hook_schema */ function core_sms_schema() { $schema['core_sms_details'] = array( 'description' => 'This table is used ...
0
votes
1answer
24 views

How to drop tables shown as Missing in Schema Report

During development/testing after using Backup and Migrate Restore in conjuction with Schema, Schema will show Extra tables no longer referenced in the database, used by modulesetc, and no longer ...
1
vote
2answers
100 views

How to remove a unique key in an update hook

I have a primary key and a unique key in my modules' schema. I need to remove the unique key. To remove an an index it is simple: function draggableviews_update_7205() { if ...
0
votes
0answers
42 views

Need help debugging a DatabaseSchemaObjectExistsException error

I'm getting this error both when I try to flush the cache and when i try to run update.php. I honestly have no idea where to start so any help is greatly appreciated. ...
0
votes
1answer
158 views

Adding new fields using hook_field_schema_alter()

I have an entity whose field schema is already defined and now I am trying to add couple of fields to it. But I am not sure how to code it up using schema_alter.Below is an example on how I would ...
0
votes
1answer
500 views

Is there a way to add a foreign key to a table?

My question is not regarding hook_schema but regarding hook_update_N: I need to add a foreign key to an existent table in drupal 7. I was looking Here but it does not seem to exist one explicitly for ...
0
votes
1answer
32 views

Schema relationship

The problems I am trying to solve are: 1- How can I connect tables defined by $schema to each other? 2- How do you insert data consistently into the database? Is there any possibility of having ...
0
votes
3answers
259 views

What entity should entity_id be joined on?

I'm writing a complex custom query to get order information from a Drupal Commerce install for export. The table field_data_commerce_customer_address has a column entity_id. I've tried to join that ...
0
votes
2answers
458 views

Drupal Schema Syntax Error

I'm building a module for Drupal 7 but having trouble with my schema and can't see what the issue is. This is my schema $schema['table_name'] = array( 'fields' => array( 'id' ...
1
vote
3answers
335 views

Cannot figure out what's wrong with my schema

It keep saying PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the ...
0
votes
1answer
193 views

Recieving PDOExceptions and missing fields and table on Module installation

I'm new to Drupal and it's pretty much my first experience of adding Modules. I've mostly being using the Migrate module so far in. On loading I'm getting PDO errors which are created by either ...
3
votes
1answer
1k views

Correct way to add custom column to user table?

I'm looking to add a column called 'updated' directly to the users table. The Field API and Joins are not an option for me in this case due to external constraints. How can I safely modify the ...
0
votes
1answer
285 views

db_add_field not working

I want to add a new field to node table using db_add_field when intalling a new module, but it seems there is something wrong or missing: here is the code used: /** * Implements hook_schema_alter() ...
1
vote
1answer
216 views

hook_schema duplicate unique keys

I am reading book 'Drupal 7 module development'. I am try to follow book to create a hook_schema (I delete some line for better read): function artwork_schema() { $schema['artwork'] = array( ...
0
votes
2answers
100 views

hook_install() doesn't seem to work, even though I have disabled and uninstalled module

I'm writing a module that will enable an editor to determine whether a script is available on a specific node, in order to improve page load times. I need to create a database table to hold an ...
0
votes
1answer
619 views

Table is not creating while installing the custom module in drupal 7 [Access Violation Error ] [closed]

I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed. While installing the module, ...
2
votes
1answer
237 views

How do I find the max length of a field (e.g. title field)

I would like to retrieve the maximum length of a field programmatically, for instance the $node->title field . I am writing a module that sets title and I don't really want to hard-code '255'. I ...
2
votes
1answer
124 views

How to implement an enumerated field using hook_schema()?

I need to have a field in my database that is shall hold a limited set of enumerated values. The MySQL ENUM type is not one of the predefined Drupal data types. So how do one implement a field to ...
0
votes
2answers
404 views

Trying to create a table with an uid field that auto-increments and is the primary key, but keep getting an error

I'm working on an .install file for my module in Drupal 7. I want to create two tables, one called tls_connect_floormap_images and one called tls_connect_floormap_coords. I'm not having any trouble ...
0
votes
2answers
792 views

Table not creating while installing a custom module in Drupal 7

I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed. While installing the module, ...
1
vote
1answer
154 views

Problem with table schema

I'm working on an API that pulls data from a Drupal site. Everything has gone pretty well I normally use Drupal Bootstrap to load Drupal use the functions I need then spit out a JSON array. I am ...
0
votes
1answer
318 views

Panels & Views harm Google rich snippets (updated)

I Updated my question after further investigation of the problem (2/21/2014) I am building a site using Drupal 7 and the schema.org module and the microdata module. The site is live on production ...
0
votes
1answer
131 views

Can't add column to renamed table

When I first developed this module internally (not on Druple.com) the module_schema function created a table with the same name of the module (it was the only table, so it made sense. Short sighted.). ...
0
votes
1answer
88 views

Drop Tables After Backup Migrate Restore

I find myself using Backup and Migrate's Restore (from manual backups folder) when testing module sets or after a change to a project is problematic. I use Schema after the restore to check for extra ...
0
votes
2answers
1k views

mymodule.install file not creating the table in drupal 7

I have a very simple table in my .install file and for some reason is not creating the table. What can it be? something i have to add in the .info file? please help. Its a drupal 7. this is what i ...
0
votes
1answer
818 views

Auto increment using serial variable

In this code i want to incerment the value by 4 and not by one . How Can i do it ? select_id' => array( 'description' => 'TODO: please describe this field!', 'type' ...
0
votes
1answer
325 views

Help with PDOException and hook_schema()

I'm trying to set up an install file for a custom module that I'm creating but having a little trouble when Drupal tries to create my tables. It's probably a simple syntax error but can't track it ...
2
votes
2answers
2k views

Microdata or Schema.org (or both)?

I am building a community site in Drupal 7. I am using the SEO checklist, which suggest to use the microdata module. Other places I read are suggesting to use Schema.org module. what is difference ...
1
vote
2answers
479 views

How to create db table while installing a module?

I want to create a table in Drupal while installing a module (custom module which is crated by me). I tried in the below way, but I could not able to create a table in Drupal db. what am I missing, ...
4
votes
2answers
2k views

Which type to use for checkbox fields in hook_field_schema?

Task: Create a custom field which contains a single checkbox by implementing hook_field_schema etc. Question: Which data type is (or should) be used to define the corresponding database column to ...
1
vote
1answer
351 views

Need help clearing the schema cache [closed]

I am checking of a particular field type in the schema using: drupal_get_schema('MY_FIELD'); I see in the database the field type is int, but when I check after: ...
3
votes
2answers
245 views

How do I prevent the automatic removal of a database table when a module is uninstalled?

In Drupal 7, a database table created through hook_schema() gets created on module installation, and gets deleted on uninstallation. I would like to prevent the removal of a database table when the ...