Book Image

Yii Project Blueprints

By : Charles R. Portwood ll
Book Image

Yii Project Blueprints

By: Charles R. Portwood ll

Overview of this book

Table of Contents (15 chapters)
Yii Project Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the database


To create the database, we again use migrations. From the command line, let's navigate to the project root and create the migration using yiic:

$ php protected/yiic.php migrate create locations

After confirming the creation, we open up the new migration file in protected/migrations and replace the contents up() method with the following:

return $this->createTable('locations', array(
   'id' => 'INTEGER PRIMARY KEY',
   'name' => 'TEXT',
   'lat' => 'TEXT',
   'long' => 'TEXT',
   'city' => 'TEXT',
   'state' => 'TEXT',
   'created' => 'INTEGER',
   'updated' => 'INTEGER'
));

Then, we replace the contents of the down() method with the following:

return $this->dropTable('locations');

From the command line, let's now apply the new migration:

$ php protected/yiic.php migrate up