Last active
December 8, 2017 20:00
-
-
Save jaynarayan89/e23ad3923ff8f96dddd35f8e8784bcce to your computer and use it in GitHub Desktop.
sample migration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Database\Migrations; | |
use CodeIgniter\Database\Migration; | |
class Migration_create_posts_table extends Migration | |
{ | |
public function up() | |
{ | |
$this->forge->addField([ | |
'id' => [ | |
'type' => 'INT', | |
'constraint' => 5, | |
'unsigned' => true, | |
'auto_increment' => true, | |
], | |
'title' => [ | |
'type' => 'VARCHAR', | |
'constraint' => '100', | |
], | |
'slug' => [ | |
'type' => 'VARCHAR', | |
'constraint' => 100, | |
], | |
'content' => [ | |
'type' => 'TEXT', | |
'null' => true, | |
], | |
'created_at' => [ | |
'type' => 'DATETIME', | |
], | |
'status' => [ | |
'type' => 'VARCHAR', | |
'constraint' => '10', | |
], | |
]); | |
$this->forge->addKey('id', true); | |
$this->forge->createTable('posts'); | |
} | |
public function down() | |
{ | |
$this->forge->dropTable('posts'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment