2019-09-30 12:42:27 -05:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2019-09-30 12:42:27 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Shlinkio\Shlink\Core;
|
|
|
|
|
2020-01-06 16:08:14 -06:00
|
|
|
use Doctrine\DBAL\Types\Types;
|
2019-09-30 12:42:27 -05:00
|
|
|
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;
|
2020-01-29 03:06:42 -06:00
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
2019-09-30 12:42:27 -05:00
|
|
|
|
2020-01-29 03:53:06 -06:00
|
|
|
return static function (ClassMetadata $metadata, array $emConfig): void {
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder = new ClassMetadataBuilder($metadata);
|
2019-09-30 12:42:27 -05:00
|
|
|
|
2020-09-27 02:53:12 -05:00
|
|
|
$builder->setTable(determineTableName('domains', $emConfig))
|
|
|
|
->setCustomRepositoryClass(Domain\Repository\DomainRepository::class);
|
2019-09-30 12:42:27 -05:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('id', Types::BIGINT)
|
|
|
|
->columnName('id')
|
|
|
|
->makePrimaryKey()
|
|
|
|
->generatedValue('IDENTITY')
|
|
|
|
->option('unsigned', true)
|
|
|
|
->build();
|
2019-09-30 12:42:27 -05:00
|
|
|
|
2022-01-10 07:37:44 -06:00
|
|
|
fieldWithUtf8Charset($builder->createField('authority', Types::STRING), $emConfig)
|
2020-01-29 03:06:42 -06:00
|
|
|
->unique()
|
|
|
|
->build();
|
2021-07-21 02:28:21 -05:00
|
|
|
|
2022-01-10 07:37:44 -06:00
|
|
|
fieldWithUtf8Charset($builder->createField('baseUrlRedirect', Types::STRING), $emConfig)
|
2021-07-21 02:28:21 -05:00
|
|
|
->columnName('base_url_redirect')
|
|
|
|
->nullable()
|
|
|
|
->build();
|
|
|
|
|
2022-01-10 07:37:44 -06:00
|
|
|
fieldWithUtf8Charset($builder->createField('regular404Redirect', Types::STRING), $emConfig)
|
2021-07-21 02:28:21 -05:00
|
|
|
->columnName('regular_not_found_redirect')
|
|
|
|
->nullable()
|
|
|
|
->build();
|
|
|
|
|
2022-01-10 07:37:44 -06:00
|
|
|
fieldWithUtf8Charset($builder->createField('invalidShortUrlRedirect', Types::STRING), $emConfig)
|
2021-07-21 02:28:21 -05:00
|
|
|
->columnName('invalid_short_url_redirect')
|
|
|
|
->nullable()
|
|
|
|
->build();
|
2020-01-29 03:06:42 -06:00
|
|
|
};
|