root/trunk/data/migrations/004_m1.php

Revision 2, 1.3 kB (checked in by nperriault, 10 months ago)

First commit of the extracted code from production, I hope no passwd has been forgotten :-)

Line 
1 <?php
2 class Migration004 extends sfMigration
3 {
4
5   // Adding blog table
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   // Dropping blog table
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
Note: See TracBrowser for help on using the browser.