CodeIgniter Forums
addColumn IF NOT EXITS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: addColumn IF NOT EXITS (/showthread.php?tid=78337)



addColumn IF NOT EXITS - Gehasi - 01-05-2021

Hi,

I'm new in codeigniter. And yes I read the manual about forge and addColumn. Smile


My Question is:
When you add a table with forge you can check if table exists when you add a TRUE in your Line like written in the manual.

Is there also an option to check if a column I want to add exists?

PHP Code:
    public function updateDatabase() {
      $forge = \Config\Database::forge();

        $addresses = ['sort' => ['type' => 'INT''constraint' => '100''null' => true'after' => 'person_idperson', ],];
        $forge->addColumn('addresses'$addresses);



When I update my page twice I got a Error Message "duplicated column name"

Any Idea how to solve that?

Thanks


RE: addColumn IF NOT EXITS - iRedds - 01-05-2021

Use migrations to change the database table.


RE: addColumn IF NOT EXITS - Gehasi - 01-06-2021

ok thx I will try....