@@ -2,14 +2,14 @@ |
||
| 2 | 2 | |
| 3 | 3 | class m170731_173719_comments_and_relationships_fix extends CDbMigration |
| 4 | 4 | { |
| 5 | - public function up() |
|
| 5 | + public function up () |
|
| 6 | 6 | { |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | - public function down() |
|
| 9 | + public function down () |
|
| 10 | 10 | { |
| 11 | - $this->addForeignKey('user_roles_fk', 'users', 'user_role', 'user_roles', 'id', 'CASCADE', 'NO ACTION'); |
|
| 12 | - $this->execute('ALTER TABLE `comments` MODIFY comment TEXT NOT NULL'); |
|
| 11 | + $this->addForeignKey ('user_roles_fk', 'users', 'user_role', 'user_roles', 'id', 'CASCADE', 'NO ACTION'); |
|
| 12 | + $this->execute ('ALTER TABLE `comments` MODIFY comment TEXT NOT NULL'); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /* |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | private $_moment = 0; |
| 11 | 11 | |
| 12 | - public function safeUp() |
|
| 12 | + public function safeUp () |
|
| 13 | 13 | { |
| 14 | - $this->_moment = time(); |
|
| 14 | + $this->_moment = time (); |
|
| 15 | 15 | |
| 16 | 16 | // Try to get the table names, if we get something back, do not run this migration |
| 17 | 17 | try |
| 18 | 18 | { |
| 19 | - $test = Yii::app()->db->schema->getTables(); |
|
| 20 | - if (count($test) <= 1) |
|
| 21 | - throw new Exception('CiiMS doesn\'t exist. Applying base migration'); |
|
| 19 | + $test = Yii::app ()->db->schema->getTables (); |
|
| 20 | + if (count ($test) <= 1) |
|
| 21 | + throw new Exception ('CiiMS doesn\'t exist. Applying base migration'); |
|
| 22 | 22 | return true; |
| 23 | 23 | } |
| 24 | 24 | catch (Exception $e) |
@@ -28,16 +28,16 @@ discard block |
||
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // Otherwise, run the install migration |
| 31 | - $this->createUserTables(); |
|
| 31 | + $this->createUserTables (); |
|
| 32 | 32 | |
| 33 | - $this->createCategories(); |
|
| 33 | + $this->createCategories (); |
|
| 34 | 34 | |
| 35 | - $this->createContent(); |
|
| 35 | + $this->createContent (); |
|
| 36 | 36 | |
| 37 | - $this->createConfiguration(); |
|
| 37 | + $this->createConfiguration (); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function safeDown() |
|
| 40 | + public function safeDown () |
|
| 41 | 41 | { |
| 42 | 42 | echo "m141001_145619_init does not support migration down.\n"; |
| 43 | 43 | return false; |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Creates the tables, indexes, and relations for users |
| 48 | 48 | */ |
| 49 | - private function createUserTables() |
|
| 49 | + private function createUserTables () |
|
| 50 | 50 | { |
| 51 | - $this->createTable('users', array( |
|
| 51 | + $this->createTable ('users', array( |
|
| 52 | 52 | 'id' => 'pk', |
| 53 | 53 | 'email' => 'string NOT NULL', |
| 54 | 54 | 'password' => 'string NOT NULL', |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | 'updated' => 'integer' |
| 60 | 60 | )); |
| 61 | 61 | |
| 62 | - $this->createTable('user_roles', array( |
|
| 62 | + $this->createTable ('user_roles', array( |
|
| 63 | 63 | 'id' => 'pk', |
| 64 | 64 | 'name' => 'string NOT NULL', |
| 65 | 65 | 'created' => 'integer', |
| 66 | 66 | 'updated' => 'integer' |
| 67 | 67 | )); |
| 68 | 68 | |
| 69 | - $this->createTable('user_metadata', array( |
|
| 69 | + $this->createTable ('user_metadata', array( |
|
| 70 | 70 | 'user_id' => 'integer', |
| 71 | 71 | 'key' => 'string NOT NULL', |
| 72 | 72 | 'value' => 'text NOT NULL', |
@@ -76,66 +76,66 @@ discard block |
||
| 76 | 76 | )); |
| 77 | 77 | |
| 78 | 78 | // Create the necessary indexes on the columns |
| 79 | - $this->createIndex('user_email', 'users', 'email', true); |
|
| 80 | - $this->createIndex('user_username', 'users', 'username', true); |
|
| 81 | - $this->createIndex('user_metadata', 'user_metadata', 'user_id, key', false); |
|
| 79 | + $this->createIndex ('user_email', 'users', 'email', true); |
|
| 80 | + $this->createIndex ('user_username', 'users', 'username', true); |
|
| 81 | + $this->createIndex ('user_metadata', 'user_metadata', 'user_id, key', false); |
|
| 82 | 82 | |
| 83 | - $this->addPrimaryKey('user_metadata_composite', 'user_metadata', 'user_id,key'); |
|
| 83 | + $this->addPrimaryKey ('user_metadata_composite', 'user_metadata', 'user_id,key'); |
|
| 84 | 84 | |
| 85 | 85 | // Setup the foreign key constraints |
| 86 | - $this->addForeignKey('user_metadata_relation_fk', 'user_metadata', 'user_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 86 | + $this->addForeignKey ('user_metadata_relation_fk', 'user_metadata', 'user_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 87 | 87 | |
| 88 | 88 | // Insert data into the tables |
| 89 | - $this->insert('user_roles', array( |
|
| 89 | + $this->insert ('user_roles', array( |
|
| 90 | 90 | 'id' => 1, |
| 91 | 91 | 'name' => 'User', |
| 92 | 92 | 'created' => $this->_moment, |
| 93 | 93 | 'updated' => $this->_moment |
| 94 | 94 | )); |
| 95 | 95 | |
| 96 | - $this->insert('user_roles', array( |
|
| 96 | + $this->insert ('user_roles', array( |
|
| 97 | 97 | 'id' => 2, |
| 98 | 98 | 'name' => 'Pending', |
| 99 | 99 | 'created' => $this->_moment, |
| 100 | 100 | 'updated' => $this->_moment |
| 101 | 101 | )); |
| 102 | 102 | |
| 103 | - $this->insert('user_roles', array( |
|
| 103 | + $this->insert ('user_roles', array( |
|
| 104 | 104 | 'id' => 3, |
| 105 | 105 | 'name' => 'Suspended', |
| 106 | 106 | 'created' => $this->_moment, |
| 107 | 107 | 'updated' => $this->_moment |
| 108 | 108 | )); |
| 109 | 109 | |
| 110 | - $this->insert('user_roles', array( |
|
| 110 | + $this->insert ('user_roles', array( |
|
| 111 | 111 | 'id' => 5, |
| 112 | 112 | 'name' => 'Collaborator', |
| 113 | 113 | 'created' => $this->_moment, |
| 114 | 114 | 'updated' => $this->_moment |
| 115 | 115 | )); |
| 116 | 116 | |
| 117 | - $this->insert('user_roles', array( |
|
| 117 | + $this->insert ('user_roles', array( |
|
| 118 | 118 | 'id' => 6, |
| 119 | 119 | 'name' => 'Author', |
| 120 | 120 | 'created' => $this->_moment, |
| 121 | 121 | 'updated' => $this->_moment |
| 122 | 122 | )); |
| 123 | 123 | |
| 124 | - $this->insert('user_roles', array( |
|
| 124 | + $this->insert ('user_roles', array( |
|
| 125 | 125 | 'id' => 7, |
| 126 | 126 | 'name' => 'User', |
| 127 | 127 | 'created' => $this->_moment, |
| 128 | 128 | 'updated' => $this->_moment |
| 129 | 129 | )); |
| 130 | 130 | |
| 131 | - $this->insert('user_roles', array( |
|
| 131 | + $this->insert ('user_roles', array( |
|
| 132 | 132 | 'id' => 8, |
| 133 | 133 | 'name' => 'Publisher', |
| 134 | 134 | 'created' => $this->_moment, |
| 135 | 135 | 'updated' => $this->_moment |
| 136 | 136 | )); |
| 137 | 137 | |
| 138 | - $this->insert('user_roles', array( |
|
| 138 | + $this->insert ('user_roles', array( |
|
| 139 | 139 | 'id' => 9, |
| 140 | 140 | 'name' => 'Administrator', |
| 141 | 141 | 'created' => $this->_moment, |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * Create the categories and relations |
| 148 | 148 | */ |
| 149 | - private function createCategories() |
|
| 149 | + private function createCategories () |
|
| 150 | 150 | { |
| 151 | 151 | // Categories |
| 152 | - $this->createTable('categories', array( |
|
| 152 | + $this->createTable ('categories', array( |
|
| 153 | 153 | 'id' => 'pk', |
| 154 | 154 | 'parent_id' => 'integer DEFAULT 1', |
| 155 | 155 | 'name' => 'string NOT NULL', |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'updated' => 'integer' |
| 159 | 159 | )); |
| 160 | 160 | |
| 161 | - $this->createTable('categories_metadata', array( |
|
| 161 | + $this->createTable ('categories_metadata', array( |
|
| 162 | 162 | 'category_id' => 'integer', |
| 163 | 163 | 'key' => 'string NOT NULL', |
| 164 | 164 | 'value' => 'text NOT NULL', |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | )); |
| 168 | 168 | |
| 169 | 169 | // Insert the first record into the categories table |
| 170 | - $this->insert('categories', array( |
|
| 170 | + $this->insert ('categories', array( |
|
| 171 | 171 | 'id' => 1, |
| 172 | 172 | 'name' => 'Uncategorized', |
| 173 | 173 | 'slug' => 'uncategorized', |
@@ -175,17 +175,17 @@ discard block |
||
| 175 | 175 | 'updated' => $this->_moment |
| 176 | 176 | )); |
| 177 | 177 | |
| 178 | - $this->addPrimaryKey('categories_metadata_composite', 'categories_metadata', 'category_id,key'); |
|
| 179 | - $this->addForeignKey('categories_parents_fk', 'categories', 'parent_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 180 | - $this->addForeignKey('categories_metadata_fk', 'categories_metadata', 'category_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 178 | + $this->addPrimaryKey ('categories_metadata_composite', 'categories_metadata', 'category_id,key'); |
|
| 179 | + $this->addForeignKey ('categories_parents_fk', 'categories', 'parent_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 180 | + $this->addForeignKey ('categories_metadata_fk', 'categories_metadata', 'category_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * Creates the content, comemnts, and necessary relations |
| 185 | 185 | */ |
| 186 | - private function createContent() |
|
| 186 | + private function createContent () |
|
| 187 | 187 | { |
| 188 | - $this->createTable('content', array( |
|
| 188 | + $this->createTable ('content', array( |
|
| 189 | 189 | 'id' => 'integer NOT NULL', |
| 190 | 190 | 'vid' => 'integer NOT NULL DEFAULT 1', |
| 191 | 191 | 'title' => 'string NOT NULL', |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | 'updated' => 'integer' |
| 205 | 205 | )); |
| 206 | 206 | |
| 207 | - $this->createTable('content_types', array( |
|
| 207 | + $this->createTable ('content_types', array( |
|
| 208 | 208 | 'id' => 'pk', |
| 209 | 209 | 'name' => 'string NOT NULL', |
| 210 | 210 | 'created' => 'integer', |
| 211 | 211 | 'updated' => 'integer' |
| 212 | 212 | )); |
| 213 | 213 | |
| 214 | - $this->createTable('content_metadata', array( |
|
| 214 | + $this->createTable ('content_metadata', array( |
|
| 215 | 215 | 'content_id' => 'integer', |
| 216 | 216 | 'key' => 'string NOT NULL', |
| 217 | 217 | 'value' => 'text NOT NULL', |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | 'updated' => 'integer' |
| 220 | 220 | )); |
| 221 | 221 | |
| 222 | - $this->createTable('comments', array( |
|
| 222 | + $this->createTable ('comments', array( |
|
| 223 | 223 | 'id' => 'pk', |
| 224 | 224 | 'content_id' => 'integer', |
| 225 | 225 | 'author_id' => 'integer', |
@@ -228,53 +228,53 @@ discard block |
||
| 228 | 228 | 'updated' => 'integer' |
| 229 | 229 | )); |
| 230 | 230 | |
| 231 | - $this->insert('content_types', array( |
|
| 231 | + $this->insert ('content_types', array( |
|
| 232 | 232 | 'id' => 1, |
| 233 | 233 | 'name' => 'Static Page', |
| 234 | 234 | 'created' => $this->_moment, |
| 235 | 235 | 'updated' => $this->_moment |
| 236 | 236 | )); |
| 237 | 237 | |
| 238 | - $this->insert('content_types', array( |
|
| 238 | + $this->insert ('content_types', array( |
|
| 239 | 239 | 'id' => 2, |
| 240 | 240 | 'name' => 'Blog Post', |
| 241 | 241 | 'created' => $this->_moment, |
| 242 | 242 | 'updated' => $this->_moment |
| 243 | 243 | )); |
| 244 | 244 | |
| 245 | - $this->addPrimaryKey('content_composite', 'content', 'id, vid'); |
|
| 245 | + $this->addPrimaryKey ('content_composite', 'content', 'id, vid'); |
|
| 246 | 246 | |
| 247 | - $this->execute('ALTER TABLE `content` CHANGE id id INT( 11 ) NOT NULL AUTO_INCREMENT'); |
|
| 247 | + $this->execute ('ALTER TABLE `content` CHANGE id id INT( 11 ) NOT NULL AUTO_INCREMENT'); |
|
| 248 | 248 | |
| 249 | - $this->addPrimaryKey('content_metadata_composite', 'content_metadata', 'content_id,key'); |
|
| 249 | + $this->addPrimaryKey ('content_metadata_composite', 'content_metadata', 'content_id,key'); |
|
| 250 | 250 | |
| 251 | - $this->createIndex('content_author', 'content', 'author_id', false); |
|
| 252 | - $this->createIndex('content_category', 'content', 'category_id', false); |
|
| 253 | - $this->createIndex('content_type', 'content', 'type_id', false); |
|
| 254 | - $this->createIndex('comment_content', 'comments', 'content_id', false); |
|
| 255 | - $this->createIndex('comment_author', 'comments', 'author_id', false); |
|
| 251 | + $this->createIndex ('content_author', 'content', 'author_id', false); |
|
| 252 | + $this->createIndex ('content_category', 'content', 'category_id', false); |
|
| 253 | + $this->createIndex ('content_type', 'content', 'type_id', false); |
|
| 254 | + $this->createIndex ('comment_content', 'comments', 'content_id', false); |
|
| 255 | + $this->createIndex ('comment_author', 'comments', 'author_id', false); |
|
| 256 | 256 | |
| 257 | - $this->addForeignKey('content_category_fk', 'content', 'category_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 258 | - $this->addForeignKey('content_author_fk', 'content', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 259 | - $this->addForeignKey('content_type_fk', 'content', 'type_id', 'content_types', 'id', 'CASCADE', 'NO ACTION'); |
|
| 257 | + $this->addForeignKey ('content_category_fk', 'content', 'category_id', 'categories', 'id', 'CASCADE', 'NO ACTION'); |
|
| 258 | + $this->addForeignKey ('content_author_fk', 'content', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 259 | + $this->addForeignKey ('content_type_fk', 'content', 'type_id', 'content_types', 'id', 'CASCADE', 'NO ACTION'); |
|
| 260 | 260 | |
| 261 | - $this->addForeignKey('comments_content_id_fk', 'comments', 'content_id', 'content', 'id', 'CASCADE', 'NO ACTION'); |
|
| 262 | - $this->addForeignKey('comments_author_fk', 'comments', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 261 | + $this->addForeignKey ('comments_content_id_fk', 'comments', 'content_id', 'content', 'id', 'CASCADE', 'NO ACTION'); |
|
| 262 | + $this->addForeignKey ('comments_author_fk', 'comments', 'author_id', 'users', 'id', 'CASCADE', 'NO ACTION'); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Creates the configuration and events tables |
| 267 | 267 | */ |
| 268 | - private function createConfiguration() |
|
| 268 | + private function createConfiguration () |
|
| 269 | 269 | { |
| 270 | - $this->createTable('configuration', array( |
|
| 270 | + $this->createTable ('configuration', array( |
|
| 271 | 271 | 'key' => 'string', |
| 272 | 272 | 'value' => 'text NOT NULL', |
| 273 | 273 | 'created' => 'integer', |
| 274 | 274 | 'updated' => 'integer' |
| 275 | 275 | )); |
| 276 | 276 | |
| 277 | - $this->createTable('events', array( |
|
| 277 | + $this->createTable ('events', array( |
|
| 278 | 278 | 'id' => 'pk', |
| 279 | 279 | 'event' => 'string NOT NULL', |
| 280 | 280 | 'event_data' => 'text DEFAULT NULL', |
@@ -283,6 +283,6 @@ discard block |
||
| 283 | 283 | 'created' => 'integer' |
| 284 | 284 | )); |
| 285 | 285 | |
| 286 | - $this->addPrimaryKey('configuration_pk', 'configuration', 'key'); |
|
| 286 | + $this->addPrimaryKey ('configuration_pk', 'configuration', 'key'); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | \ No newline at end of file |