Skip to content

Instantly share code, notes, and snippets.

@jaynarayan89
Last active December 8, 2017 20:00
Show Gist options
  • Save jaynarayan89/e23ad3923ff8f96dddd35f8e8784bcce to your computer and use it in GitHub Desktop.
Save jaynarayan89/e23ad3923ff8f96dddd35f8e8784bcce to your computer and use it in GitHub Desktop.
sample migration file
<?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