Welcome Guest, Not a member yet? Register   Sign In
Where are the migration commands?
#1

I'm using CodeIgniter 4.0.2 and the migration commands are gone. How can I get them back?
Reply
#2

(This post was last modified: 02-27-2020, 03:16 PM by InsiteFX.)

There not gone they use the same commands as Database Forge.

Look at the Database Forge commands.

Here is the Migration from Myth/Auth:

PHP Code:
<?php namespace Myth\Auth\Database\Migrations;

use 
CodeIgniter\Database\Migration;

class 
CreateAuthTables extends Migration
{
    public function up()
    {
        /*
         * Users
         */
        $this->forge->addField([
            'id'               => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'email'            => ['type' => 'varchar''constraint' => 255],
            'username'         => ['type' => 'varchar''constraint' => 30'null' => true],
            'password_hash'    => ['type' => 'varchar''constraint' => 255],
            'reset_hash'       => ['type' => 'varchar''constraint' => 255'null' => true],
            'reset_at'         => ['type' => 'datetime''null' => true],
            'reset_expires'    => ['type' => 'datetime''null' => true],
            'activate_hash'    => ['type' => 'varchar''constraint' => 255'null' => true],
            'status'           => ['type' => 'varchar''constraint' => 255'null' => true],
            'status_message'   => ['type' => 'varchar''constraint' => 255'null' => true],
            'active'           => ['type' => 'tinyint''constraint' => 1'null' => 0'default' => 0],
            'force_pass_reset' => ['type' => 'tinyint''constraint' => 1'null' => 0'default' => 0],
            'created_at'       => ['type' => 'datetime''null' => true],
            'updated_at'       => ['type' => 'datetime''null' => true],
            'deleted_at'       => ['type' => 'datetime''null' => true],
        ]);

        $this->forge->addKey('id'true);
        $this->forge->addUniqueKey('email');
        $this->forge->addUniqueKey('username');

        $this->forge->createTable('users'true);

        /*
         * Auth Login Attempts
         */
        $this->forge->addField([
            'id'         => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'ip_address' => ['type' => 'varchar''constraint' => 255'null' => true],
            'email'      => ['type' => 'varchar''constraint' => 255'null' => true],
            'user_id'    => ['type' => 'int''constraint' => 11'unsigned' => true'null' => true], // Only for successful logins
            'date'       => ['type' => 'datetime'],
            'success'    => ['type' => 'tinyint''constraint' => 1],
        ]);
        $this->forge->addKey('id'true);
        $this->forge->addKey('email');
        $this->forge->addKey('user_id');
        // NOTE: Do NOT delete the user_id or email when the user is deleted for security audits
        $this->forge->createTable('auth_logins'true);

        /*
         * Auth Tokens
         * @see https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence
         */
        $this->forge->addField([
            'id'              => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'selector'        => ['type' => 'varchar''constraint' => 255],
            'hashedValidator' => ['type' => 'varchar''constraint' => 255],
            'user_id'         => ['type' => 'int''constraint' => 11'unsigned' => true],
            'expires'         => ['type' => 'datetime'],
        ]);
        $this->forge->addKey('id'true);
        $this->forge->addKey('selector');
        $this->forge->addForeignKey('user_id''users''id'false'CASCADE');
        $this->forge->createTable('auth_tokens'true);

        /*
         * Password Reset Table
         */
        $this->forge->addField([
            'id'         => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'email'      => ['type' => 'varchar''constraint' => 255],
            'ip_address' => ['type' => 'varchar''constraint' => 255],
            'user_agent' => ['type' => 'varchar''constraint' => 255],
            'token'      => ['type' => 'varchar''constraint' => 255'null' => true],
            'created_at' => ['type' => 'datetime''null' => false],
        ]);
        $this->forge->addKey('id'true);
        $this->forge->createTable('auth_reset_attempts');

        /*
         * Activation Attempts Table
         */
        $this->forge->addField([
            'id'         => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'ip_address' => ['type' => 'varchar''constraint' => 255],
            'user_agent' => ['type' => 'varchar''constraint' => 255],
            'token'      => ['type' => 'varchar''constraint' => 255'null' => true],
            'created_at' => ['type' => 'datetime''null' => false],
        ]);
        $this->forge->addKey('id'true);
        $this->forge->createTable('auth_activation_attempts');

        /*
         * Groups Table
         */
        $fields = [
            'id'          => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'name'        => ['type' => 'varchar''constraint' => 255],
            'description' => ['type' => 'varchar''constraint' => 255],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey('id'true);
        $this->forge->createTable('auth_groups'true);

        /*
         * Permissions Table
         */
        $fields = [
            'id'          => ['type' => 'int''constraint' => 11'unsigned' => true'auto_increment' => true],
            'name'        => ['type' => 'varchar''constraint' => 255],
            'description' => ['type' => 'varchar''constraint' => 255],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey('id'true);
        $this->forge->createTable('auth_permissions'true);

        /*
         * Groups/Permissions Table
         */
        $fields = [
            'group_id'      => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
            'permission_id' => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey(['group_id''permission_id']);
        $this->forge->addForeignKey('group_id''auth_groups''id'false'CASCADE');
        $this->forge->addForeignKey('permission_id''auth_permissions''id'false'CASCADE');
        $this->forge->createTable('auth_groups_permissions'true);

        /*
         * Users/Groups Table
         */
        $fields = [
            'group_id' => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
            'user_id'  => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey(['group_id''user_id']);
        $this->forge->addForeignKey('group_id''auth_groups''id'false'CASCADE');
        $this->forge->addForeignKey('user_id''users''id'false'CASCADE');
        $this->forge->createTable('auth_groups_users'true);

        /*
         * Users/Permissions Table
         */
        $fields = [
            'user_id'       => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
            'permission_id' => ['type' => 'int''constraint' => 11'unsigned' => true'default' => 0],
        ];

        $this->forge->addField($fields);
        $this->forge->addKey(['user_id''permission_id']);
        $this->forge->addForeignKey('user_id''users''id'false'CASCADE');
        $this->forge->addForeignKey('permission_id''auth_permissions''id'false'CASCADE');
        $this->forge->createTable('auth_users_permissions');
    }

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

    public function down()
    {
        
// drop constraints first to prevent errors
        if ($this->db->DBDriver != 'SQLite3')
        {
            $this->forge->dropForeignKey('auth_tokens''auth_tokens_user_id_foreign');
            $this->forge->dropForeignKey('auth_groups_permissions''auth_groups_permissions_group_id_foreign');
            $this->forge->dropForeignKey('auth_groups_permissions''auth_groups_permissions_permission_id_foreign');
            $this->forge->dropForeignKey('auth_groups_users''auth_groups_users_group_id_foreign');
            $this->forge->dropForeignKey('auth_groups_users''auth_groups_users_user_id_foreign');
            $this->forge->dropForeignKey('auth_users_permissions''auth_users_permissions_user_id_foreign');
            $this->forge->dropForeignKey('auth_users_permissions''auth_users_permissions_permission_id_foreign');
        }

        
$this->forge->dropTable('users'true);
        
$this->forge->dropTable('auth_logins'true);
        
$this->forge->dropTable('auth_tokens'true);
        
$this->forge->dropTable('auth_reset_attempts'true);
        $this->forge->dropTable('auth_activation_attempts'true);
        
$this->forge->dropTable('auth_groups'true);
        
$this->forge->dropTable('auth_permissions'true);
        
$this->forge->dropTable('auth_groups_permissions'true);
        
$this->forge->dropTable('auth_groups_users'true);
        
$this->forge->dropTable('auth_users_permissions'true);
    }


That should point you in the right direction.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I tried to run "php spark" and no migration commands appear.
Reply
#4

I am having the same problem. No spark commands seem to run at all. This is what I just trying to run spark (which used to show a helpful list of commands).


Code:
CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-02-27 23:04:31pm

Command "help" not found.
Reply
#5

Try

> php spark list
Reply
#6

(This post was last modified: 02-27-2020, 11:19 PM by marqone.)

I did some more digging around. I installed the appstarter project in a clean directory and tried the spark command just to make sure it was not an issue with my install that I have been using since before the RC's. I ended up getting the Kint error... which is weird because the fix for that appeared to be copying the Kint.php file from the system/config directory into the app/config directory, but when I checked out app/config the file was there

Code:
$ ./spark
An uncaught Exception was encountered

Type:        Error
Message:    Class 'Kint\Kint' not found
Filename:    /home/greg/test/vendor/codeigniter4/framework/system/ThirdParty/Kint/init.php
Line Number: 46


So with that not working I tried out the regular codeigniter4/framework package. This had a better result, but still think something is slightly off as I recall when you ran the spark command previously it would run the list command when no parameters were passed; this did not, but the list command does work. 

Code:
$ ./spark


CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-02-27 23:54:58pm

Description:
  Displays basic usage information.

Usage:
  help command_name

Arguments:
  command_name      The command name [default: "help"]

(02-27-2020, 10:50 PM)dave friend Wrote: Try

> php spark list

Tried that too. 
Code:
$ php spark list


CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-02-28 00:08:01am

Command "list" not found.

More updates -- because I have to test migrations for a project... sorry if this is too many messages.

So I rolled back to RC4 and found out that spark did not work there either, so I rolled back to RC3 and spark started to work again...
Reply
#7

Make sure that you are running it in the root along with index.php public folder.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

I know that php spark is working because I just migrated the Myth/Auth tables.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(02-27-2020, 03:59 PM)falko Wrote: I tried to run "php spark" and no migration commands appear.
Do 
Code:
php spark list
Reply
#10

(This post was last modified: 02-28-2020, 09:34 AM by marqone.)

(02-28-2020, 07:34 AM)rahulswt7 Wrote:
(02-27-2020, 03:59 PM)falko Wrote: I tried to run "php spark" and no migration commands appear.
Do 
Code:
php spark list

Yes - tried that too. 
Code:
$ php spark list


CodeIgniter CLI Tool - Version 4.0.2 - Server-Time: 2020-02-28 00:08:01am

Command "list" not found.

(02-28-2020, 06:04 AM)InsiteFX Wrote: I know that php spark is working because I just migrated the Myth/Auth tables.

Can you let us know your environment and how you installed CI? This might have something to do with installing via composer.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB