Reputation: 55
When I add new fields to table with migration on codeigniter, all records deleted on table. How can i keep old recors on my table with migration? Thank you.
Upvotes: 2
Views: 8745
Reputation: 3586
Use add_column
rather than add_field
. add_field
is used to define fields for table creation, add_column
modifies an existing table. The docs are pretty confusing on that point.
Upvotes: 5
Reputation: 626
Its working for me. You can try this -
$this->load->database();
$this->db->query("ALTER TABLE table_name ADD column_name TEXT NULL");
Upvotes: 0