-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated readme, added migration and language files
- Loading branch information
bidi
committed
Apr 30, 2020
1 parent
febce97
commit ca1d5b8
Showing
9 changed files
with
2,039 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore | ||
cache |
110 changes: 110 additions & 0 deletions
110
data/database/migrations/20200416084037_default_schema.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
use Frontend\User\Entity\User; | ||
use Frontend\User\Entity\UserResetPassword; | ||
|
||
class DefaultSchema extends AbstractMigration | ||
{ | ||
protected array $fkCascade = ['delete' => 'CASCADE', 'update' => 'CASCADE']; | ||
|
||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html | ||
* | ||
* The following commands can be used in this method and Phinx will | ||
* automatically reverse them when rolling back: | ||
* | ||
* createTable | ||
* renameTable | ||
* addColumn | ||
* addCustomColumn | ||
* renameColumn | ||
* addIndex | ||
* addForeignKey | ||
* | ||
* Any other destructive changes will result in an error when trying to | ||
* rollback the migration. | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function change() | ||
{ | ||
$this->table('user', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('identity', 'string', ['null' => false, 'limit' => 100]) | ||
->addColumn('password', 'string', ['null' => false, 'limit' => 100]) | ||
->addColumn('status', 'enum', | ||
[ | ||
'default' => User::STATUS_PENDING, | ||
'values' => User::STATUSES | ||
] | ||
) | ||
->addColumn('isDeleted', 'enum', | ||
[ | ||
'default' => User::IS_DELETED_NO, | ||
'values' => [User::IS_DELETED_YES, User::IS_DELETED_NO] | ||
] | ||
) | ||
->addColumn('hash', 'string', ['null' => false, 'limit' => 100]) | ||
->addTimestamps('created', 'updated') | ||
->addIndex(['identity'], ['name' => 'identity', 'unique' => true]) | ||
->create(); | ||
|
||
$this->table('user_detail', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('firstName', 'string', ['null' => true, 'limit' => 255]) | ||
->addColumn('lastName', 'string', ['null' => true, 'limit' => 255]) | ||
->addTimestamps('created', 'updated') | ||
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade) | ||
->create(); | ||
|
||
$this->table('user_avatar', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('name', 'string', ['null' => false, 'limit' => 255]) | ||
->addTimestamps('created', 'updated') | ||
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade) | ||
->create(); | ||
|
||
$this->table('user_role', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('name', 'string', ['null' => false, 'limit' => 150]) | ||
->addTimestamps('created', 'updated') | ||
->addIndex(['name'], ['name' => 'name', 'unique' => true]) | ||
->create(); | ||
|
||
$this->table('user_roles', ['id' => false, 'primary_key' => ['userUuid', 'roleUuid']]) | ||
->addColumn('userUuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('roleUuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addTimestamps('created', 'updated') | ||
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade) | ||
->addForeignKey('roleUuid', 'user_role', 'uuid', $this->fkCascade) | ||
->create(); | ||
|
||
$this->table('user_reset_password', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['null' => false, 'limit' => 16]) | ||
->addColumn('userUuid', 'binary', ['null' => true, 'limit' => 16]) | ||
->addColumn('hash', 'string', ['null' => false, 'limit' => 100]) | ||
->addColumn( | ||
'status', | ||
'enum', [ | ||
'null' => false, | ||
'default' => UserResetPassword::STATUS_REQUESTED, | ||
'values' => UserResetPassword::STATUSES | ||
] | ||
) | ||
->addColumn('expires', 'timestamp', ['null' => true]) | ||
->addTimestamps('created', 'updated') | ||
->addIndex(['userUuid'], ['unique' => false]) | ||
->addIndex(['hash'], ['unique' => true]) | ||
->addForeignKey('userUuid', 'user', 'uuid', $this->fkCascade) | ||
->create(); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
data/database/migrations/20200416154725_contact_message.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class ContactMessage extends AbstractMigration | ||
{ | ||
/** | ||
* Change Method. | ||
* | ||
* Write your reversible migrations using this method. | ||
* | ||
* More information on writing migrations is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html | ||
* | ||
* The following commands can be used in this method and Phinx will | ||
* automatically reverse them when rolling back: | ||
* | ||
* createTable | ||
* renameTable | ||
* addColumn | ||
* addCustomColumn | ||
* renameColumn | ||
* addIndex | ||
* addForeignKey | ||
* | ||
* Any other destructive changes will result in an error when trying to | ||
* rollback the migration. | ||
* | ||
* Remember to call "create()" or "update()" and NOT "save()" when working | ||
* with the Table class. | ||
*/ | ||
public function change() | ||
{ | ||
$this->table('contact_message', ['id' => false, 'primary_key' => 'uuid', 'collation' => 'utf8mb4_general_ci']) | ||
->addColumn('uuid', 'binary', ['limit' => 16]) | ||
->addColumn('email', 'string', ['limit' => 150]) | ||
->addColumn('name', 'string', ['limit' => 150]) | ||
->addColumn('subject', 'text') | ||
->addColumn('message', 'text') | ||
->addColumn( | ||
'platform', | ||
'enum', | ||
[ | ||
'values' => [ | ||
'website', | ||
'designer', | ||
'admin' | ||
], | ||
'default' => 'website' | ||
] | ||
) | ||
->addTimestamps('created', 'updated') | ||
->addIndex(['email']) | ||
->create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Data\Database\Seeds; | ||
|
||
use Phinx\Seed\AbstractSeed; | ||
use Ramsey\Uuid\Codec\OrderedTimeCodec; | ||
use Ramsey\Uuid\Uuid; | ||
use Ramsey\Uuid\UuidFactory; | ||
|
||
class RoleSeeder extends AbstractSeed | ||
{ | ||
/** | ||
* Run Method. | ||
* | ||
* Write your database seeder using this method. | ||
* | ||
* More information on writing seeders is available here: | ||
* http://docs.phinx.org/en/latest/seeding.html | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function run() | ||
{ | ||
$uuidFactory = $this->getUuidGenerator(); | ||
|
||
$role = $this->table('user_role'); | ||
$role->insert( | ||
[ | ||
[ | ||
'uuid' => $uuidFactory->uuid1()->getBytes(), | ||
'name' => 'admin' | ||
], | ||
[ | ||
'uuid' => $uuidFactory->uuid1()->getBytes(), | ||
'name' => 'user' | ||
], | ||
[ | ||
'uuid' => $uuidFactory->uuid1()->getBytes(), | ||
'name' => 'guest' | ||
], | ||
] | ||
)->save(); | ||
} | ||
|
||
/** | ||
* @return UuidFactory | ||
*/ | ||
protected function getUuidGenerator() | ||
{ | ||
/** @var UuidFactory $factory */ | ||
$factory = clone Uuid::getFactory(); | ||
$codec = new OrderedTimeCodec($factory->getUuidBuilder()); | ||
$factory->setCodec($codec); | ||
|
||
return $factory; | ||
} | ||
} |
Empty file.
Binary file not shown.
Oops, something went wrong.