Skip to content

Commit 8f1401a

Browse files
author
Julien Neuhart
committed
Create a new migration for companies, users_companies and products tables
1 parent 21b1eef commit 8f1401a

File tree

8 files changed

+81
-50
lines changed

8 files changed

+81
-50
lines changed

src/api/migrations/Version20200424154558.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class Version20200424154558 extends AbstractMigration
1616
{
1717
public function getDescription(): string
1818
{
19-
return 'Create users, reset_password_tokens, companies, users_companies and products tables.';
19+
return 'Create users and reset_password_tokens tables.';
2020
}
2121

2222
public function up(Schema $schema): void
@@ -37,21 +37,6 @@ public function up(Schema $schema): void
3737
->column('user_id')->references('users')->notNull()->unique()
3838
->column('token')->string(255)->notNull()->unique()
3939
->column('valid_until')->datetimeImmutable()->notNull();
40-
41-
$db->table('companies')
42-
->column('id')->guid()->primaryKey()->comment('@UUID')->graphqlField()
43-
->column('name')->string(255)->notNull()->unique()->graphqlField()
44-
->column('website')->string(255)->null()->default(null)->graphqlField()
45-
->column('logo')->string(255)->null()->default(null)->graphqlField();
46-
47-
$db->junctionTable('users', 'companies')->graphqlField();
48-
49-
$db->table('products')
50-
->column('id')->guid()->primaryKey()->comment('@UUID')->graphqlField()
51-
->column('company_id')->references('companies')->notNull()->graphqlField()
52-
->column('name')->string(255)->notNull()->unique()->graphqlField()
53-
->column('price')->float()->notNull()->graphqlField()
54-
->column('pictures')->array()->null()->default(null)->graphqlField();
5540
}
5641

5742
public function down(Schema $schema): void
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
use RuntimeException;
10+
use TheCodingMachine\FluidSchema\TdbmFluidSchema;
11+
12+
/**
13+
* Auto-generated Migration: Please modify to your needs!
14+
*/
15+
final class Version20200619151658 extends AbstractMigration
16+
{
17+
public function getDescription(): string
18+
{
19+
return 'Create companies, users_companies and products tables.';
20+
}
21+
22+
public function up(Schema $schema): void
23+
{
24+
$db = new TdbmFluidSchema($schema);
25+
26+
$db->table('companies')
27+
->column('id')->guid()->primaryKey()->comment('@UUID')->graphqlField()
28+
->column('name')->string(255)->notNull()->unique()->graphqlField()
29+
->column('website')->string(255)->null()->default(null)->graphqlField()
30+
->column('logo')->string(255)->null()->default(null)->graphqlField();
31+
32+
$db->junctionTable('users', 'companies')->graphqlField();
33+
34+
$db->table('products')
35+
->column('id')->guid()->primaryKey()->comment('@UUID')->graphqlField()
36+
->column('company_id')->references('companies')->notNull()->graphqlField()
37+
->column('name')->string(255)->notNull()->unique()->graphqlField()
38+
->column('price')->float()->notNull()->graphqlField()
39+
->column('pictures')->array()->null()->default(null)->graphqlField();
40+
}
41+
42+
public function down(Schema $schema): void
43+
{
44+
throw new RuntimeException('Never rollback a migration!');
45+
}
46+
}

src/api/src/Domain/Dao/Generated/BaseCompanyDao.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public function setDefaultSort(string $defaultSort) : void
220220
public function findOneByName(string $name, array $additionalTablesFetch = []) : ?\App\Domain\Model\Company
221221
{
222222
$filter = [
223-
'name' => $name,
224-
];
223+
'name' => $name,
224+
];
225225
return $this->findOne($filter, [], $additionalTablesFetch);
226226
}
227-
}
227+
}

src/api/src/Domain/Dao/Generated/BaseDoctrineMigrationVersionDao.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ public function setDefaultSort(string $defaultSort) : void
208208
{
209209
$this->defaultSort = $defaultSort;
210210
}
211-
}
211+
}

src/api/src/Domain/Dao/Generated/BaseProductDao.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public function setDefaultSort(string $defaultSort) : void
220220
public function findOneByName(string $name, array $additionalTablesFetch = []) : ?\App\Domain\Model\Product
221221
{
222222
$filter = [
223-
'name' => $name,
224-
];
223+
'name' => $name,
224+
];
225225
return $this->findOne($filter, [], $additionalTablesFetch);
226226
}
227-
}
227+
}

src/api/src/Domain/Dao/Generated/BaseResetPasswordTokenDao.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ public function setDefaultSort(string $defaultSort) : void
218218
public function findOneByToken(string $token, array $additionalTablesFetch = []) : ?\App\Domain\Model\ResetPasswordToken
219219
{
220220
$filter = [
221-
'token' => $token,
222-
];
221+
'token' => $token,
222+
];
223223
return $this->findOne($filter, [], $additionalTablesFetch);
224224
}
225-
}
225+
}

src/api/src/Domain/Dao/Generated/BaseUserDao.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ public function setDefaultSort(string $defaultSort) : void
220220
public function findOneByEmail(string $email, array $additionalTablesFetch = []) : ?\App\Domain\Model\User
221221
{
222222
$filter = [
223-
'email' => $email,
224-
];
223+
'email' => $email,
224+
];
225225
return $this->findOne($filter, [], $additionalTablesFetch);
226226
}
227-
}
227+
}

src/api/src/Domain/Dao/Generated/DaoFactory.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@ class DaoFactory
2020
private $container = null;
2121

2222
/**
23-
* @var \App\Infrastructure\Dao\CompanyDao|null
23+
* @var \App\Domain\Dao\CompanyDao|null
2424
*/
2525
private $companyDao = null;
2626

