mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-10-22 19:14:40 +02:00
3.3 KiB
3.3 KiB
Alternate Snippets for Migrations
[ProjectRoot]/app/Database/Migrations/
Table of Content
Create Migration
Command
ci4:migration
Output
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddBlog extends Migration
{
public function up()
{
//
}
public function down()
{
//
}
}
-
Migration Up
Command
ci4:migration:upOutput
public function up() { $this->forge->addField([ 'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], 'name' => [ 'type' => 'VARCHAR', 'constraint' => 255, ], '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->createTable('tableName'); } -
Migration Down
Command
ci4:migration:downOutput
public function down() { $this->forge->dropTable('tableName'); }
Create Table
-
Add Column
-
BIGINT
Command
ci4:migration:bigintOutput
'columnName' => [ 'type' => 'BIGINT', 'constraint' => '20', 'null' => true, ], -
CHAR
Command
ci4:migration:charOutput
'columnName' => [ 'type' => 'CHAR', 'constraint' => '10', 'null' => true, ], -
DATETIME
Command
ci4:migration:datetimeOutput
'columnName' => [ 'type' => 'DATETIME', 'null' => true, ], -
INT
Command
ci4:migration:intOutput
'columnName' => [ 'type' => 'INT', 'constraint' => '11', 'null' => true, ], -
VARCHAR
Command
ci4:migration:varcharOutput
'columnName' => [ 'type' => 'VARCHAR', 'constraint' => '255', 'null' => true, ],
-
-
ID
Command :
ci4:migration:idOutput :
'id' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true, ], -
Timestamp
Command :
ci4:migration:timestampOutput :
'created_at' => [ 'type' => 'DATETIME', 'null' => true, ], 'updated_at' => [ 'type' => 'DATETIME', 'null' => true, ], 'deleted_at' => [ 'type' => 'DATETIME', 'null' => true, ],