# Dynamically add columns in an existing table on the fly in cakephp 3

**URL:** https://discourse.cakephp.org/t/dynamically-add-columns-in-an-existing-table-on-the-fly-in-cakephp-3/503
**Category:** Need Help
**Created:** [June 9, 2016, 11:24am UTC](https://discourse.cakephp.org/t/dynamically-add-columns-in-an-existing-table-on-the-fly-in-cakephp-3/503 "2016-06-09T11:24:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jigar](https://avatars.discourse-cdn.com/v4/letter/j/4491bb/32.png) [@Jigar](https://discourse.cakephp.org/u/Jigar)
#### Post date: [June 9, 2016, 11:24am UTC](https://discourse.cakephp.org/t/dynamically-add-columns-in-an-existing-table-on-the-fly-in-cakephp-3/503/1 "2016-06-09T11:24:07Z")

</div>

I want to add column in my existing table in cakephp 3.

My ContactsTable.php file code is…

```
<?php

namespace App\Model\Table;

use Cake\ORM\Table;
use Migrations\AbstractMigration;

class ContactsTable extends Table
{
    public function initialize(array $config)
    {
        $this->addBehavior('Timestamp');            

        $table = $this->table('contacts');
        $table->addColumn('price', 'decimal')->update();

    }
}

```

I have tried as cakephp 3 documentation but I got error…

`Call to a member function addColumn() on a non-object`

How do I add columns on-the-fly via the controller?

**This question has an answer.** at [http://stackoverflow.com/questions/37362123/dynamically-add-columns-in-an-existing-table-on-the-fly-in-cakephp-3](http://stackoverflow.com/questions/37362123/dynamically-add-columns-in-an-existing-table-on-the-fly-in-cakephp-3) but the cache is not getting refreshed on debug false.
