![]() |
I would like to add new column in database within migration, but I want to add also foreign key.
I already have a table devices and I want to add column customer_id with relation to customers table. Here is a migration PHP Code: <?php But when I ran php spark migrate -all I'm getting Code: Field `customer_id` not found. and migration fail.
Please Read:
CodeIgniter 4 User Guide - Foreign Keys CodeIgniter 4 User Guide - Adding Foreign Keys What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@InsiteFX thanks, but I can't find what I needed in docs.
Here is the working example how to get it to work. I ended with alter query. PHP Code: <?php
Yes, you need to use query() method now.
The feature to add keys to existing tables will be implemented in v4.3.0. See https://github.com/codeigniter4/CodeIgni....rst#forge PHP Code: $this->forge->addKey(['category', 'name'], false, false, 'category_name'); |
Welcome Guest, Not a member yet? Register Sign In |