CodeIgniter Forums

Full Version: Problem on migration use
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Codeigniter Users,

I've problem when I try to migrate some files in sequential mode.
After respect recommendations on Migrations in CI4 Userguide, I run spark command migrate, and I've got this error msg :

Code:
Type:        mysqli_sql_exception
Message:     Unknown column 'group' in 'where clause'
Filename:    /Applications/MAMP/htdocs/bl6/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php
Line Number: 329

I have this exception even specify the group into my migration files...

PHP Code:
<?php namespace App\Database\Migrations;

use 
CodeIgniter\Database\Migration;

class 
Migration_User extends Migration
{
 
   protected $DBGroup 'default';

 
   public function up()
 
   {
......... 

And I still have access to the database on my web application, but same mysql connection problem on group in "where clause".

If anyone could help me.

Thanks in advance
The issue isn't with your database group but rather with a table in your database that is expected to have a `group` column which is missing. I'd bet 99% that this is the `migrations` table which is created automatically upon using migrations and should look like this:

+-----------+--------------+------+-----+---------+-------+
| Field     | Type         | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| version   | varchar(255) | NO   |     | NULL    |       |
| name      | varchar(255) | NO   |     | NULL    |       |
| group     | varchar(255) | NO   |     | NULL    |       |
| namespace | varchar(255) | NO   |     | NULL    |       |
| time      | int(11)      | NO   |     | NULL    |       |
+-----------+--------------+------+-----+---------+-------+


If you have access to the database check the integrity of you migrations table and either repair it by adding `groups` or (if you haven't run any migrations yet) drop it and the framework will recreate it.
(05-20-2019, 06:35 AM)MGatner Wrote: [ -> ]The issue isn't with your database group but rather with a table in your database that is expected to have a `group` column which is missing. I'd bet 99% that this is the `migrations` table which is created automatically upon using migrations and should look like this:

+-----------+--------------+------+-----+---------+-------+
| Field     | Type         | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| version   | varchar(255) | NO   |     | NULL    |       |
| name      | varchar(255) | NO   |     | NULL    |       |
| group     | varchar(255) | NO   |     | NULL    |       |
| namespace | varchar(255) | NO   |     | NULL    |       |
| time      | int(11)      | NO   |     | NULL    |       |
+-----------+--------------+------+-----+---------+-------+


If you have access to the database check the integrity of you migrations table and either repair it by adding `groups` or (if you haven't run any migrations yet) drop it and the framework will recreate it.


Hello MGatner,

Indeed, it was my migration table in error. I've just dropped it, and re-run migrate command, it works fine now !!!

Thanks for your reply.
(05-20-2019, 06:35 AM)MGatner Wrote: [ -> ]The issue isn't with your database group but rather with a table in your database that is expected to have a `group` column which is missing. I'd bet 99% that this is the `migrations` table which is created automatically upon using migrations and should look like this:

+-----------+--------------+------+-----+---------+-------+
| Field     | Type         | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| version   | varchar(255) | NO   |     | NULL    |       |
| name      | varchar(255) | NO   |     | NULL    |       |
| group     | varchar(255) | NO   |     | NULL    |       |
| namespace | varchar(255) | NO   |     | NULL    |       |
| time      | int(11)      | NO   |     | NULL    |       |
+-----------+--------------+------+-----+---------+-------+


If you have access to the database check the integrity of you migrations table and either repair it by adding `groups` or (if you haven't run any migrations yet) drop it and the framework will recreate it.
I miss some info in the docs that the table migrations is created automatically when using migrations.
@muuucho I don’t know that it is mentioned, but it would be good to have it there.
(12-20-2019, 06:58 AM)MGatner Wrote: [ -> ]@muuucho I don’t know that it is mentioned, but it would be good to have it there.
It just says "The database table migration tracks which migrations have already been run" but not that it is automatically created. Actually the ci3 docs doesn't explain either.