Iam using this query to create tables in the Database:
$this->dbforge->add_field("label varchar(100) NOT NULL DEFAULT 'default label'");
How can I add Primary key, Unique key Full text and Index attributes to a Field?
You can add a Key with the add_key function:
$this->dbforge->add_key ( 'field_name', TRUE );
The second parameter indicates whether or not you want a Primary Key.
I haven't been able to find a way to add different types of keys using DBForge, short of extending the class. I have found it easier to run a mysql query that adds the index, once I'm sure the table has been created successfully.
$query = "ALTER TABLE `table_name` ADD UNIQUE INDEX `index_name` (`field_name`);";
$this->db->query ( $query );