CodeIgniter Forums
Problem on migration use - 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: Problem on migration use (/showthread.php?tid=73651)



Problem on migration use - cedreek - 05-18-2019

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


RE: Problem on migration use - MGatner - 05-20-2019

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.


RE: Problem on migration use - cedreek - 05-21-2019

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


RE: Problem on migration use - muuucho - 12-20-2019

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


RE: Problem on migration use - MGatner - 12-20-2019

@muuucho I don’t know that it is mentioned, but it would be good to have it there.


RE: Problem on migration use - muuucho - 12-20-2019

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