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

My autoload setup

PHP Code:
$psr4 = [
         
'App'         => APPPATH,                // To ensure filters, etc still found,
     
APP_NAMESPACE => APPPATH,                // For custom namespace
     
'Config'      => APPPATH 'Config',
     
'Mod'         => ROOTPATH 'mod',        
]; 

My migration file path

Code:
/mod/System/Database/Migrations/xxxxx_add_system.php


I use "php spark migrate" and show 

Code:
CodeIgniter CLI Tool - Version 4.0.3 - Server-Time: 2020-06-24 23:02:57pm

Running all new migrations...
Done

but no table created
Reply
#2

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?
Reply
#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




Theme © iAndrew 2016 - Forum software by © MyBB