| 1 |
<?php |
|---|
| 2 |
class Migration004 extends sfMigration |
|---|
| 3 |
{ |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
public function up() |
|---|
| 7 |
{ |
|---|
| 8 |
$this->executeSQL("SET FOREIGN_KEY_CHECKS = 0;"); |
|---|
| 9 |
$this->executeSQL("DROP TABLE IF EXISTS `blog_posts`;"); |
|---|
| 10 |
$this->executeSQL("CREATE TABLE `blog_posts` ( |
|---|
| 11 |
`id` INTEGER NOT NULL AUTO_INCREMENT, |
|---|
| 12 |
`title` VARCHAR(255) NOT NULL, |
|---|
| 13 |
`slug` VARCHAR(255) NOT NULL, |
|---|
| 14 |
`body` TEXT, |
|---|
| 15 |
`author_id` INTEGER NOT NULL, |
|---|
| 16 |
`is_published` INTEGER default 0 NOT NULL, |
|---|
| 17 |
`created_at` DATETIME, |
|---|
| 18 |
`updated_at` DATETIME, |
|---|
| 19 |
PRIMARY KEY (`id`), |
|---|
| 20 |
KEY `blog_posts_is_published_index`(`is_published`), |
|---|
| 21 |
KEY `blog_posts_created_at_index`(`created_at`), |
|---|
| 22 |
KEY `blog_posts_updated_at_index`(`updated_at`), |
|---|
| 23 |
KEY `post_index`(`slug`, `created_at`, `is_published`), |
|---|
| 24 |
INDEX `blog_posts_FI_1` (`author_id`), |
|---|
| 25 |
CONSTRAINT `blog_posts_FK_1` |
|---|
| 26 |
FOREIGN KEY (`author_id`) |
|---|
| 27 |
REFERENCES `sf_guard_user` (`id`) |
|---|
| 28 |
ON DELETE SET NULL |
|---|
| 29 |
)Type=MyISAM;"); |
|---|
| 30 |
$this->executeSQL("SET FOREIGN_KEY_CHECKS = 1;"); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
public function down() |
|---|
| 35 |
{ |
|---|
| 36 |
$this->executeSQL("SET FOREIGN_KEY_CHECKS = 0;"); |
|---|
| 37 |
$this->executeSQL("DROP TABLE IF EXISTS `blog_posts`;"); |
|---|
| 38 |
$this->executeSQL("SET FOREIGN_KEY_CHECKS = 1;"); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
} |
|---|
| 42 |
|
|---|