Skip to content

Instantly share code, notes, and snippets.

@lucassmacedo
Created October 8, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucassmacedo/5d4a4608bd751f299146 to your computer and use it in GitHub Desktop.
Save lucassmacedo/5d4a4608bd751f299146 to your computer and use it in GitHub Desktop.
Migrations tutorial step 1
<?php
use Phinx\Migration\AbstractMigration;
class CreatePostsTable extends AbstractMigration {
public function up() {
$table = $this->table('posts');
$table->addColumn('title', 'string')
->addColumn('slug','string')
->addIndex(array('slug'), array('unique' => true))
->addColumn('description', 'text')
->addColumn('created', 'datetime')
->create();
}
public function down() {
$this->dropTable('posts');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment