Skip to content

Commit

Permalink
Merge pull request #83 from neighborhoods/KOJO-149-state-transition-c…
Browse files Browse the repository at this point in the history
…hange-migration

KOJO-149 | State Transition Change migration
  • Loading branch information
mucha55 committed Oct 2, 2019
2 parents c43d79f + 77963e1 commit 685b1d3
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Db/Setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
calls:
- [addVersion, ["@db.setup.schema.version.1_0_0"]]
- [addVersion, ["@db.setup.schema.version.2_0_0"]]
- [addVersion, ["@db.setup.schema.version.3_0_0"]]
db.setup:
public: false
alias: neighborhoods.kojo.db.setup
32 changes: 32 additions & 0 deletions src/Db/Setup/Schema/Version_3_0_0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\Kojo\Db\Setup\Schema;

use Doctrine\DBAL\Types\Type;
use Neighborhoods\Kojo\Db\Schema\VersionAbstract;
use Neighborhoods\Kojo\Db\Schema\VersionInterface;
use Neighborhoods\Kojo\Doctrine\Connection\DecoratorInterface;
use Neighborhoods\Kojo\JobStateChangeInterface;
use Neighborhoods\Kojo\JobStateChange;

class Version_3_0_0 extends VersionAbstract
{
protected function _assembleSchemaChanges(): VersionInterface
{
$connectionDecoratorRepository = $this->_getDoctrineConnectionDecoratorRepository();
$createSchema = $connectionDecoratorRepository->createSchema(DecoratorInterface::ID_SCHEMA);
$createTable = $createSchema->createTable(JobStateChange\RepositoryInterface::TABLE_NAME);
$createTable->addColumn(JobStateChangeInterface::PROP_ID, Type::BIGINT,
[
'autoincrement' => true,
'unsigned' => true
]
);
$createTable->setPrimaryKey([JobStateChangeInterface::PROP_ID]);
$createTable->addColumn(JobStateChangeInterface::PROP_DATA, Type::JSON);
$this->_setCreateTable($createTable);

return $this;
}
}
8 changes: 8 additions & 0 deletions src/Db/Setup/Schema/Version_3_0_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
neighborhoods.kojo.db.setup.schema.version.3_0_0:
class: Neighborhoods\Kojo\Db\Setup\Schema\Version_3_0_0
calls:
- [setDoctrineConnectionDecoratorRepository, ["@doctrine.connection.decorator.repository"]]
- [setTableName, ["@=constant(\"\\\\Neighborhoods\\\\Kojo\\\\JobStateChange\\\\RepositoryInterface::TABLE_NAME\")"]]
db.setup.schema.version.3_0_0:
alias: neighborhoods.kojo.db.setup.schema.version.3_0_0
1 change: 1 addition & 0 deletions src/Db/TearDown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
public: false
class: Neighborhoods\Kojo\Db\TearDown
calls:
- [addVersion, ["@db.tear_down.schema.version.6_0_0"]]
- [addVersion, ["@db.tear_down.schema.version.5_0_0"]]
- [addVersion, ["@db.tear_down.schema.version.4_0_0"]]
- [addVersion, ["@db.tear_down.schema.version.3_0_0"]]
Expand Down
18 changes: 18 additions & 0 deletions src/Db/TearDown/Schema/Version_6_0_0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);

namespace Neighborhoods\Kojo\Db\TearDown\Schema;

use Neighborhoods\Kojo\Db\Schema\VersionAbstract;
use Neighborhoods\Kojo\Db\Schema\VersionInterface;
use Neighborhoods\Kojo\JobStateChange;

class Version_6_0_0 extends VersionAbstract
{
protected function _assembleSchemaChanges(): VersionInterface
{
$this->setTableName(JobStateChange\RepositoryInterface::TABLE_NAME);

return $this;
}
}
7 changes: 7 additions & 0 deletions src/Db/TearDown/Schema/Version_6_0_0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
neighborhoods.kojo.db.tear_down.schema.version.6_0_0:
class: Neighborhoods\Kojo\Db\TearDown\Schema\Version_6_0_0
calls:
- [setDoctrineConnectionDecoratorRepository, ["@doctrine.connection.decorator.repository"]]
db.tear_down.schema.version.6_0_0:
alias: neighborhoods.kojo.db.tear_down.schema.version.6_0_0

0 comments on commit 685b1d3

Please sign in to comment.