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

  • Home
  • SEARCH
  • 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 7417407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:41:48+00:00 2026-05-29T07:41:48+00:00

I am trying to create a migration file in Codeigniter but when I run

  • 0

I am trying to create a migration file in Codeigniter but when I run it it’s throwing an error and no matter what I do I cannot get it to run.

class Migration_Add_users extends CI_Migration {     

public function up()
{
        $this->dbforge->add_field(array(
            'USERS_id' => array(
                'type' => 'INT',
                'constraint' => 5,
                'auto_increment' => TRUE,
            ),
            'USERS_firstname' => array(
                'type' => 'VARCHAR',
                'constraint' => '100',
            ),
            'USERS_surname' => array(
                'type' => 'VARCHAR',
                'constraint' => '100',
            ),
            'USERS_email' => array(
                'type' => 'VARCHAR',
                'constraint' => '150',
                ),
            'USERS_password' => array(
                'type' => 'VARCHAR',
                'constraint' => '150',
                ),
            'USERS_password' => array(
                'type' => 'VARCHAR',
                'constraint' => '150',
                ),
            'USERS_created' => array(
                'type' => 'DATETIME',
                ),
        ));

        $this->dbforge->create_table('users');
        $this->dbforge->add_key('USERS_id', TRUE);
    }

    public function down()
    {
        $this->dbforge->drop_table('users');
    }
}

this is the error

Error Number: 1075
Incorrect table definition; there can be only one auto column and it must be defined as a key

table

CREATE TABLE `users` ( 
`USERS_id` INT(5) NOT NULL AUTO_INCREMENT, 
`USERS_firstname` VARCHAR(100) NOT NULL, 
`USERS_surname` VARCHAR(100) NOT NULL, 
`USERS_email` VARCHAR(150) NOT NULL, 
`USERS_password` VARCHAR(150) NOT NULL, 
`USERS_created` DATETIME NOT NULL ) DEFAULT 
CHARACTER SET utf8 COLLATE utf8_general_ci;
  • 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-29T07:41:49+00:00Added an answer on May 29, 2026 at 7:41 am

    I needed to run the

    dbforge->add_key 
    

    before the

    dbforge->create_table
    

    There must be a way to add this to the

    dbforge->add_field 
    

    array

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

Sidebar

Related Questions

I get this when trying to run the migration: Mysql2::Error: Duplicate entry 'repeat' for
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
I am trying to run an active record migration but am receiving the following
Trying to create a user account in a test. But getting a Object reference
I am trying to get my rails application running on my web server, but
I'm a beginner at Ruby On Rails and am trying to get a migration
I am simply trying to create a plugin migration generator without any parameters, like
I'm trying to use the suffix column of my class but I keep getting
I'm trying to create a migration for a simple table that is just used
I'm trying to add an index to my models, but keep getting this error.

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.