Author: david
Date: Fri May 4 14:29:15 2012
New Revision: 11638
Log:
Add a no-backup option. Start work on upgrade code
Modified:
trunk/lib/task/migrate/arUpgradeSqlTask.class.php
Modified: trunk/lib/task/migrate/arUpgradeSqlTask.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgradeSqlTask.class.php Fri May 4 13:37:14
2012 (r11637)
+++ trunk/lib/task/migrate/arUpgradeSqlTask.class.php Fri May 4 14:29:15
2012 (r11638)
@@ -29,7 +29,8 @@
{
protected
$initialVersion,
- $targetVersion;
+ $targetVersion,
+ $upgraders = array();
/**
* @see sfBaseTask
@@ -53,7 +54,7 @@
new sfCommandOption('application', null,
sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true),
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED,
'The environment', 'cli'),
new sfCommandOption('connection', null,
sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
- new sfCommandOption('no-confirmation', null,
sfCommandOption::PARAMETER_OPTIONAL, 'Skip confirmation', null),
+ new sfCommandOption('no-backup', 'B', sfCommandOption::PARAMETER_NONE,
'Don\'t backup database', null),
));
}
@@ -72,8 +73,8 @@
$this->initialVersion = QubitPdo::fetchColumn($sql);
- // A bug in the migration script for Release 1.1 left the version="62"
- // instead of "75", so we need to check if the user is upgrading from 1.1
+ // A bug in the migration script for Release 1.1 left the version=62
+ // instead of 75, so we need to check if the user is upgrading from 1.1
// or 1.2
if (62 == intval($this->initialVersion))
{
@@ -99,14 +100,17 @@
}
// Attempt to backup database (MySQL only)
- $backupName = $this->backupDatabase($database);
+ if (!$options['no-backup'])
+ {
+ $backupName = $this->backupDatabase($database);
+ }
// If backup failed, warn user to backup database manually
if (!isset($backupName) && !$this->askConfirmation(array(
- 'WARNING: Could not back-up your database!',
+ 'WARNING: Your database has not been backed up!',
'Please back-up your database manually before you proceed.',
'',
- 'Have you done a manual backup and are ready to proceed? (y/N)'),
+ 'Have you done a manual backup and wish to proceed? (y/N)'),
'QUESTION_LARGE',
false))
{
@@ -116,6 +120,14 @@
}
// TODO Do upgrade
+ // Find all the upgrade classes in lib/task/migrate
+ foreach
(sfFinder::type('file')->maxdepth(0)->name('arUpgrader*.class.php')->in(sfConfig::get('sf_lib_dir').'/task/migrate')
as $filename)
+ {
+ $className = ucfirst(str_replace($filename, '.class.php', ''));
+ $this->upgraders[constant($className, '::INIT_VERSION')] = $className;
+ }
+
+ var_dump($this->upgraders);
$this->logSection('upgrade-sql', sprintf('Upgrading from version %s',
$this->initialVersion));
}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.