Welcome Guest, Not a member yet? Register   Sign In
How to use proper C_I 4 migrate (spark)
#1

(This post was last modified: 03-19-2022, 09:57 PM by luckmoshy.)

Hi guys I am stuck with C_i 4 how to use exact migration spark
I see like there is an issue with safe in ci_4 migration if you do take no serious care you will lose your entire database record

PHP Code:
php spark migrate --all/*work*/
php spark migrate:rollback/*work*/
php spark migrate  testMigration /*I want to spark single but it runs all migration why?*/

php spark migrate:rollback  testMigration /*I want to rollback single but it rollback All migrations Why?*/
php spark migrate:refresh  testMigration /*I want to refresh single migration but it refreshes all Why?*/
/*namespace*/
php spark make:migrate  testMigration -n Admin/*work*/

php spark migrate  testMigration -n Admin/*not work*/

php spark make:migrate:refresh  testMigration -n Admin/*not work*/

php spark make:migrate:rollback  testMigration -n Admin/*not work*/ 

so which is a proper way to organize this?

i follow https://codeigniter.com/user_guide/dbmgm...ation.html but !!!

in this scenario
Code:
Web Engineer@Yekrina MINGW64 /c/xampp/htdocs/allwebdevelopers/truelionkingsafars
$ php spark migrate testMigration


CodeIgniter v4.1.9 Command Line Tool - Server Time: 2022-03-20 07:53:43 UTC+03:0
0

Running all new migrations...
Done migrations.

Web Engineer@Yekrina MINGW64 /c/xampp/htdocs/allwebdevelopers/truelionkingsafars
$

it ends like that and in the database seems nothing was inserted
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#2

Show us the migration file.
What did you Try? What did you Get? What did you Expect?

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

(This post was last modified: 03-20-2022, 02:48 AM by luckmoshy.)

(03-19-2022, 09:47 PM)luckmoshy Wrote: Hi guys I am stuck with C_i 4 how to use exact migration spark
I see like there is an issue with safe in ci_4 migration if you do take no serious care you will lose your entire database records

PHP Code:
php spark migrate --all/*work*/
php spark migrate:rollback/*work*/
php spark migrate  testMigration /*I want to spark single but it runs all migration why?*/

php spark migrate:rollback  testMigration /*I want to rollback single but it rollback All migrations Why?*/
php spark migrate:refresh  testMigration /*I want to refresh single migration but it refreshes all Why?*/
/*namespace*/
php spark make:migrate  testMigration -n Admin/*work*/

php spark migrate  testMigration -n Admin/*not work*/

php spark make:migrate:refresh  testMigration -n Admin/*not work*/

php spark make:migrate:rollback  testMigration -n Admin/*not work*/ 

so which is a proper way to organize this?

i follow https://codeigniter.com/user_guide/dbmgm...ation.html but !!!

in this scenario
Code:
Web Engineer@Yekrina MINGW64 /c/xampp/htdocs/allwebdevelopers/truelionkingsafars
$ php spark migrate testMigration


CodeIgniter v4.1.9 Command Line Tool - Server Time: 2022-03-20 07:53:43 UTC+03:0
0

Running all new migrations...
Done migrations.

Web Engineer@Yekrina MINGW64 /c/xampp/htdocs/allwebdevelopers/truelionkingsafars
$

it ends like that and in the database seems nothing was inserted

This is an Admin  Migration  namespace

PHP Code:
<?php

namespace Admin\Database\Migrations;

use 
CodeIgniter\Database\Migration;

class 
testMigration extends Migration
{
 public function 
up()
    {
        $this->forge->addField([
          'blog_id'=> [
 
'type'          => 'INT',
 
'constraint'    => 11,
 
'unsigned'      => true,
 
'auto_increment' => true,
                        ],
                        'title'=> [
                                'type'      => 'VARCHAR',
                                'constraint' => '255',
 
'null' => false,
 
'not' => false,
                        ],
 
'slug'=> [
                                'type'=> 'VARCHAR',
                                'constraint' => '255',
 
'null' => false,
 
'not' => false,
                        ],
 
'label'=> [
                                'type'=> 'VARCHAR',
                                'constraint' => '255',
 
'null' => true,
 
'not' => true,
                        ], 
                        'description'=> [
                                'type' => 'MEDIUMTEXT',
                                'null' => false,
 
'not'=>false,
 
'Comment'=>'description'
                        ],
 
'discription_mage'=> [
                                'type'      => 'VARCHAR',
                                'constraint' => '255',
 
'null' => false,
 
'not' => false,
                        ],
 
        ]);
 
 
 
$this->forge->addPrimaryKey('blog_id',true);
 
$this->forge->addKey('slug','label');
 
$attributes = ['ENGINE' => 'InnoDB'];
 
$this->forge->createTable('blog',false$attributes);         
    
}

    public function down()
    {
        $this->forge->dropTable('blog',true);
    }
  

my PSR4
Code:
'Admin'=>ROOTPATH .'admin'
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4

Hi, try the following way.
Code:
php spark migrate -n Admin
Reply
#5

You misunderstand DB migrations.
You can't specify a migration file like:
Code:
$ php spark migrate  testMigration /*I want to spark single but it runs all migration why?*/

If you run migrations, all migration files (not yet executed at that time) are executed.

Code:
$ php spark help migrate

CodeIgniter v4.1.9 Command Line Tool - Server Time: 2022-03-20 06:27:01 UTC-05:00

Usage:
  migrate [options]

Description:
  Locates and runs all new migrations against the database.

Options:
  -n    Set migration namespace
  -g    Set database group
  --all  Set for all namespaces, will ignore (-n) option
Reply




Theme © iAndrew 2016 - Forum software by © MyBB