Welcome Guest, Not a member yet? Register   Sign In
How set up Migration in HMVC?
#3

(06-25-2020, 12:17 PM)marqone Wrote: Hi Jailin -- Usually when I run into stuff like that it is because I did not add the namespace to the file in question; is the namespace in the file defined at the top?

My Migration file :

PHP Code:
<?php namespace Mod\System\Database\Migrations;

use 
CodeIgniter\Database\Migration;

class 
AddSystem extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type' => 'bigint',
                'auto_increment' => true,
                'unsigned' => true,
                'comment' => 'PK'
            ],
            'module_id' => [
                'type' => 'bigint',
                'unsigned' => true,
                'comment' => '模組ID'
            ],
            'setting_key' => [
                'type' => 'varchar',
                'constraint' => 255,
                'null' => false,
                'default' => '',
                'comment' => '設定欄位'
            ],
            'setting_value' => [
                'type' => 'text',
                'null' => true,
                'default' => null,
                'comment' => '設定值'
            ],
            'remark' => [
                'type' => 'text',
                'null' => true,
                'default' => null,
                'comment' => '設定值說明'
            ],
            'created_at' => [
                'type' => 'TIMESTAMP',
                'null' => false,
                'comment' => '新增時間'
            ],
            'updated_at' => [
                'type' => 'TIMESTAMP',
                'null' => false,
                'comment' => '最後更新時間'
            ]
        ]);

        $attributes = ['ENGINE' => 'InnoDB''COMMENT' => '系統設定'];
        $this->forge->addPrimaryKey('id');
        $this->forge->addUniqueKey('setting_key');
        $this->forge->addKey('module_id');
        $this->forge->createTable('system'true$attributes); 
    }

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

    public function down()
    {
        //
    }

Reply


Messages In This Thread
How set up Migration in HMVC? - by jailin - 06-24-2020, 08:06 AM
RE: How set up Migration in HMVC? - by marqone - 06-25-2020, 12:17 PM
RE: How set up Migration in HMVC? - by jailin - 06-26-2020, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB