Add DoctrineMigration Patch

This commit is contained in:
Nicolas Le Goff
2013-11-07 18:05:10 +01:00
parent 431d2532e2
commit 99d4895f57
37 changed files with 705 additions and 84 deletions

View File

@@ -46,7 +46,6 @@ $app = new CLI("
under certain conditions; type `about:license' for details.\n\n"
. ' SETUP', Version::getName() . ' ' . Version::getNumber());
$app->register(new DoctrineMigrationServiceProvider());
$app->command(new \module_console_aboutAuthors('about:authors'));

View File

@@ -14,4 +14,4 @@ $app = new \Alchemy\Phrasea\Application();
return $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app['EM']->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($app['EM'])
));
));

View File

@@ -0,0 +1,65 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Alchemy\Phrasea\Application;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version320alpha4 extends AbstractMigration
{
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'.");
$app = new Application();
$rsm = new ResultSetMapping();
$rsm->addScalarResult('Name', 'Name');
$found = false;
foreach ($app['EM']->createNativeQuery('SHOW TABLE STATUS', $rsm)->getResult() as $row) {
if (strcmp('feeds', $row['Name'])) {
$found = true;
break;
}
}
if ($found) {
$this->addSql("RENAME TABLE `feeds` TO `feeds_backup`");
}
$this->addSql("CREATE TABLE IF NOT EXISTS Feeds (id INT AUTO_INCREMENT NOT NULL, public TINYINT(1) NOT NULL, icon_url TINYINT(1) NOT NULL, base_id INT DEFAULT NULL, title VARCHAR(128) NOT NULL, subtitle VARCHAR(1024) DEFAULT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedPublishers (id INT AUTO_INCREMENT NOT NULL, feed_id INT DEFAULT NULL, usr_id INT NOT NULL, owner TINYINT(1) NOT NULL, created_on DATETIME NOT NULL, INDEX IDX_31AFAB251A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedEntries (id INT AUTO_INCREMENT NOT NULL, publisher_id INT DEFAULT NULL, feed_id INT DEFAULT NULL, title VARCHAR(128) NOT NULL, subtitle VARCHAR(128) NOT NULL, author_name VARCHAR(128) NOT NULL, author_email VARCHAR(128) NOT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, INDEX IDX_5FC892F940C86FCE (publisher_id), INDEX IDX_5FC892F951A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedItems (id INT AUTO_INCREMENT NOT NULL, entry_id INT DEFAULT NULL, record_id INT NOT NULL, sbas_id INT NOT NULL, ord INT NOT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, INDEX IDX_7F9CDFA6BA364942 (entry_id), UNIQUE INDEX lookup_unique_idx (entry_id, sbas_id, record_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedTokens (id INT AUTO_INCREMENT NOT NULL, feed_id INT DEFAULT NULL, usr_id INT NOT NULL, value VARCHAR(12) DEFAULT NULL, INDEX IDX_9D1CA84851A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE FeedPublishers ADD CONSTRAINT FK_31AFAB251A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
$this->addSql("ALTER TABLE FeedEntries ADD CONSTRAINT FK_5FC892F940C86FCE FOREIGN KEY (publisher_id) REFERENCES FeedPublishers (id)");
$this->addSql("ALTER TABLE FeedEntries ADD CONSTRAINT FK_5FC892F951A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
$this->addSql("ALTER TABLE FeedItems ADD CONSTRAINT FK_7F9CDFA6BA364942 FOREIGN KEY (entry_id) REFERENCES FeedEntries (id)");
$this->addSql("ALTER TABLE FeedTokens ADD CONSTRAINT FK_9D1CA84851A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
}
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 FeedPublishers DROP FOREIGN KEY FK_31AFAB251A5BC03");
$this->addSql("ALTER TABLE FeedEntries DROP FOREIGN KEY FK_5FC892F951A5BC03");
$this->addSql("ALTER TABLE FeedTokens DROP FOREIGN KEY FK_9D1CA84851A5BC03");
$this->addSql("ALTER TABLE FeedEntries DROP FOREIGN KEY FK_5FC892F940C86FCE");
$this->addSql("ALTER TABLE FeedItems DROP FOREIGN KEY FK_7F9CDFA6BA364942");
$this->addSql("DROP TABLE Feeds");
$this->addSql("DROP TABLE FeedPublishers");
$this->addSql("DROP TABLE FeedEntries");
$this->addSql("DROP TABLE FeedItems");
$this->addSql("DROP TABLE FeedTokens");
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version360alpha1 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS Baskets (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(128) NOT NULL, description LONGTEXT DEFAULT NULL, usr_id INT NOT NULL, is_read TINYINT(1) NOT NULL, pusher_id INT DEFAULT NULL, archived TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS StoryWZ (id INT AUTO_INCREMENT NOT NULL, sbas_id INT NOT NULL, record_id INT NOT NULL, usr_id INT NOT NULL, created DATETIME NOT NULL, UNIQUE INDEX user_story (usr_id, sbas_id, record_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS ValidationSessions (id INT AUTO_INCREMENT NOT NULL, basket_id INT DEFAULT NULL, initiator_id INT NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, expires DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_5B9DFB061BE1FB52 (basket_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS ValidationDatas (id INT AUTO_INCREMENT NOT NULL, participant_id INT DEFAULT NULL, basket_element_id INT DEFAULT NULL, agreement TINYINT(1) DEFAULT NULL, note LONGTEXT DEFAULT NULL, updated DATETIME NOT NULL, INDEX IDX_70E84DDC9D1C3019 (participant_id), INDEX IDX_70E84DDCE989605 (basket_element_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS BasketElements (id INT AUTO_INCREMENT NOT NULL, basket_id INT DEFAULT NULL, record_id INT NOT NULL, sbas_id INT NOT NULL, ord INT NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_C0B7ECB71BE1FB52 (basket_id), UNIQUE INDEX unique_recordcle (basket_id, sbas_id, record_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS ValidationParticipants (id INT AUTO_INCREMENT NOT NULL, usr_id INT NOT NULL, is_aware TINYINT(1) NOT NULL, is_confirmed TINYINT(1) NOT NULL, can_agree TINYINT(1) NOT NULL, can_see_others TINYINT(1) NOT NULL, reminded DATETIME DEFAULT NULL, ValidationSession_id INT DEFAULT NULL, INDEX IDX_17850D7BF25B0F5B (ValidationSession_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE ValidationSessions ADD CONSTRAINT FK_5B9DFB061BE1FB52 FOREIGN KEY (basket_id) REFERENCES Baskets (id)");
$this->addSql("ALTER TABLE ValidationDatas ADD CONSTRAINT FK_70E84DDC9D1C3019 FOREIGN KEY (participant_id) REFERENCES ValidationParticipants (id)");
$this->addSql("ALTER TABLE ValidationDatas ADD CONSTRAINT FK_70E84DDCE989605 FOREIGN KEY (basket_element_id) REFERENCES BasketElements (id)");
$this->addSql("ALTER TABLE BasketElements ADD CONSTRAINT FK_C0B7ECB71BE1FB52 FOREIGN KEY (basket_id) REFERENCES Baskets (id)");
$this->addSql("ALTER TABLE ValidationParticipants ADD CONSTRAINT FK_17850D7BF25B0F5B FOREIGN KEY (ValidationSession_id) REFERENCES ValidationSessions (id)");
}
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 ValidationSessions DROP FOREIGN KEY FK_5B9DFB061BE1FB52");
$this->addSql("ALTER TABLE Orders DROP FOREIGN KEY FK_E283F8D81BE1FB52");
$this->addSql("ALTER TABLE BasketElements DROP FOREIGN KEY FK_C0B7ECB71BE1FB52");
$this->addSql("ALTER TABLE ValidationParticipants DROP FOREIGN KEY FK_17850D7BF25B0F5B");
$this->addSql("ALTER TABLE OrderElements DROP FOREIGN KEY FK_8C7066C88D9F6D38");
$this->addSql("ALTER TABLE ValidationDatas DROP FOREIGN KEY FK_70E84DDCE989605");
$this->addSql("ALTER TABLE ValidationDatas DROP FOREIGN KEY FK_70E84DDC9D1C3019");
$this->addSql("DROP TABLE Baskets");
$this->addSql("DROP TABLE StoryWZ");
$this->addSql("DROP TABLE ValidationSessions");
$this->addSql("DROP TABLE Orders");
$this->addSql("DROP TABLE ValidationDatas");
$this->addSql("DROP TABLE BasketElements");
$this->addSql("DROP TABLE ValidationParticipants");
$this->addSql("DROP TABLE OrderElements");
}
}

View File

@@ -0,0 +1,40 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version370alpha7 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS LazaretChecks (id INT AUTO_INCREMENT NOT NULL, lazaret_file_id INT DEFAULT NULL, checkClassname VARCHAR(512) NOT NULL, INDEX IDX_CE873ED44CF84ADD (lazaret_file_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS LazaretSessions (id INT AUTO_INCREMENT NOT NULL, usr_id INT DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS LazaretAttributes (id INT AUTO_INCREMENT NOT NULL, lazaret_file_id INT DEFAULT NULL, name VARCHAR(64) NOT NULL, value VARCHAR(2048) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_5FF72F9B4CF84ADD (lazaret_file_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS LazaretFiles (id INT AUTO_INCREMENT NOT NULL, lazaret_session_id INT DEFAULT NULL, filename VARCHAR(512) NOT NULL, thumbFilename VARCHAR(512) NOT NULL, originalName VARCHAR(256) NOT NULL, base_id INT NOT NULL, uuid VARCHAR(36) NOT NULL, sha256 VARCHAR(64) NOT NULL, forced TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_D30BD768EE187C01 (lazaret_session_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE LazaretChecks ADD CONSTRAINT FK_CE873ED44CF84ADD FOREIGN KEY (lazaret_file_id) REFERENCES LazaretFiles (id)");
$this->addSql("ALTER TABLE LazaretAttributes ADD CONSTRAINT FK_5FF72F9B4CF84ADD FOREIGN KEY (lazaret_file_id) REFERENCES LazaretFiles (id)");
$this->addSql("ALTER TABLE LazaretFiles ADD CONSTRAINT FK_D30BD768EE187C01 FOREIGN KEY (lazaret_session_id) REFERENCES LazaretSessions (id)");
}
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 LazaretFiles DROP FOREIGN KEY FK_D30BD768EE187C01");
$this->addSql("ALTER TABLE LazaretChecks DROP FOREIGN KEY FK_CE873ED44CF84ADD");
$this->addSql("ALTER TABLE LazaretAttributes DROP FOREIGN KEY FK_5FF72F9B4CF84ADD");
$this->addSql("DROP TABLE LazaretChecks");
$this->addSql("DROP TABLE LazaretSessions");
$this->addSql("DROP TABLE LazaretAttributes");
$this->addSql("DROP TABLE LazaretFiles");
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version370alpha8 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS Tasks (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, jobId VARCHAR(255) NOT NULL, settings LONGTEXT NOT NULL, completed TINYINT(1) NOT NULL, status VARCHAR(255) NOT NULL, crashed INT NOT NULL, single_run TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, last_execution DATETIME DEFAULT NULL, period INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
}
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("DROP TABLE Tasks");
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version380alpha11 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS SessionModules (id INT AUTO_INCREMENT NOT NULL, session_id INT DEFAULT NULL, module_id INT NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_BA36EF49613FECDF (session_id), UNIQUE INDEX unique_module (session_id, module_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS Sessions (id INT AUTO_INCREMENT NOT NULL, usr_id INT NOT NULL, user_agent VARCHAR(512) NOT NULL, ip_address VARCHAR(40) DEFAULT NULL, platform VARCHAR(128) DEFAULT NULL, browser_name VARCHAR(128) DEFAULT NULL, browser_version VARCHAR(32) DEFAULT NULL, screen_width INT DEFAULT NULL, screen_height INT DEFAULT NULL, token VARCHAR(128) DEFAULT NULL, nonce VARCHAR(16) DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, UNIQUE INDEX UNIQ_6316FF455F37A13B (token), INDEX usr_id (usr_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE SessionModules ADD CONSTRAINT FK_BA36EF49613FECDF FOREIGN KEY (session_id) REFERENCES Sessions (id)");
}
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 SessionModules DROP FOREIGN KEY FK_BA36EF49613FECDF");
$this->addSql("DROP TABLE SessionModules");
$this->addSql("DROP TABLE Sessions");
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version380alpha4 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS AuthFailures (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(128) NOT NULL, ip VARCHAR(128) DEFAULT NULL, locked TINYINT(1) NOT NULL, created DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
}
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("DROP TABLE AuthFailures");
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha1a extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS FtpCredential (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, usrId INT NOT NULL, active TINYINT(1) NOT NULL, address VARCHAR(128) NOT NULL, login VARCHAR(128) NOT NULL, password VARCHAR(128) NOT NULL, reception_folder VARCHAR(128) NOT NULL, repository_prefix_name VARCHAR(128) NOT NULL, passive TINYINT(1) NOT NULL, tls TINYINT(1) NOT NULL, max_retry INT NOT NULL, updated DATETIME NOT NULL, UNIQUE INDEX UNIQ_62DA9661A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE FtpCredential ADD CONSTRAINT FK_62DA9661A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
}
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("DROP TABLE FtpCredential");
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha1b extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS Orders (id INT AUTO_INCREMENT NOT NULL, basket_id INT DEFAULT NULL, usr_id INT NOT NULL, order_usage VARCHAR(2048) NOT NULL, todo INT DEFAULT NULL, deadline DATETIME NOT NULL, created_on DATETIME NOT NULL, UNIQUE INDEX UNIQ_E283F8D81BE1FB52 (basket_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS OrderElements (id INT AUTO_INCREMENT NOT NULL, order_id INT DEFAULT NULL, base_id INT NOT NULL, record_id INT NOT NULL, order_master_id INT DEFAULT NULL, deny TINYINT(1) DEFAULT NULL, INDEX IDX_8C7066C88D9F6D38 (order_id), UNIQUE INDEX unique_ordercle (base_id, record_id, order_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE Orders ADD CONSTRAINT FK_E283F8D81BE1FB52 FOREIGN KEY (basket_id) REFERENCES Baskets (id)");
$this->addSql("ALTER TABLE OrderElements ADD CONSTRAINT FK_8C7066C88D9F6D38 FOREIGN KEY (order_id) REFERENCES Orders (id)");
}
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 OrderElements DROP FOREIGN KEY FK_8C7066C88D9F6D38");
$this->addSql("DROP TABLE Orders");
$this->addSql("DROP TABLE OrderElements");
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha2 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS Users (id INT AUTO_INCREMENT NOT NULL, model_of INT DEFAULT NULL, login VARCHAR(128) NOT NULL, email VARCHAR(128) DEFAULT NULL, password VARCHAR(128) DEFAULT NULL, nonce VARCHAR(16) DEFAULT NULL, salted_password TINYINT(1) NOT NULL, first_name VARCHAR(64) NOT NULL, last_name VARCHAR(64) NOT NULL, gender VARCHAR(8) DEFAULT NULL, address LONGTEXT NOT NULL, city VARCHAR(64) NOT NULL, country VARCHAR(64) NOT NULL, zip_code VARCHAR(32) NOT NULL, geoname_id INT DEFAULT NULL, locale VARCHAR(8) DEFAULT NULL, timezone VARCHAR(128) NOT NULL, job VARCHAR(128) NOT NULL, activity VARCHAR(256) NOT NULL, company VARCHAR(64) NOT NULL, phone VARCHAR(32) NOT NULL, fax VARCHAR(32) NOT NULL, admin TINYINT(1) NOT NULL, guest TINYINT(1) NOT NULL, mail_notifications TINYINT(1) NOT NULL, request_notifications TINYINT(1) NOT NULL, ldap_created TINYINT(1) NOT NULL, last_model VARCHAR(64) DEFAULT NULL, push_list LONGTEXT NOT NULL, can_change_profil TINYINT(1) NOT NULL, can_change_ftp_profil TINYINT(1) NOT NULL, last_connection DATETIME DEFAULT NULL, mail_locked TINYINT(1) NOT NULL, deleted TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, UNIQUE INDEX UNIQ_D5428AEDC121714D (model_of), INDEX salted_password (salted_password), INDEX admin (admin), INDEX guest (guest), UNIQUE INDEX email_unique (email), UNIQUE INDEX login_unique (login), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE Users ADD CONSTRAINT FK_D5428AEDC121714D FOREIGN KEY (model_of) REFERENCES Users (id)");
}
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 Users DROP FOREIGN KEY FK_D5428AEDC121714D");
$this->addSql("DROP TABLE Users");
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha3 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS UserQueries (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, usr_id INT NOT NULL, query VARCHAR(256) NOT NULL, created DATETIME NOT NULL, INDEX IDX_5FB80D87A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE UserQueries ADD CONSTRAINT FK_5FB80D87A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
}
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("DROP TABLE UserQueries");
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha4 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS UserSettings (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, usr_id INT NOT NULL, name VARCHAR(64) NOT NULL, value VARCHAR(128) DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_2847E61CA76ED395 (user_id), UNIQUE INDEX unique_setting (user_id, name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE UserSettings ADD CONSTRAINT FK_2847E61CA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
}
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("DROP TABLE UserSettings");
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha5 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS UserNotificationSettings (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, usr_id INT NOT NULL, name VARCHAR(64) NOT NULL, value VARCHAR(128) DEFAULT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_CFF041AAA76ED395 (user_id), UNIQUE INDEX unique_index (user_id, name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE UserNotificationSettings ADD CONSTRAINT FK_CFF041AAA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)");
}
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("DROP TABLE UserNotificationSettings");
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha6 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS FtpExportElements (id INT AUTO_INCREMENT NOT NULL, export_id INT DEFAULT NULL, record_id INT NOT NULL, base_id INT NOT NULL, subdef VARCHAR(255) NOT NULL, filename VARCHAR(255) NOT NULL, folder VARCHAR(255) DEFAULT NULL, error TINYINT(1) NOT NULL, done TINYINT(1) NOT NULL, businessfields TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_7BF0AE1264CDAF82 (export_id), INDEX done (done), INDEX error (error), UNIQUE INDEX unique_ftp_export (export_id, base_id, record_id, subdef), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FtpExports (id INT AUTO_INCREMENT NOT NULL, crash INT NOT NULL, nbretry INT NOT NULL, mail LONGTEXT DEFAULT NULL, addr LONGTEXT NOT NULL, use_ssl TINYINT(1) NOT NULL, login LONGTEXT DEFAULT NULL, pwd LONGTEXT DEFAULT NULL, passif TINYINT(1) NOT NULL, destfolder LONGTEXT NOT NULL, sendermail LONGTEXT DEFAULT NULL, text_mail_sender LONGTEXT DEFAULT NULL, text_mail_receiver LONGTEXT DEFAULT NULL, usr_id INT NOT NULL, foldertocreate LONGTEXT DEFAULT NULL, logfile TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE FtpExportElements ADD CONSTRAINT FK_7BF0AE1264CDAF82 FOREIGN KEY (export_id) REFERENCES FtpExports (id)");
}
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 FtpExportElements DROP FOREIGN KEY FK_7BF0AE1264CDAF82");
$this->addSql("DROP TABLE FtpExportElements");
$this->addSql("DROP TABLE FtpExports");
}
}

View File

@@ -0,0 +1,68 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Alchemy\Phrasea\Application;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\Query\ResultSetMapping;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha7 extends AbstractMigration
{
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'.");
$app = new Application();
$rsm = new ResultSetMapping();
$rsm->addScalarResult('Name', 'Name');
$found = false;
foreach ($app['EM']->createNativeQuery('SHOW TABLE STATUS', $rsm)->getResult() as $row) {
if (strcmp('feeds', $row['Name'])) {
$found = true;
break;
}
}
if ($found) {
$this->addSql("RENAME TABLE `feeds` TO `feeds_backup`");
}
$this->addSql("CREATE TABLE IF NOT EXISTS Feeds (id INT AUTO_INCREMENT NOT NULL, public TINYINT(1) NOT NULL, icon_url TINYINT(1) NOT NULL, base_id INT DEFAULT NULL, title VARCHAR(128) NOT NULL, subtitle VARCHAR(1024) DEFAULT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedPublishers (id INT AUTO_INCREMENT NOT NULL, feed_id INT DEFAULT NULL, usr_id INT NOT NULL, owner TINYINT(1) NOT NULL, created_on DATETIME NOT NULL, INDEX IDX_31AFAB251A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS AggregateTokens (id INT AUTO_INCREMENT NOT NULL, usr_id INT NOT NULL, value VARCHAR(12) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedEntries (id INT AUTO_INCREMENT NOT NULL, publisher_id INT DEFAULT NULL, feed_id INT DEFAULT NULL, title VARCHAR(128) NOT NULL, subtitle VARCHAR(128) NOT NULL, author_name VARCHAR(128) NOT NULL, author_email VARCHAR(128) NOT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, INDEX IDX_5FC892F940C86FCE (publisher_id), INDEX IDX_5FC892F951A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedItems (id INT AUTO_INCREMENT NOT NULL, entry_id INT DEFAULT NULL, record_id INT NOT NULL, sbas_id INT NOT NULL, ord INT NOT NULL, created_on DATETIME NOT NULL, updated_on DATETIME NOT NULL, INDEX IDX_7F9CDFA6BA364942 (entry_id), UNIQUE INDEX lookup_unique_idx (entry_id, sbas_id, record_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE IF NOT EXISTS FeedTokens (id INT AUTO_INCREMENT NOT NULL, feed_id INT DEFAULT NULL, usr_id INT NOT NULL, value VARCHAR(12) DEFAULT NULL, INDEX IDX_9D1CA84851A5BC03 (feed_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE FeedPublishers ADD CONSTRAINT FK_31AFAB251A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
$this->addSql("ALTER TABLE FeedEntries ADD CONSTRAINT FK_5FC892F940C86FCE FOREIGN KEY (publisher_id) REFERENCES FeedPublishers (id)");
$this->addSql("ALTER TABLE FeedEntries ADD CONSTRAINT FK_5FC892F951A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
$this->addSql("ALTER TABLE FeedItems ADD CONSTRAINT FK_7F9CDFA6BA364942 FOREIGN KEY (entry_id) REFERENCES FeedEntries (id)");
$this->addSql("ALTER TABLE FeedTokens ADD CONSTRAINT FK_9D1CA84851A5BC03 FOREIGN KEY (feed_id) REFERENCES Feeds (id)");
}
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 FeedPublishers DROP FOREIGN KEY FK_31AFAB251A5BC03");
$this->addSql("ALTER TABLE FeedEntries DROP FOREIGN KEY FK_5FC892F951A5BC03");
$this->addSql("ALTER TABLE FeedTokens DROP FOREIGN KEY FK_9D1CA84851A5BC03");
$this->addSql("ALTER TABLE FeedEntries DROP FOREIGN KEY FK_5FC892F940C86FCE");
$this->addSql("ALTER TABLE FeedItems DROP FOREIGN KEY FK_7F9CDFA6BA364942");
$this->addSql("DROP TABLE Feeds");
$this->addSql("DROP TABLE FeedPublishers");
$this->addSql("DROP TABLE AggregateTokens");
$this->addSql("DROP TABLE FeedEntries");
$this->addSql("DROP TABLE FeedItems");
$this->addSql("DROP TABLE FeedTokens");
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Alchemy\Phrasea\Setup\DoctrineMigrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version390alpha8 extends AbstractMigration
{
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("CREATE TABLE IF NOT EXISTS Tasks (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, jobId VARCHAR(255) NOT NULL, settings LONGTEXT NOT NULL, completed TINYINT(1) NOT NULL, status VARCHAR(255) NOT NULL, crashed INT NOT NULL, single_run TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, last_execution DATETIME DEFAULT NULL, period INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
}
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("DROP TABLE Tasks");
}
}

View File

@@ -23,7 +23,6 @@ class PreSchemaUpgradeCollection
public function __construct()
{
$this->upgrades[] = new Upgrade39();
}
/**

View File

@@ -1,44 +0,0 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2013 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Setup\Version\PreSchemaUpgrade;
use Alchemy\Phrasea\Application;
use Doctrine\ORM\EntityManager;
class Upgrade39 implements PreSchemaUpgradeInterface
{
/**
* {@inheritdoc}
*/
public function apply(EntityManager $em)
{
$em->getConnection()->executeQuery('RENAME TABLE `feeds` TO `feeds_backup`');
}
/**
* {@inheritdoc}
*/
public function isApplyable(Application $app)
{
$rs = $app['phraseanet.appbox']->get_connection()->query('SHOW TABLE STATUS');
$found = false;
foreach ($rs as $row) {
if ('feeds' === $row['Name']) {
$found = true;
break;
}
}
return $found;
}
}

View File

@@ -10,6 +10,7 @@
*/
use Alchemy\Phrasea\Application;
use Doctrine\ORM\Tools\SchemaTool;
use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\Specification\Image as ImageSpecification;
use Symfony\Component\Filesystem\Filesystem;
@@ -304,16 +305,9 @@ class appbox extends base
$upgrader->add_steps_complete(1);
$upgrader->set_current_message(_('Creating new tables'));
//create schema
$app['phraseanet.pre-schema-upgrader']->apply($app);
if ($app['EM']->getConnection()->getDatabasePlatform()->supportsAlterTable()) {
$tool = new \Doctrine\ORM\Tools\SchemaTool($app['EM']);
$metas = $app['EM']->getMetadataFactory()->getAllMetadata();
$tool->updateSchema($metas, true);
}
$upgrader->add_steps_complete(1);
/**
@@ -388,6 +382,12 @@ class appbox extends base
$app['phraseanet.cache-service']->flushAll();
if ($app['EM']->getConnection()->getDatabasePlatform()->supportsAlterTable()) {
$tool = new SchemaTool($app['EM']);
$metas = $app['EM']->getMetadataFactory()->getAllMetadata();
$tool->updateSchema($metas, true);
}
$upgrader->add_steps_complete(1);
if (version::lt($from_version, '3.1')) {

View File

@@ -61,7 +61,10 @@ class patch_320alpha4b implements patchInterface
public function apply(base $appbox, Application $app)
{
$feeds = [];
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$feeds = array();
try {
$sql = 'ALTER TABLE `ssel` ADD `migrated` INT NOT NULL DEFAULT "0"';

View File

@@ -10,6 +10,8 @@
*/
use Alchemy\Phrasea\Application;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\DriverManager;
/**
*
@@ -55,7 +57,10 @@ class patch_360alpha1a implements patchInterface
public function apply(base $appbox, Application $app)
{
$tables = ['StoryWZ', 'ValidationDatas', 'ValidationParticipants', 'ValidationSessions', 'BasketElements', 'Baskets'];
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$tables = array('StoryWZ', 'ValidationDatas', 'ValidationParticipants', 'ValidationSessions', 'BasketElements', 'Baskets');
foreach ($tables as $table) {
$sql = 'DELETE FROM ' . $table;
@@ -67,8 +72,8 @@ class patch_360alpha1a implements patchInterface
$stories = [];
$sql = 'SELECT sbas_id, rid as record_id, usr_id
FROM ssel
WHERE temporaryType = "1"';
FROM ssel
WHERE temporaryType = "1"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
@@ -88,8 +93,9 @@ class patch_360alpha1a implements patchInterface
}
$sql = 'DELETE FROM ssel
WHERE temporaryType="1" AND record_id = :record_id
AND usr_id = :usr_id AND sbas_id = :sbas_id';
WHERE temporaryType="1" AND record_id = :record_id
AND usr_id = :usr_id AND sbas_id = :sbas_id';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($stories as $row) {
@@ -117,8 +123,7 @@ class patch_360alpha1a implements patchInterface
$sql = 'INSERT INTO Baskets
(
SELECT ssel_id as id, name, descript as description, usr_id, 1 as is_read
, pushFrom as pusher_id,
0 as archived, date as created, updater as updated
, pushFrom as pusher_id, 0 as archived, date as created, updater as updated
FROM ssel
WHERE temporaryType = "0"
)';
@@ -137,9 +142,9 @@ class patch_360alpha1a implements patchInterface
foreach ($rs as $row) {
$sql = 'SELECT c.sselcont_id, c.record_id, b.sbas_id
FROM sselcont c, bas b, ssel s
WHERE s.temporaryType = "0" AND b.base_id = c.base_id
AND c.ssel_id = :ssel_id AND s.ssel_id = c.ssel_id';
FROM sselcont c, bas b, ssel s
WHERE s.temporaryType = "0" AND b.base_id = c.base_id
AND c.ssel_id = :ssel_id AND s.ssel_id = c.ssel_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute([':ssel_id' => $row['ssel_id']]);
@@ -189,8 +194,8 @@ class patch_360alpha1a implements patchInterface
$sql = 'INSERT INTO ValidationSessions
(
SELECT null as id, v.ssel_id as basket_id ,created_on as created
,updated_on as updated ,expires_on as expires
,v.usr_id as initiator_id
,updated_on as updated ,expires_on as expires
,v.usr_id as initiator_id
FROM ssel s, validate v
WHERE v.ssel_id = s.ssel_id AND v.usr_id = s.usr_id
)';
@@ -202,11 +207,11 @@ class patch_360alpha1a implements patchInterface
$sql = 'INSERT INTO ValidationParticipants
(
SELECT v.id as id, v.usr_id
, 1 AS is_aware, confirmed as is_confirmed, 1 as can_agree
, can_see_others, last_reminder AS reminded
, vs.`id` AS ValidationSession_id
FROM validate v, ssel s, ValidationSessions vs
WHERE s.ssel_id = v.ssel_id AND vs.basket_id = v.ssel_id
, 1 AS is_aware, confirmed as is_confirmed, 1 as can_agree
, can_see_others, last_reminder AS reminded
, vs.`id` AS ValidationSession_id
FROM validate v, ssel s, ValidationSessions vs
WHERE s.ssel_id = v.ssel_id AND vs.basket_id = v.ssel_id
)';
$stmt = $appbox->get_connection()->prepare($sql);
@@ -214,21 +219,22 @@ class patch_360alpha1a implements patchInterface
$stmt->closeCursor();
$sql = 'SELECT usr_id, basket_id, p.id as participant_id
FROM ValidationParticipants p, ValidationSessions s
WHERE p.ValidationSession_Id = s.id';
FROM ValidationParticipants p, ValidationSessions s
WHERE p.ValidationSession_Id = s.id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$sql = 'INSERT INTO ValidationDatas (
SELECT d.id , :participant_id as participant_id, d.sselcont_id, d.agreement,
d.note, d.updated_on as updated
FROM validate v, validate_datas d, sselcont c
WHERE c.sselcont_id = d.sselcont_id AND v.id = d.validate_id
AND v.usr_id = :usr_id AND v.ssel_id = :basket_id
)';
$sql = 'INSERT INTO ValidationDatas
(
SELECT d.id , :participant_id as participant_id, d.sselcont_id, d.agreement
,d.note, d.updated_on as updated
FROM validate v, validate_datas d, sselcont c
WHERE c.sselcont_id = d.sselcont_id AND v.id = d.validate_id
AND v.usr_id = :usr_id AND v.ssel_id = :basket_id
)';
$stmt = $appbox->get_connection()->prepare($sql);
foreach ($rs as $row) {
$params = [
@@ -242,14 +248,14 @@ class patch_360alpha1a implements patchInterface
$stmt->closeCursor();
$sql = 'UPDATE ValidationDatas
SET agreement = NULL where agreement = "0"';
SET agreement = NULL where agreement = "0"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'UPDATE ValidationDatas
SET agreement = "0" where agreement = "-1"';
SET agreement = "0" where agreement = "-1"';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -59,6 +59,9 @@ class patch_370alpha7a implements patchInterface
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$conn = $appbox->get_connection();
try {

View File

@@ -65,7 +65,10 @@ class patch_370alpha8a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$ttasks = [];
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$ttasks = array();
$conn = $appbox->get_connection();
$sql = 'SELECT task_id, active, name, class, settings FROM task2 WHERE class=\'task_period_workflow01\'';
if (($stmt = $conn->prepare($sql)) !== FALSE) {

View File

@@ -50,6 +50,9 @@ class patch_380alpha11a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
try {
$sql = 'SELECT usr_id, user_agent, ip, platform, browser, app,
browser_version, screen, token, nonce, lastaccess, created_on

View File

@@ -49,6 +49,9 @@ class patch_380alpha4a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$conn = $app['phraseanet.appbox']->get_connection();
$sql = 'SELECT date, login, ip, locked FROM badlog ORDER BY id ASC';
$stmt = $conn->prepare($sql);

View File

@@ -49,6 +49,9 @@ class patch_390alpha1a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release . 'a');
$version->execute('up');
$conn = $app['phraseanet.appbox']->get_connection();
$sql = 'SELECT usr_id, activeFTP, addrFTP, loginFTP,
retryFTP, passifFTP, pwdFTP, destFTP, prefixFTPfolder

View File

@@ -51,6 +51,9 @@ class patch_390alpha1b implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release . 'b');
$version->execute('up');
$sql = 'DELETE FROM Orders';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -51,6 +51,9 @@ class patch_390alpha2a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM Users';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -49,6 +49,9 @@ class patch_390alpha3a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM UserQueries';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -49,6 +49,9 @@ class patch_390alpha4a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM UserSettings';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -49,6 +49,9 @@ class patch_390alpha5a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM UserNotificationSettings';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -51,6 +51,9 @@ class patch_390alpha6a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM FtpExports';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -54,6 +54,9 @@ class patch_390alpha7a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM Feeds';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

View File

@@ -49,6 +49,9 @@ class patch_390alpha8a implements patchInterface
*/
public function apply(base $appbox, Application $app)
{
$version = $app['doctrine-migration.configuration']->getVersion($this->release);
$version->execute('up');
$sql = 'DELETE FROM Tasks';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute();

50
lib/conf.d/migrations.yml Normal file
View File

@@ -0,0 +1,50 @@
name: Phraseanet Migrations
migrations_namespace: Alchemy\Phrasea\Setup\DoctrineMigrations
table_name: doctrine_migration_versions
migrations:
migration1:
version: 3.2.0-alpha.4
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version320alpha4
migration2:
version: 3.6.0-alpha.1
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version360alpha1
migration3:
version: 3.7.0-alpha.7
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version370alpha7
migration4:
version: 3.7.0-alpha.8
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version370alpha8
migration5:
version: 3.8.0-alpha.4
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version380alpha4
migration6:
version: 3.8.0-alpha.11
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version380alpha11
migration7:
version: 3.9.0-alpha.1a
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha1a
migration8:
version: 3.9.0-alpha.1b
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha1b
migration9:
version: 3.9.0-alpha.2
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha2
migration10:
version: 3.9.0-alpha.3
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha3
migration11:
version: 3.9.0-alpha.4
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha4
migration12:
version: 3.9.0-alpha.5
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha5
migration13:
version: 3.9.0-alpha.6
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha6
migration14:
version: 3.9.0-alpha.7
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha7
migration15:
version: 3.9.0-alpha.8
class: Alchemy\Phrasea\Setup\DoctrineMigrations\Version390alpha8

View File

@@ -0,0 +1,17 @@
<?php
namespace Alchemy\Tests\Phrasea\Core\CLIProvider;
class DoctrineMigrationServiceProviderTest extends ServiceProviderTestCase
{
public function provideServiceDescription()
{
return array(
array(
'Alchemy\Phrasea\Core\CLIProvider\ DoctrineMigrationServiceProvider',
'doctrine-migration.configuration',
'Doctrine\DBAL\Migrations\Configuration\YamlConfiguration'
)
);
}
}