![]() |
DB Migration keeps failing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: DB Migration keeps failing (/showthread.php?tid=88352) |
DB Migration keeps failing - kcs - 08-26-2023 Hi everyone, I am trying to make a simple DB migration, renaming a column in an existing table. I tripled checked my migration file, connection and everything I could think of but I am stuck with an error and have no idea what to do. Can you help me understand where the problem is? My migration: PHP Code: public function up() The error I am getting: Code: An uncaught Exception was encountered RE: DB Migration keeps failing - ozornick - 08-26-2023 Most likely, there is data in your table that has the value title = NULL. You cannot change such a column. Delete the found values with NULL or set them as "" (empty string) RE: DB Migration keeps failing - kcs - 08-26-2023 (08-26-2023, 12:31 PM)ozornick Wrote: Most likely, there is data in your table that has the value title = NULL. I have no Null value on that column RE: DB Migration keeps failing - kenjis - 08-26-2023 It seems an SQL syntax error. Check the SQL statement that was executed. RE: DB Migration keeps failing - kcs - 08-26-2023 (08-26-2023, 02:14 PM)kenjis Wrote: It seems an SQL syntax error. Check the SQL statement that was executed.How do I do that? Is it somewhere in the logs? Or should I use a different command when I run php spark migrate ? // Edit I am not sure if this is the best way... but I went into the BaseConnection.php file and added log_message('debug', $query); to get the query in the logs. It gives me this: Code: DEBUG - 2023-08-26 22:12:15 --> ALTER TABLE `news` RE: DB Migration keeps failing - ozornick - 08-26-2023 Oh, add number for varchar length 'constraint' => '100', RE: DB Migration keeps failing - kcs - 08-27-2023 That was it!!! I did not realise that I needed to resend all the constraints when modifying a column. Thanks a lot @ozornick. |