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\Core;
|
|
|
|
|
2020-01-06 15:57:10 -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;
|
|
|
|
|
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);
|
|
|
|
|
2020-01-29 03:53:06 -06:00
|
|
|
$builder->setTable(determineTableName('visit_locations', $emConfig));
|
2020-01-29 03:06:42 -06:00
|
|
|
|
|
|
|
$builder->createField('id', Types::BIGINT)
|
|
|
|
->columnName('id')
|
|
|
|
->makePrimaryKey()
|
|
|
|
->generatedValue('IDENTITY')
|
|
|
|
->option('unsigned', true)
|
2020-01-06 15:31:00 -06:00
|
|
|
->build();
|
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$columns = [
|
|
|
|
'country_code' => 'countryCode',
|
|
|
|
'country_name' => 'countryName',
|
|
|
|
'region_name' => 'regionName',
|
|
|
|
'city_name' => 'cityName',
|
|
|
|
'timezone' => 'timezone',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($columns as $columnName => $fieldName) {
|
2022-01-10 07:37:44 -06:00
|
|
|
fieldWithUtf8Charset($builder->createField($fieldName, Types::STRING), $emConfig)
|
2020-01-29 03:06:42 -06:00
|
|
|
->columnName($columnName)
|
|
|
|
->nullable()
|
|
|
|
->build();
|
|
|
|
}
|
|
|
|
|
|
|
|
$builder->createField('latitude', Types::FLOAT)
|
|
|
|
->columnName('lat')
|
|
|
|
->nullable(false)
|
|
|
|
->build();
|
2020-01-06 15:31:00 -06:00
|
|
|
|
2020-01-29 03:06:42 -06:00
|
|
|
$builder->createField('longitude', Types::FLOAT)
|
|
|
|
->columnName('lon')
|
|
|
|
->nullable(false)
|
|
|
|
->build();
|
2020-03-23 14:37:45 -05:00
|
|
|
|
|
|
|
$builder->createField('isEmpty', Types::BOOLEAN)
|
|
|
|
->columnName('is_empty')
|
|
|
|
->option('default', false)
|
|
|
|
->nullable(false)
|
|
|
|
->build();
|
2020-01-29 03:06:42 -06:00
|
|
|
};
|