CodeIgniter Forums
DB Forge: possibility to change / set a primary key on a field of an existing table? - 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: DB Forge: possibility to change / set a primary key on a field of an existing table? (/showthread.php?tid=79181)



DB Forge: possibility to change / set a primary key on a field of an existing table? - Zeff - 05-06-2021

Hi all,

I was reading the user guide on the CI4 Database Forge class.
I want to set a primary key on an field of an (existing) table. 

The addPrimaryKey() should be use on fields that must be created, but is there a possibility to do so on an existing one (by mesans of modifyColumn() for example...)? 

Thanks in advance!


RE: DB Forge: possibility to change / set a primary key on a field of an existing table? - InsiteFX - 05-06-2021

I'm pretty sure that you would need to use alter table field to make it a primary key.