| @@ 32-96 (lines=65) @@ | ||
| 29 | /** |
|
| 30 | * @package Limoncello\Passport |
|
| 31 | */ |
|
| 32 | class MySqlPassportMigration implements MigrationInterface |
|
| 33 | { |
|
| 34 | use DatabaseSchemaMigrationTrait; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var ContainerInterface |
|
| 38 | */ |
|
| 39 | private $container; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @inheritdoc |
|
| 43 | */ |
|
| 44 | public function init(ContainerInterface $container): MigrationInterface |
|
| 45 | { |
|
| 46 | $this->container = $container; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return void |
|
| 53 | * |
|
| 54 | * @throws DBALException |
|
| 55 | */ |
|
| 56 | public function migrate(): void |
|
| 57 | { |
|
| 58 | $this->createDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return void |
|
| 63 | * |
|
| 64 | * @throws DBALException |
|
| 65 | */ |
|
| 66 | public function rollback(): void |
|
| 67 | { |
|
| 68 | $this->removeDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return ContainerInterface |
|
| 73 | */ |
|
| 74 | protected function getContainer(): ContainerInterface |
|
| 75 | { |
|
| 76 | assert($this->container !== null); |
|
| 77 | ||
| 78 | return $this->container; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return Connection |
|
| 83 | */ |
|
| 84 | protected function getConnection(): Connection |
|
| 85 | { |
|
| 86 | return $this->getContainer()->get(Connection::class); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @return DatabaseSchemaInterface |
|
| 91 | */ |
|
| 92 | protected function getDatabaseSchema(): DatabaseSchemaInterface |
|
| 93 | { |
|
| 94 | return $this->getContainer()->get(DatabaseSchemaInterface::class); |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| @@ 32-94 (lines=63) @@ | ||
| 29 | /** |
|
| 30 | * @package Limoncello\Passport |
|
| 31 | */ |
|
| 32 | class PassportMigration implements MigrationInterface |
|
| 33 | { |
|
| 34 | use DatabaseSchemaMigrationTrait; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var ContainerInterface |
|
| 38 | */ |
|
| 39 | private $container; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @inheritdoc |
|
| 43 | */ |
|
| 44 | public function init(ContainerInterface $container): MigrationInterface |
|
| 45 | { |
|
| 46 | $this->container = $container; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return void |
|
| 53 | * |
|
| 54 | * @throws DBALException |
|
| 55 | */ |
|
| 56 | public function migrate(): void |
|
| 57 | { |
|
| 58 | $this->createDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return void |
|
| 63 | */ |
|
| 64 | public function rollback(): void |
|
| 65 | { |
|
| 66 | $this->removeDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @return ContainerInterface |
|
| 71 | */ |
|
| 72 | protected function getContainer(): ContainerInterface |
|
| 73 | { |
|
| 74 | assert($this->container !== null); |
|
| 75 | ||
| 76 | return $this->container; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return Connection |
|
| 81 | */ |
|
| 82 | protected function getConnection(): Connection |
|
| 83 | { |
|
| 84 | return $this->getContainer()->get(Connection::class); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * @return DatabaseSchemaInterface |
|
| 89 | */ |
|
| 90 | protected function getDatabaseSchema(): DatabaseSchemaInterface |
|
| 91 | { |
|
| 92 | return $this->getContainer()->get(DatabaseSchemaInterface::class); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| @@ 32-96 (lines=65) @@ | ||
| 29 | /** |
|
| 30 | * @package Limoncello\Passport |
|
| 31 | */ |
|
| 32 | class PostgreSqlPassportMigration implements MigrationInterface |
|
| 33 | { |
|
| 34 | use DatabaseSchemaMigrationTrait; |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @var ContainerInterface |
|
| 38 | */ |
|
| 39 | private $container; |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @inheritdoc |
|
| 43 | */ |
|
| 44 | public function init(ContainerInterface $container): MigrationInterface |
|
| 45 | { |
|
| 46 | $this->container = $container; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return void |
|
| 53 | * |
|
| 54 | * @throws DBALException |
|
| 55 | */ |
|
| 56 | public function migrate(): void |
|
| 57 | { |
|
| 58 | $this->createDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return void |
|
| 63 | * |
|
| 64 | * @throws DBALException |
|
| 65 | */ |
|
| 66 | public function rollback(): void |
|
| 67 | { |
|
| 68 | $this->removeDatabaseSchema($this->getConnection(), $this->getDatabaseSchema()); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @return ContainerInterface |
|
| 73 | */ |
|
| 74 | protected function getContainer(): ContainerInterface |
|
| 75 | { |
|
| 76 | assert($this->container !== null); |
|
| 77 | ||
| 78 | return $this->container; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @return Connection |
|
| 83 | */ |
|
| 84 | protected function getConnection(): Connection |
|
| 85 | { |
|
| 86 | return $this->getContainer()->get(Connection::class); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * @return DatabaseSchemaInterface |
|
| 91 | */ |
|
| 92 | protected function getDatabaseSchema(): DatabaseSchemaInterface |
|
| 93 | { |
|
| 94 | return $this->getContainer()->get(DatabaseSchemaInterface::class); |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||