Welcome Guest, Not a member yet? Register   Sign In
edit table and add new index key with forge
#1

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 )
Reply
#2

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#3

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB