# Cakephp3 - migration : Add new table with primary key problem

**URL:** https://discourse.cakephp.org/t/cakephp3-migration-add-new-table-with-primary-key-problem/2418
**Category:** Need Help
**Created:** [April 17, 2017, 9:11am UTC](https://discourse.cakephp.org/t/cakephp3-migration-add-new-table-with-primary-key-problem/2418 "2017-04-17T09:11:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kripx](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kripx/32/570_2.png) [@kripx](https://discourse.cakephp.org/u/kripx)
#### Post date: [April 17, 2017, 9:11am UTC](https://discourse.cakephp.org/t/cakephp3-migration-add-new-table-with-primary-key-problem/2418/1 "2017-04-17T09:11:51Z")

</div>

Hi there, I tried to add new table named ‘allvisitor’ with auto increment ID as primary key…but FAILED

```auto
public function change()
    {
        $this->table('allvisitor)
                ->addColumn('id', 'integer',
                    [
                        'autoIncrement' => true,
                        'limit' => 10,
                    ])
            ->addPrimaryKey(['id'])

```

When I ran migrate command

```auto
$ bin/cake migrations migrate -t 20170417083919

Welcome to CakePHP v3.3.16 Console
---------------------------------------------------------------
App : src
Path: /var/www/html/AYAM/ayam_v4_site/src/
PHP : 7.1.4
---------------------------------------------------------------
using migration path /var/www/html/AYAM/ayam_v4_site/config/Migrations
using seed path /var/www/html/AYAM/ayam_v4_site/config/Seeds
using environment default
using adapter mysql
using database ayamDB_v4

 == 20170417083919 AyamVersion402rev1: migrating
Exception: SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'id' in [/var/www/html/AYAM/ayam_v4_site/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php, line 338]

```

---

<div class="post-metadata">

### Author: ![aavrug](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/aavrug/32/178_2.png) [@aavrug](https://discourse.cakephp.org/u/aavrug)
#### Post date: [April 17, 2017, 9:15am UTC](https://discourse.cakephp.org/t/cakephp3-migration-add-new-table-with-primary-key-problem/2418/2 "2017-04-17T09:15:45Z")

</div>

The error message says that you already have the `id` column in your table.

---

<div class="post-metadata">

### Author: ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)
#### Post date: [April 17, 2017, 7:22pm UTC](https://discourse.cakephp.org/t/cakephp3-migration-add-new-table-with-primary-key-problem/2418/3 "2017-04-17T19:22:23Z")

</div>

[http://docs.phinx.org/en/latest/migrations.html#creating-a-table](http://docs.phinx.org/en/latest/migrations.html#creating-a-table)

> Phinx automatically creates an auto-incrementing primary key column called id for every table