2727
/**
28-
* @var \App\Infrastructure\Dao\DoctrineMigrationVersionDao|null
28+
* @var \App\Domain\Dao\DoctrineMigrationVersionDao|null
2929
*/
3030
private $doctrineMigrationVersionDao = null;
3131

3232
/**
33-
* @var \App\Infrastructure\Dao\ProductDao|null
33+
* @var \App\Domain\Dao\ProductDao|null
3434
*/
3535
private $productDao = null;
3636

3737
/**
38-
* @var \App\Infrastructure\Dao\ResetPasswordTokenDao|null
38+
* @var \App\Domain\Dao\ResetPasswordTokenDao|null
3939
*/
4040
private $resetPasswordTokenDao = null;
4141

4242
/**
43-
* @var \App\Infrastructure\Dao\UserDao|null
43+
* @var \App\Domain\Dao\UserDao|null
4444
*/
4545
private $userDao = null;
4646

@@ -49,73 +49,73 @@ public function __construct(\Psr\Container\ContainerInterface $container)
4949
$this->container = $container;
5050
}
5151

52-
public function getCompanyDao() : \App\Infrastructure\Dao\CompanyDao
52+
public function getCompanyDao() : \App\Domain\Dao\CompanyDao
5353
{
5454
if (!$this->companyDao) {
55-
$this->companyDao = $this->container->get('App\\Infrastructure\\Dao\\CompanyDao');
55+
$this->companyDao = $this->container->get('App\\Domain\\Dao\\CompanyDao');
5656
}
5757

5858
return $this->companyDao;
5959
}
6060

61-
public function setCompanyDao(\App\Infrastructure\Dao\CompanyDao $companyDao) : void
61+
public function setCompanyDao(\App\Domain\Dao\CompanyDao $companyDao) : void
6262
{
6363
$this->companyDao = $companyDao;
6464
}
6565

66-
public function getDoctrineMigrationVersionDao() : \App\Infrastructure\Dao\DoctrineMigrationVersionDao
66+
public function getDoctrineMigrationVersionDao() : \App\Domain\Dao\DoctrineMigrationVersionDao
6767
{
6868
if (!$this->doctrineMigrationVersionDao) {
69-
$this->doctrineMigrationVersionDao = $this->container->get('App\\Infrastructure\\Dao\\DoctrineMigrationVersionDao');
69+
$this->doctrineMigrationVersionDao = $this->container->get('App\\Domain\\Dao\\DoctrineMigrationVersionDao');
7070
}
7171

7272
return $this->doctrineMigrationVersionDao;
7373
}
7474

75-
public function setDoctrineMigrationVersionDao(\App\Infrastructure\Dao\DoctrineMigrationVersionDao $doctrineMigrationVersionDao) : void
75+
public function setDoctrineMigrationVersionDao(\App\Domain\Dao\DoctrineMigrationVersionDao $doctrineMigrationVersionDao) : void
7676
{
7777
$this->doctrineMigrationVersionDao = $doctrineMigrationVersionDao;
7878
}
7979

80-
public function getProductDao() : \App\Infrastructure\Dao\ProductDao
80+
public function getProductDao() : \App\Domain\Dao\ProductDao
8181
{
8282
if (!$this->productDao) {
83-
$this->productDao = $this->container->get('App\\Infrastructure\\Dao\\ProductDao');
83+
$this->productDao = $this->container->get('App\\Domain\\Dao\\ProductDao');
8484
}
8585

8686
return $this->productDao;
8787
}
8888

89-
public function setProductDao(\App\Infrastructure\Dao\ProductDao $productDao) : void
89+
public function setProductDao(\App\Domain\Dao\ProductDao $productDao) : void
9090
{
9191
$this->productDao = $productDao;
9292
}
9393

94-
public function getResetPasswordTokenDao() : \App\Infrastructure\Dao\ResetPasswordTokenDao
94+
public function getResetPasswordTokenDao() : \App\Domain\Dao\ResetPasswordTokenDao
9595
{
9696
if (!$this->resetPasswordTokenDao) {
97-
$this->resetPasswordTokenDao = $this->container->get('App\\Infrastructure\\Dao\\ResetPasswordTokenDao');
97+
$this->resetPasswordTokenDao = $this->container->get('App\\Domain\\Dao\\ResetPasswordTokenDao');
9898
}
9999

100100
return $this->resetPasswordTokenDao;
101101
}
102102

103-
public function setResetPasswordTokenDao(\App\Infrastructure\Dao\ResetPasswordTokenDao $resetPasswordTokenDao) : void
103+
public function setResetPasswordTokenDao(\App\Domain\Dao\ResetPasswordTokenDao $resetPasswordTokenDao) : void
104104
{
105105
$this->resetPasswordTokenDao = $resetPasswordTokenDao;
106106
}
107107

108-
public function getUserDao() : \App\Infrastructure\Dao\UserDao
108+
public function getUserDao() : \App\Domain\Dao\UserDao
109109
{
110110
if (!$this->userDao) {
111-
$this->userDao = $this->container->get('App\\Infrastructure\\Dao\\UserDao');
111+
$this->userDao = $this->container->get('App\\Domain\\Dao\\UserDao');
112112
}
113113

114114
return $this->userDao;
115115
}
116116

117-
public function setUserDao(\App\Infrastructure\Dao\UserDao $userDao) : void
117+
public function setUserDao(\App\Domain\Dao\UserDao $userDao) : void
118118
{
119119
$this->userDao = $userDao;
120120
}
121-
}
121+
}

0 commit comments

Comments
 (0)