Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix the June 2013 migrations on PagodaBox
Browse files Browse the repository at this point in the history
Signed-off-by: Max Fierke <[email protected]>
  • Loading branch information
maxfierke committed Jul 1, 2013
1 parent ad128e5 commit 077c1d4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
26 changes: 21 additions & 5 deletions app/DoctrineMigrations/Version20130616122810.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,27 @@ public function up(Schema $schema)
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");

$this->addSql("ALTER TABLE os_user DROP FOREIGN KEY FK_7BB0CD52BF396750");
$this->addSql("ALTER TABLE os_clock ADD uid INT DEFAULT NULL");
$this->addSql("ALTER TABLE os_clock ADD CONSTRAINT FK_34E85465539B0606 FOREIGN KEY (uid) REFERENCES os_user (id)");
$this->addSql("UPDATE os_clock SET uid = id");
$this->addSql("CREATE UNIQUE INDEX UNIQ_34E85465539B0606 ON os_clock (uid)");
$tables = $schema->getTables();
foreach ($tables as $table) {
if ($table->getName() === "os_user") {
if ($table->hasForeignKey('FK_7BB0CD52BF396750')) {
$this->addSql("ALTER TABLE os_user DROP FOREIGN KEY FK_7BB0CD52BF396750");
}
} else if ($table->getName() === "os_clock") {
if (!$table->hasColumn("uid")) {
$this->addSql("ALTER TABLE os_clock ADD uid INT DEFAULT NULL");
$this->addSql("UPDATE os_clock SET uid = id");
}

if (!$table->hasForeignKey('FK_34E85465539B0606')) {
$this->addSql("ALTER TABLE os_clock ADD CONSTRAINT FK_34E85465539B0606 FOREIGN KEY (uid) REFERENCES os_user (id)");
}

if (!$table->hasIndex('UNIQ_34E85465539B0606')) {
$this->addSql("CREATE UNIQUE INDEX UNIQ_34E85465539B0606 ON os_clock (uid)");
}
}
}
}

public function down(Schema $schema)
Expand Down
14 changes: 12 additions & 2 deletions app/DoctrineMigrations/Version20130616165301.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ public function up(Schema $schema)
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");

$this->addSql("ALTER TABLE os_settings ADD massEmail VARCHAR(255) DEFAULT NULL");
if ($schema->hasTable('os_settings')) {
$table = $schema->getTable('os_settings');
if (!$table->hasColumn('massEmail')) {
$this->addSql("ALTER TABLE os_settings ADD massEmail VARCHAR(255) DEFAULT NULL");
}
}
}

public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");

$this->addSql("ALTER TABLE os_settings DROP massEmail");
if ($schema->hasTable('os_settings')) {
$table = $schema->getTable('os_settings');
if (!$table->hasColumn('massEmail')) {
$this->addSql("ALTER TABLE os_settings DROP massEmail");
}
}
}
}

0 comments on commit 077c1d4

Please sign in to comment.