
上QQ阅读APP看书,第一时间看更新
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