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 8487441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:14:27+00:00 2026-06-10T21:14:27+00:00

I have this entity: $schema[‘apiuser’] = array( ‘description’ => ‘The base table for api_user.’,

  • 0

I have this entity:

    $schema['apiuser'] = array(
        'description' => 'The base table for api_user.',
        'fields' => array(
            'apiuser_id' => array(
                'description' => 'The primary identifier for an artwork.',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ),
            'public_key' => array(
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
                'description' => "Foreign key: {file_managed}.fid of user's picture.",
            )           
        ),
        'unique keys' => array(
            'id' => array('apiuser_id')
        ),
        'primary key' => array('apiuser_id'),
        );

Later I have added a new field:

,
            $schema['apiuser'] = array(
    'description' => 'The base table for api_user.',
    'fields' => array(
        'apiuser_id' => array(
            'description' => 'The primary identifier for an artwork.',
            'type' => 'serial',
            'unsigned' => TRUE,
            'not null' => TRUE,
        ),
        'public_key' => array(
            'type' => 'int',
            'not null' => TRUE,
            'default' => 0,
            'description' => "Foreign key: {file_managed}.fid of user's picture.",
        ),
        'user_id' => array(
            'description' => 'The primary identifier for an artwork.',
            'type' => 'int',
            'not null' => TRUE,
        )

    ),
    'unique keys' => array(
        'id' => array('apiuser_id')
    ),
    'primary key' => array('apiuser_id'),
    );

Drupal doesn’t change the respective table into mysql so I modified it manually. But now when I try to save the entity that new field is not filled. I have installed devel module and used ‘drush cc all’ to clear the cache, deactivated and activated the modeule but still doesn’t work

  • 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-06-10T21:14:29+00:00Added an answer on June 10, 2026 at 9:14 pm

    This is what the update script is for. You’ll want to write an update_N function, in which you can use the schema object to add your column:

    function your_module_update_7001($sandbox) {
      // do some checking (i.e. if already exists, etc)
      // get $schema from wherever you defined it for hook_schema...
      $spec = $schema['fields']['user_id'];
      Database::getConnection()->schema()->addField('apiuser', 'user_id', $spec);
    }
    

    Then run http://yoursite.com/update.php and drupal will modify your table accordingly.

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

Sidebar

Related Questions

I have defined this entity in schema.yml Jobsearch: tableName: jobsearch columns: seeker_id: primary: true
I have this piece of code: @Entity @Table(name = MOVERS) public class MOVers implements
I have xsd file. I want to generate my entity model from this schema
I have 2 entities: News and NewsComment @Entity @Table(name = news, schema = city)
I have a class annotated like this: @Entity @Table(name=MYENTITY) @SequenceGenerator(name=CODE_GEN, sequenceName=SEQ_NAME) public class MyEntity
This is what I have: An entity-relational schema, modelled for Doctrine 2.0 (in PHP);
Let's say I have this entity (for Hibernate): @Entity public class Person { @Id
If I have this entity: @Entity class Pet { @Id long id; public enum
I have this type of data: entity, account, month1, month2, ..., month12 abc, 2000.02,
I have this DependencyProperty which holds an entity with a property that is a

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.