| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Topic Prefixes extension for the phpBB Forum Software package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright (c) 2016 phpBB Limited <https://www.phpbb.com> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license GNU General Public License, version 2 (GPL-2.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace phpbb\topicprefixes\migrations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * Class install_schema | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class install_schema extends \phpbb\db\migration\migration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	 * @inheritdoc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	public function effectively_installed() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		return $this->db_tools->sql_table_exists($this->table_prefix . 'topic_prefixes'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 * @inheritdoc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	public static function depends_on() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		return ['\phpbb\db\migration\data\v31x\v314']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 * Add the topic prefixes schema to the database: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 *    topic_prefixes: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	 *        prefix_id       Prefix identifier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	 *        prefix_tag      Prefix tag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	 *        prefix_enabled  Prefix enabled/disabled state | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 *        forum_id        The forum identifier associated with the prefix | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 *    topics: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 *        topic_prefix_id The prefix identifier associated with the topic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	 * @return array Array of table schema | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 45 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	public function update_schema() | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  | 		return [ | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  | 			'add_tables'	=> [ | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | 				$this->table_prefix . 'topic_prefixes'	=> [ | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 					'COLUMNS'     => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 						'prefix_id'			=> ['UINT', null, 'auto_increment'], | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 						'prefix_tag'		=> ['VCHAR_UNI', ''], | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 						'prefix_enabled'	=> ['BOOL', 1], | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 						'forum_id'			=> ['UINT', 0], | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 					], | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 					'PRIMARY_KEY'			=> 'prefix_id', | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 				], | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  | 			], | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  | 			'add_columns'	=> [ | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  | 				$this->table_prefix . 'topics'			=> [ | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  | 					'topic_prefix_id'		=> ['UINT', 0], | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  | 				], | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  | 			], | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 		]; | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 * Drop the topic prefixes schema from the database | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	 * @return array Array of table schema | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	public function revert_schema() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			'drop_tables'	=> [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 				$this->table_prefix . 'topic_prefixes', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			'drop_columns'	=> [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 				$this->table_prefix . 'topics'			=> [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 					'topic_prefix_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 				], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 			], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 86 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 87 |  |  |  |