| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Aimeos (aimeos.org), 2018 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace Aimeos\MW\Setup\Task; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Adds the new type columns | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  | class TypesMigrateColumnsEzpublish extends \Aimeos\MW\Setup\Task\TypesMigrateColumns | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | 	private $tables = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  | 		'db-customer' => ['ezuser_list', 'ezuser_property'], | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  | 	]; | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 	private $constraints = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 		'db-customer' => ['ezuser_list' => 'unq_ezpli_sid_dm_rid_tid_pid', 'ezuser_property' => 'unq_ezppr_sid_tid_lid_value'], | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 	]; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 	private $migrations = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 		'db-customer' => [ | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | 			'ezuser_list' => 'UPDATE "ezuser_list" SET "type" = ( SELECT "code" FROM "ezuser_list_type" AS t WHERE t."id" = "typeid" AND t."domain" = "domain" LIMIT 1 ) WHERE "type" IS NULL', | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 			'ezuser_property' => 'UPDATE "ezuser_property" SET "type" = ( SELECT "code" FROM "ezuser_property_type" AS t WHERE t."id" = "typeid" AND t."domain" = "domain" LIMIT 1 ) WHERE "type" IS NULL', | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 		], | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 	]; | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  | 	 * Returns the list of task names which depends on this task. | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  | 	 * | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  | 	 * @return array List of task names | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	public function getPostDependencies() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	{ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 40 |  |  | 		return ['TablesCreateMShop']; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  | 	/** | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  | 	 * Executes the task | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	public function migrate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		$this->msg( sprintf( 'Add new type columns for FosUser' ), 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		$this->status( '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		foreach( $this->tables as $rname => $list ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 			$this->addColumn( $rname, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		$this->msg( sprintf( 'Drop old unique indexes for FosUser' ), 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		$this->status( '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		foreach( $this->constraints as $rname => $list ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			$this->dropIndex( $rname, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		$this->msg( sprintf( 'Migrate typeid to type for FosUser' ), 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		$this->status( '' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		foreach( $this->migrations as $rname => $list ) { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 67 |  |  | 			$this->migrateData( $rname, $list ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 70 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |  |