CodeIgniter Forums
Adding foreign key to exisiting table - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Adding foreign key to exisiting table (/showthread.php?tid=83008)



Adding foreign key to exisiting table - sadiqsalau - 09-09-2022

I would like to be able to add foreign key to an already existing table. We are working on an application and the database is likely to change over time. The only issue is altering an exisiting table. We would have used another framework but have decided to stick with codeigniter4 due to its performance.


RE: Adding foreign key to exisiting table - superior - 09-12-2022

Like this?
https://codeigniter4.github.io/userguide/dbmgmt/forge.html#adding-foreign-keys


RE: Adding foreign key to exisiting table - kenjis - 09-12-2022

You can use $db->query().
See https://codeigniter4.github.io/userguide/database/queries.html#regular-queries


RE: Adding foreign key to exisiting table - kenjis - 01-21-2023

This feature is added in v4.3.0.
See https://codeigniter4.github.io/userguide/changelogs/v4.3.0.html#forge
Forge::processIndexes()