CodeIgniter Forums
edit table and add new index key with forge - 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: edit table and add new index key with forge (/showthread.php?tid=78272)



edit table and add new index key with forge - tmtuan - 12-26-2020

Hi,

i'm using CI4 and db migration, when i create the table i can create the index at the same time, it worked perfectly, but when i try to edit the table and try to create the index with forge, it's not working, or the dbforge doesn't had the method that allow us to create the index. Do we have anyway to create the index of a field when editing table with forge ( just like laravel does )


RE: edit table and add new index key with forge - includebeer - 12-27-2020

According to the user guide it looks like it’s only possible when creating a table.
Quote:AddKey(): Adds a key to the set that will be used to create a table.

I guess you could execute an SQL query to create your index directly if it’s not possible with the Forge class.


RE: edit table and add new index key with forge - tmtuan - 12-27-2020

(12-27-2020, 08:18 AM)includebeer Wrote: According to the user guide it looks like it’s only possible when creating a table.
Quote:AddKey(): Adds a key to the set that will be used to create a table.

I guess you could execute an SQL query to create your index directly if it’s not possible with the Forge class.
YEs, i used $this->db->query to excute the raw query and create the index, it's worked! but i think CI4 should have funtion for this situation