CodeIgniter4 - How i can add extra 3 fields to a created table using Migration ? |
Dear Everyone,
I'm a beginner to CI4, I created a table with 10+ fields using migration file, after reviewing my management, they want me to add extra 4 fields on it. So I should create a new migration fille seperate for each field or i can just create a migration file using below command ? Code: php spark make:migration AddExtraFieldsToEmployeesTable This is correct way ?
You can update the migration and delete the old table and record in "migration" table. Or php spark migrate:refresh
Add SQL to ALTER TABLE and execute it. (05-10-2024, 05:08 AM)sarath_unrelax Wrote: So I should create a new migration fille seperate for each field No. (05-10-2024, 05:08 AM)sarath_unrelax Wrote: or i can just create a migration file using below command ? Yes, but note that you must use a unique classname in all migration classes (now and in the future). (05-10-2024, 05:08 AM)sarath_unrelax Wrote: After i can use addField() command in up() and removeFiled() in down() ? No, you must use addColumn() and dropColumn(). https://codeigniter4.github.io/CodeIgnit...to-a-table https://codeigniter4.github.io/CodeIgnit...dropcolumn |
Welcome Guest, Not a member yet? Register Sign In |