1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOS User Util package. |
5
|
|
|
* |
6
|
|
|
* (c) Jean-Bernard Addor |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FosUserUtil\Doctrine\DBAL; |
13
|
|
|
|
14
|
|
|
use Doctrine\DBAL\Schema\Schema; |
15
|
|
|
|
16
|
|
|
class SchemaBuilder |
17
|
|
|
{ |
18
|
|
|
protected $schema; |
19
|
|
|
|
20
|
2 |
|
public function __construct(Schema $schema) |
21
|
|
|
{ |
22
|
2 |
|
$this->schema = $schema; |
23
|
2 |
|
} |
24
|
|
|
|
25
|
1 |
|
public function userTable() |
26
|
|
|
{ |
27
|
1 |
|
$UserTable = $this->schema->createTable('http_user'); |
28
|
1 |
|
$UserTable->addColumn('uuid', 'guid'); |
29
|
1 |
|
$UserTable->setPrimaryKey(['uuid']); |
30
|
1 |
|
$UserTable->addColumn('username', 'string', ['length' => 180]); |
31
|
1 |
|
$UserTable->addColumn('username_canonical', 'string', ['length' => 180]); |
32
|
1 |
|
$UserTable->addUniqueIndex(['username_canonical'], 'username_canonical_unique_index'); // name probably not needed |
33
|
1 |
|
$UserTable->addColumn('email', 'string', ['length' => 180]); |
34
|
1 |
|
$UserTable->addColumn('email_canonical', 'string', ['length' => 180]); |
35
|
1 |
|
$UserTable->addUniqueIndex(['email_canonical'], 'email_canonical_unique_index'); // name probably not needed |
36
|
1 |
|
$UserTable->addColumn('enabled', 'boolean'); |
37
|
1 |
|
$UserTable->addColumn('salt', 'string', ['notnull' => false]); // 'length' => 255 |
38
|
1 |
|
$UserTable->addColumn('password', 'string'); // 'length' => 255 |
39
|
1 |
|
$UserTable->addColumn('last_login', 'datetime', ['notnull' => false]); |
40
|
1 |
|
$UserTable->addColumn('confirmation_token', 'string', ['length' => 180, 'notnull' => false]); |
41
|
1 |
|
$UserTable->addUniqueIndex(['confirmation_token'], 'confirmation_token_unique_index'); // name probably not needed |
42
|
1 |
|
$UserTable->addColumn('password_requested_at', 'datetime', ['notnull' => false]); |
43
|
1 |
|
$UserTable->addColumn('roles', 'array'); |
44
|
|
|
|
45
|
1 |
|
return $UserTable; |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
// https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/config/doctrine-mapping/User.orm.xml |
50
|
|
|
|