Changeset 33248
- Timestamp:
- 12/11/11 16:31:52 (1 year ago)
- Files:
-
- plugins/sfSyncContentPlugin/branches/1.0 (modified) (1 prop)
- plugins/sfSyncContentPlugin/branches/1.0/README (modified) (1 diff)
- plugins/sfSyncContentPlugin/branches/1.0/lib/task/mysqldumpTask.class.php (modified) (2 diffs)
- plugins/sfSyncContentPlugin/branches/1.0/lib/task/synccontentTask.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSyncContentPlugin/branches/1.0
- Property svn:ignore set to
.README.swp
- Property svn:ignore set to
plugins/sfSyncContentPlugin/branches/1.0/README
r24693 r33248 87 87 # If you use P'unk Avenue stuff 88 88 - "data/pk_writable" 89 90 There is also an option to ignore specified database tables. Call this with 91 92 symfony project:sync-content frontend dev to prod@staging --ignore-tables=table1,table2 93 94 The target of the sync will drop and rebuild its database in this scenario so 95 that you don't trigger any 500 errors when navigating to the site. 89 96 90 97 == About Those Pesky Password Prompts == plugins/sfSyncContentPlugin/branches/1.0/lib/task/mysqldumpTask.class.php
r22583 r33248 21 21 new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'doctrine'), 22 22 // add your own options here 23 new sfCommandOption('ignore-tables', null, sfCommandOption::PARAMETER_OPTIONAL, 'Comma-separated list of tables from the remote database to ignore'), 23 24 )); 24 25 … … 41 42 $conn = $args['connection']; 42 43 } 43 $params = sfSyncContentTools::shellDatabaseParams(sfSyncContentTools::getDatabaseParams($this->configuration, $conn)); 44 $dbparams = sfSyncContentTools::getDatabaseParams($this->configuration, $conn); 45 $params = sfSyncContentTools::shellDatabaseParams($dbparams); 46 47 // set up the ignore flag 48 $ignoreFlag = ''; 49 if (isset($options['ignore-tables']) && !empty($options['ignore-tables'])) 50 { 51 foreach(explode(',', $options['ignore-tables']) as $ignoreTable) 52 { 53 $ignoreFlag .= ' ' . escapeshellarg('--ignore-table=' . $dbparams['dbname'] . '.' . $ignoreTable) . ' '; 54 } 55 } 44 56 45 57 // Right to stdout for the convenience of the remote ssh connection from 46 58 // sync-content 47 system("mysqldump --skip-opt --add-drop-table --create-options " . 48 "--disable-keys --extended-insert --set-charset $params ", $result); 59 $command = "mysqldump --skip-opt --add-drop-table --create-options " . 60 "--disable-keys --extended-insert --set-charset $params $ignoreFlag"; 61 system($command, $result); 49 62 50 63 if ($result != 0) plugins/sfSyncContentPlugin/branches/1.0/lib/task/synccontentTask.class.php
r22882 r33248 32 32 'The remote environment and site. The site name must be defined in properties.ini'))); 33 33 34 $this->addOptions(array( 35 new sfCommandOption('ignore-tables', null, sfCommandOption::PARAMETER_OPTIONAL, 'Comma-separated list of tables from the remote database to ignore'), 36 )); 37 34 38 $this->namespace = 'project'; 35 39 $this->name = 'sync-content'; … … 102 106 $this->sshPort = $data['port'] + 0; 103 107 } 104 108 109 $ignoreTables = (!empty($options['ignore-tables']))? '--ignore-tables=' . $options['ignore-tables'] : ''; 105 110 $binary = $_SERVER['SCRIPT_FILENAME']; 106 111 // A further simplification: use the subsidiary tasks locally too. This resolves issues with the … … 108 113 if ($direction == 'to') 109 114 { 110 $cmd = "$binary project:mysql-dump --application=$application --env=$env | " . $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-load --application=$application --env=$envRemote"); 115 if (!empty($options['ignore-tables'])) 116 { 117 $this->_content_sync_remote_system($pathRemote, "$binary doctrine:drop-db --no-confirmation; $binary doctrine:create-db; $binary doctrine:build-sql; $binary doctrine:insert-sql;"); 118 } 119 $cmd = "$binary project:mysql-dump --application=$application --env=$env $ignoreTables | " . $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-load --application=$application --env=$envRemote"); 111 120 $this->_content_sync_system($cmd); 112 121 } 113 122 else 114 123 { 115 $cmd = $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-dump --application=$application --env=$envRemote") . " | $binary project:mysql-load --application=$application --env=$env"; 124 if (!empty($options['ignore-tables'])) 125 { 126 $this->_content_sync_system("$binary doctrine:drop-db --no-confirmation; $binary doctrine:create-db; $binary doctrine:build-sql; $binary doctrine:insert-sql;"); 127 } 128 $cmd = $this->_content_sync_build_remote_cmd($pathRemote, "./symfony project:mysql-dump --application=$application --env=$envRemote $ignoreTables") . " | $binary project:mysql-load --application=$application --env=$env"; 116 129 $this->_content_sync_system($cmd); 117 130 }