2018-12-16 05:08:03 -06:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2018-12-16 05:08:03 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Shlinkio\Shlink\Rest;
|
|
|
|
|
2020-01-06 16:08:14 -06:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2018-12-16 05:08:03 -06:00
|
|
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
2020-01-29 03:06:42 -06:00
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
2019-08-11 06:44:42 -05:00
|
|
|
use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType;
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
return static function (ClassMetadata $metadata): void {
|
|
|
|
$builder = new ClassMetadataBuilder($metadata);
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->setTable('api_keys');
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('id', Types::BIGINT)
|
|
|
|
->makePrimaryKey()
|
|
|
|
->generatedValue('IDENTITY')
|
|
|
|
->option('unsigned', true)
|
|
|
|
->build();
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('key', Types::STRING)
|
|
|
|
->columnName('`key`')
|
|
|
|
->unique()
|
|
|
|
->build();
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('expirationDate', ChronosDateTimeType::CHRONOS_DATETIME)
|
|
|
|
->columnName('expiration_date')
|
|
|
|
->nullable()
|
|
|
|
->build();
|
2018-12-16 05:08:03 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('enabled', Types::BOOLEAN)
|
|
|
|
->build();
|
|
|
|
};
|