CodeIgniter Forums
Database Forge - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forum-29.html)
+--- Thread: Database Forge (/thread-70447.html)



Database Forge - iceleo - 04-10-2018

Hello,

Maybe the Database Forge is not designed for more purposes. I use it to create a table, modify a column, I realized it was not flexible enough. So I request some method for this class.

modifyPrimaryKey(string $table_name, string | array $keys); // ALTER TABLE `table_name` DROP PRIMARY KEY, ADD PRIMARY KEY(`key_1`, `key_2`);

This method is designed to modify one or more primary keys from a table.


dropPrimaryKey(string $table_name); // ALTER TABLE `table_name` DROP PRIMARY KEY;

This method is designed to drop all primary keys from a table.

You can use modifyPrimaryKey() method for both method above. If $keys is empty, just drop all primary keys.

It's up to you.


addField(array $field) and modifyColumn(string $table, array $field);
Should be had (bool) 'primary' property in array $field like unsigned, auto_increment.

Thank you.