| @@ 29-74 (lines=46) @@ | ||
| 26 | /** |
|
| 27 | * Auto-generated Migration: Please modify to your needs! |
|
| 28 | */ |
|
| 29 | class Version20141125173004 extends AbstractMigration implements ContainerAwareInterface |
|
| 30 | { |
|
| 31 | /** |
|
| 32 | * @var ContainerInterface |
|
| 33 | */ |
|
| 34 | private $container; |
|
| 35 | ||
| 36 | public function setContainer(ContainerInterface $container = null) |
|
| 37 | { |
|
| 38 | $this->container = $container; |
|
| 39 | } |
|
| 40 | ||
| 41 | public function up(Schema $schema) |
|
| 42 | { |
|
| 43 | $gatewaySchema = $this->getGatewaySchema(); |
|
| 44 | $middlewareUser = $this->getMiddlewareUser(); |
|
| 45 | ||
| 46 | // this up() migration is auto-generated, please modify it to your needs |
|
| 47 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
| 48 | ||
| 49 | $this->addSql(sprintf('CREATE TABLE %s.saml_entity (entity_id VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, configuration LONGTEXT NOT NULL, PRIMARY KEY(entity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', $gatewaySchema)); |
|
| 50 | $this->addSql(sprintf("GRANT DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity TO %s", $gatewaySchema, $middlewareUser)); |
|
| 51 | } |
|
| 52 | ||
| 53 | public function down(Schema $schema) |
|
| 54 | { |
|
| 55 | $gatewaySchema = $this->getGatewaySchema(); |
|
| 56 | $middlewareUser = $this->getMiddlewareUser(); |
|
| 57 | ||
| 58 | // this down() migration is auto-generated, please modify it to your needs |
|
| 59 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
| 60 | ||
| 61 | $this->addSql(sprintf("REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.saml_entity FROM %s", $gatewaySchema, $middlewareUser)); |
|
| 62 | $this->addSql(sprintf('DROP TABLE %s.saml_entity', $gatewaySchema)); |
|
| 63 | } |
|
| 64 | ||
| 65 | private function getGatewaySchema() |
|
| 66 | { |
|
| 67 | return $this->container->getParameter('database_gateway_name'); |
|
| 68 | } |
|
| 69 | ||
| 70 | private function getMiddlewareUser() |
|
| 71 | { |
|
| 72 | return $this->container->getParameter('database_middleware_user'); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| @@ 13-67 (lines=55) @@ | ||
| 10 | /** |
|
| 11 | * Auto-generated Migration: Please modify to your needs! |
|
| 12 | */ |
|
| 13 | class Version20141209150426 extends AbstractMigration implements ContainerAwareInterface |
|
| 14 | { |
|
| 15 | /** |
|
| 16 | * @var ContainerInterface |
|
| 17 | */ |
|
| 18 | private $container; |
|
| 19 | ||
| 20 | public function setContainer(ContainerInterface $container = null) |
|
| 21 | { |
|
| 22 | $this->container = $container; |
|
| 23 | } |
|
| 24 | ||
| 25 | public function up(Schema $schema) |
|
| 26 | { |
|
| 27 | $gatewaySchema = $this->getGatewaySchema(); |
|
| 28 | $middlewareUser = $this->getMiddlewareUser(); |
|
| 29 | ||
| 30 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
| 31 | ||
| 32 | $this->addSql(sprintf( |
|
| 33 | 'CREATE TABLE %s.second_factor (identity_id VARCHAR(36) NOT NULL, name_id VARCHAR(200) NOT NULL, institution VARCHAR(200) NOT NULL, second_factor_id VARCHAR(36) NOT NULL, second_factor_type VARCHAR(50) NOT NULL, second_factor_identifier VARCHAR(100) NOT NULL, INDEX idx_secondfactor_nameid (name_id), PRIMARY KEY(identity_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', |
|
| 34 | $gatewaySchema |
|
| 35 | )); |
|
| 36 | $this->addSql(sprintf( |
|
| 37 | 'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.second_factor TO %s', |
|
| 38 | $gatewaySchema, |
|
| 39 | $middlewareUser |
|
| 40 | )); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function down(Schema $schema) |
|
| 44 | { |
|
| 45 | $gatewaySchema = $this->getGatewaySchema(); |
|
| 46 | $middlewareUser = $this->getMiddlewareUser(); |
|
| 47 | ||
| 48 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
|
| 49 | ||
| 50 | $this->addSql(sprintf( |
|
| 51 | 'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.second_factor FROM %s', |
|
| 52 | $gatewaySchema, |
|
| 53 | $middlewareUser |
|
| 54 | )); |
|
| 55 | $this->addSql('DROP TABLE second_factor'); |
|
| 56 | } |
|
| 57 | ||
| 58 | private function getGatewaySchema() |
|
| 59 | { |
|
| 60 | return $this->container->getParameter('database_gateway_name'); |
|
| 61 | } |
|
| 62 | ||
| 63 | private function getMiddlewareUser() |
|
| 64 | { |
|
| 65 | return $this->container->getParameter('database_middleware_user'); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||