codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.37k stars 1.9k forks source link

Bug: Composer php spark migrate error #3771

Closed ChibuezeAgwuDennis closed 4 years ago

ChibuezeAgwuDennis commented 4 years ago

Hello Team group I run a composer command to migrate my database schemas here is the error i got. Please this need a fix

PS C:\php748\htdocs\shop> php spark migrate

CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-10-12 15:42:13pm

Running all new migrations...

Unknown column 'group' in 'where clause'
C:\php748\htdocs\shop\system\Database\MySQLi\Connection.php - 331
paulbalandan commented 4 years ago

Can you try the latest develop branch if the problem is still there?

paulbalandan commented 4 years ago

Or did you check if the table you are using actually has the group column.

lonnieezell commented 4 years ago

That sounds like an issue with the query, not the framework, but if you could provide the schema and code you're using we can verify.

ChibuezeAgwuDennis commented 4 years ago

That sounds like an issue with the query, not the framework, but if you could provide the schema and code you're using we can verify.

Here is the code i will like you to check it


namespace App\Database\Migrations;

use CodeIgniter\Config\Config;
use CodeIgniter\Database\Migration;

class Cart extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id'          => [
                'type'           => 'INT',
                'constraint'     => 50,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'user_id'          => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'default'       => 0
            ],
            'identifier'       => [
                'type'           => 'VARCHAR',
                'constraint'     => '150',
            ],
            'instance' => [
                'type'           => 'VARCHAR',
                'constraint'     => '200',
            ],
            'content' => [
                'type'           => 'TEXT',
                'null'  => true
            ],
        ]);
        $this->forge->addKey(['identifier', 'instance']);
        $this->forge->addPrimaryKey('identifier');
        $this->forge->createTable(Config::get('cart')->database['table']);
    }

    //--------------------------------------------------------------------

    public function down()
    {
        $this->forge->dropTable(Config::get('cart')->database['table']);
    }
}

here is my config code

namespace Config;

use CodeIgniter\Config\BaseConfig;

class Cart extends BaseConfig
{

    /*
    |--------------------------------------------------------------------------
    | Default tax rate
    |--------------------------------------------------------------------------
    |
    | This default tax rate will be used when you make a class implement the
    | Taxable interface and use the HasTax trait.
    |
    */

    public $tax = 21;

    /*
    |--------------------------------------------------------------------------
    | Shoppingcart database settings
    |--------------------------------------------------------------------------
    |
    | Here you can set the connection that the shoppingcart should use when
    | storing and restoring a cart.
    |
    */

    public $database = [

        'connection' => null,

        'table' => 'cart',

    ];

    /*
    |--------------------------------------------------------------------------
    | Destroy the cart on user logout
    |--------------------------------------------------------------------------
    |
    | When this option is set to 'true' the cart will automatically
    | destroy all cart instances when the user logs out.
    |
    */

    public $destroy_on_logout = false;

    /*
    |--------------------------------------------------------------------------
    | Default number format
    |--------------------------------------------------------------------------
    |
    | This defaults will be used for the formated numbers if you don't
    | set them in the method call.
    |
    */

    public $format = [

        'decimals'  => 2,

        'decimal_point' => '.',

        'thousand_seperator' => ','

    ];

}

Were am I doing it wrong

ChibuezeAgwuDennis commented 4 years ago

Or did you check if the table you are using actually has the group column.

I am not sure I called anything relating to column group check the code above and that is the only code I am trying to migrate