Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:15:50+00:00 2026-05-26T23:15:50+00:00

I have the following schema (generated from an existing table with the schema module

  • 0

I have the following schema (generated from an existing table with the schema module (7.x-1.0-beta3) in a custom module.

function myproject_entities_schema() {

// ---------------------------------------------------------------------------------
// MESSAGE
// ---------------------------------------------------------------------------------
$schema['myproject_entity_message'] = array(
    'description' => 'The base table for myproject message instances',
    'fields' => array(
        'id' => array(
            'description' => 'The primary identifier for a message instance',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'weekendday' => array(
            'description' => 'Whether this message gets send on a weekendday(1) or on a workday(0)',
            'type' => 'int',
            'size' => 'tiny',
            'not null' => TRUE,
            'default' => 0,
        ),
        'day' => array(
            'description' => 'Numbered day of campaign schedule',
            'type' => 'int',
            'not null' => TRUE,
        ),
        'content' => array(
            'description' => 'Message content',
            'type' => 'text',
            'not null' => TRUE,
        ),
        'time_to_send' => array(
            'description' => 'When the message should arrive at the user',
            'type' => 'datetime',
            'not null' => TRUE,
        ),
        'campaign_fk' => array(
            'description' => 'the foreign key of the campaign this message belongs to',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => FALSE,
        ),
        'user_id' => array(
            'description' => 'The user id this message is generated for',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'pool_id' => array(
            'description' => 'The pool node id this message was generated from',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'message_template_id' => array(
            'description' => 'The node id of the message template this message was generated from',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
    ),
    'primary key' => array('id'),
    'indexes' => array(
        'CAMPAIGN' => array('campaign_fk'),
        'MESSAGE_TEMPLATE' => array('message_template_id'),
        'POOL' => array('pool_id'),
        'USER' => array('user_id'),
    ),
);

// ---------------------------------------------------------------------------------
// CAMPAIGN
// ---------------------------------------------------------------------------------
$schema['myproject_entity_campaign'] = array(
    'description' => 'The base table for myproject campaigns instances',
    'fields' => array(
        'id' => array(
            'description' => 'The primary identifier for a campaign instance',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'schedule' => array(
            'description' => 'The schedule of the campaign in text format.',
            'type' => 'text',
            'not null' => TRUE,
        ),
        'interruptible' => array(
            'description' => 'Whether this campaign is interruptible or not',
            'type' => 'int',
            'size' => 'tiny',
            'not null' => TRUE,
        ),
        'campaign_template_id' => array(
            'description' => 'Node id of campaign template this instance was created from',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'product_fk' => array(
            'description' => 'Primary key of product instance this campaign belongs to',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => FALSE,
        ),
    ),
    'primary key' => array('id'),
    'indexes' => array(
        'CAMPAIGN_TEMPLATE' => array('campaign_template_id'),
        'PRODUCT' => array('product_fk'),
    ),
);

// ---------------------------------------------------------------------------------
// PRODUCT
// ---------------------------------------------------------------------------------
$schema['myproject_entity_product'] = array(
    'description' => 'The base table for myproject product instances',
    'fields' => array(
        'id' => array(
            'description' => 'The primary identifier for a product instance',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'start' => array(
            'description' => 'Time when the campaign started',
            'type' => 'datetime',
            'not null' => TRUE,
        ),
        'current_campaign_fk' => array(
            'description' => 'Foreign key of currently running campaign instance',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => FALSE,
        ),
        'next_campaign_fk' => array(
            'description' => 'Foreign key of campaign instance to run next',
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => FALSE,
        ),
    ),
    'primary key' => array('id'),
    'indexes' => array(
        'CURRENT' => array('current_campaign_fk'),
        'NEXT' => array('next_campaign_fk'),
    ),
);

return $schema;
}

When i try to install the module and thus create the schema, I always get the following notice (which I dont think is the main reason for failing):

Notice: Undefined index: datetime:normal in DatabaseSchema_mysql->processField() (line 200 of /Users/xxx/Repos/myproject/includes/database/mysql/schema.inc).

And the following error:

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 right syntax to use near 'NOT NULL COMMENT 'When the message should arrive at the user', `campaign_fk` IN' at line 6: CREATE TABLE {myproject_entity_message} ( `id` INT unsigned NOT NULL auto_increment COMMENT 'The primary identifier for a message instance', `weekendday` TINYINT NOT NULL DEFAULT 0 COMMENT 'Whether this message gets send on a weekendday(1) or on a workday(0)', `day` INT NOT NULL COMMENT 'Numbered day of campaign schedule', `content` TEXT NOT NULL COMMENT 'Message content', `time_to_send` NOT NULL COMMENT 'When the message should arrive at the user', `campaign_fk` INT unsigned NULL DEFAULT NULL COMMENT 'the foreign key of the campaign this message belongs to', `user_id` INT unsigned NOT NULL COMMENT 'The user id this message is generated for', `pool_id` INT unsigned NOT NULL COMMENT 'The pool node id this message was generated from', `message_template_id` INT unsigned NOT NULL COMMENT 'The node id of the message template this message was generated from', PRIMARY KEY (`id`), INDEX `CAMPAIGN` (`campaign_fk`), INDEX `MESSAGE_TEMPLATE` (`message_template_id`), INDEX `POOL` (`pool_id`), INDEX `USER` (`user_id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT 'The base table for myproject message instances'; Array ( ) in db_create_table() (line 2684 of /Users/xxx/Repos/myproject/includes/database/database.inc).

I searched for errors in the schema definition but could not find any. Also I don’t see what exactly is wrong with the sql statement.

My server setup is:
Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 with Suhosin-Patch
MySQL client version: mysqlnd 5.0.8-dev – 20102224 – $Revision: 308673 $

Does anyone see whats wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:15:51+00:00Added an answer on May 26, 2026 at 11:15 pm

    I think you need to use datetime:normal as the key for your datetime column type.

    'time_to_send' => array(
      'description' => 'When the message should arrive at the user',
      'type' => 'datetime:normal',
      'not null' => TRUE,
    ),
    

    Other than that you can try specifying the column type as a MySQL DATETIME explicitly:

    'time_to_send' => array(
      'description' => 'When the message should arrive at the user',
      'mysql_type' => 'DATETIME',
      'not null' => TRUE,
    ),
    

    The problem seems to stem from whether or not DATETIME is actually allowed in Drupal 7; see this discussion for a lot more details than I can fit in here 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have generated a class from XSD. The following [System.Xml.Serialization.XmlElementAttribute(mailer, Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public itemOrderMailer[] mailer
In a table I have the following schema table1: playerID int primary key, nationalities
I have the following table schema; CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have no control over database schema and have the following (simplified) table structure:
I have this array which gets the last table from a database. However the
I have the following schema, which I use to ensure that a person's PhoneNumber
I have a database where I store objects. I have the following (simplified) schema
Say you have the following in a schema: <xsd:complexType name=shape/> <xsd:complexType name=circle> <xsd:complexContent> <xsd:extension
Trying to map the following schema using the Entity Framework. A Customer can have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.