Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter4 - How i can add extra 3 fields to a created table using Migration ?
#1

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
After i can use addField() command in up() and removeFiled() in down() ?

This is correct way ?
Reply
#2

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.
Simple CI 4 project for beginners codeigniter-expenses
Reply
#3

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

Code:
php spark make:migration AddExtraFieldsToEmployeesTable

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB