Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Mar 23, 2010
0 parents commit 8f198ef
Show file tree
Hide file tree
Showing 17 changed files with 2,284 additions and 0 deletions.
480 changes: 480 additions & 0 deletions README.markdown

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions lib/DoctrineExtensions/Migrations/AbstractMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace DoctrineExtensions\Migrations;

use Doctrine\DBAL\Schema\Schema,
DoctrineExtensions\Migrations\Configuration\Configuration,
DoctrineExtensions\Migrations\Version;

/**
* Abstract class for all users migration classes to extend from.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
abstract class AbstractMigration
{
/** The Doctrine\DBAL\Connection instance we are migrating */
protected $_connection;

/** Reference to the SchemaManager instance referened by $_connection */
protected $_sm;

/** Reference to the DatabasePlatform instance referenced by $_conection */
protected $_platform;

/** CLI Printer instance used for useful output about your migration */
protected $_printer;

/** Reference to the Version instance representing this migration */
protected $_version;

public function __construct(Version $version)
{
$configuration = $version->getConfiguration();
$this->_connection = $configuration->getConnection();
$this->_sm = $this->_connection->getSchemaManager();
$this->_platform = $this->_connection->getDatabasePlatform();
$this->_printer = $configuration->getPrinter();
$this->_version = $version;
}

abstract public function up(Schema $schema);
abstract public function down(Schema $schema);

protected function _announce($message)
{
$this->_version->announce($message);
}

protected function _addSchemaChangesSql(Schema $schema)
{
return $this->_version->migrateSchema($schema);
}

protected function _addSql($sql)
{
return $this->_version->addSql($sql);
}

protected function _throwIrreversibleMigrationException($msg = null)
{
throw new IrreversibleMigrationException($msg);
}

public function preUp(Schema $schema)
{
}

public function postUp(Schema $schema)
{
}

public function preDown(Schema $schema)
{
}

public function postDown(Schema $schema)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace DoctrineExtensions\Migrations\Configuration;

use DoctrineExtensions\Migrations\MigrationsException;

/**
* Abstract Migration Configuration class for loading configuration information
* from a configuration file (xml or yml).
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
abstract class AbstractFileConfiguration extends Configuration
{
/** Whether or not the configuration file has been loaded yet or not */
private $_loaded = false;

/**
* Load the information from the passed configuration file
*
* @param string $file The path to the configuration file
* @return void
* @throws MigrationException $exception Throws exception if configuration file was already loaded
*/
public function load($file)
{
if ($this->_loaded) {
throw MigrationsException::configurationFileAlreadyLoaded();
}
$this->_load($file);
$this->_loaded = true;
}

/**
* Abstract method that each file configuration driver must implement to
* load the given configuration file whether it be xml, yaml, etc. or something
* else.
*
* @param string $file
* @return void
*/
abstract protected function _load($file);
}
Loading

0 comments on commit 8f198ef

Please sign in to comment.