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