diff --git a/databox/api/config/services.yaml b/databox/api/config/services.yaml index ca5706fab..f3036233b 100644 --- a/databox/api/config/services.yaml +++ b/databox/api/config/services.yaml @@ -20,6 +20,7 @@ services: string $databoxClientBaseUrl: '%env(DATABOX_CLIENT_URL)%' ApiPlatform\State\ProviderInterface $itemProvider: '@api_platform.doctrine.orm.state.item_provider' ApiPlatform\State\ProviderInterface $itemsProvider: '@api_platform.doctrine.orm.state.collection_provider' + bool $useAlias: '%elastica.use_alias%' _instanceof: Alchemy\Workflow\Executor\Action\ActionInterface: diff --git a/databox/api/migrations/Version20230925140946.php b/databox/api/migrations/Version20230925140946.php new file mode 100644 index 000000000..77ecc6c6e --- /dev/null +++ b/databox/api/migrations/Version20230925140946.php @@ -0,0 +1,242 @@ +addSql('ALTER TABLE alternate_url ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN alternate_url.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN asset.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset_data_template ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_data_template ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_data_template.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN asset_data_template.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset_file_version ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_file_version.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset_relationship ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_relationship ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_relationship.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN asset_relationship.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset_rendition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_rendition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_rendition.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN asset_rendition.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE attribute ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE attribute ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN attribute.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE attribute_class ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute_class.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE attribute_definition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE attribute_definition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute_definition.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN attribute_definition.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE collection ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE collection ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE collection ALTER deleted_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN collection.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN collection.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN collection.deleted_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE collection_asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN collection_asset.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE esindex_state ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE esindex_state ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN esindex_state.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN esindex_state.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE file ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE file ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN file.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN file.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE integration_data ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE integration_data ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN integration_data.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN integration_data.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE populate_pass ALTER ended_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE populate_pass ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN populate_pass.ended_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN populate_pass.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE rendition_class ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_class.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE rendition_definition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE rendition_definition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_definition.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN rendition_definition.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE rendition_rule ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE rendition_rule ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_rule.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN rendition_rule.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE tag ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE tag ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN tag.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN tag.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE tag_filter_rule ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE tag_filter_rule ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN tag_filter_rule.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN tag_filter_rule.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE template_attribute ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE template_attribute ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN template_attribute.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN template_attribute.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE user_preference ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE user_preference ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN user_preference.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN user_preference.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE webhook ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN webhook.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE webhook_log ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN webhook_log.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE workspace ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace ALTER deleted_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN workspace.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN workspace.deleted_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE workspace_env ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_env ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_env.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN workspace_env.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE workspace_integration ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_integration ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_integration.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN workspace_integration.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE workspace_secret ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_secret ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_secret.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN workspace_secret.updated_at IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE workspace_integration ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_integration ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_integration.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN workspace_integration.updated_at IS NULL'); + $this->addSql('ALTER TABLE esindex_state ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE esindex_state ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN esindex_state.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN esindex_state.updated_at IS NULL'); + $this->addSql('ALTER TABLE collection ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE collection ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE collection ALTER deleted_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN collection.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN collection.updated_at IS NULL'); + $this->addSql('COMMENT ON COLUMN collection.deleted_at IS NULL'); + $this->addSql('ALTER TABLE webhook ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN webhook.created_at IS NULL'); + $this->addSql('ALTER TABLE integration_data ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE integration_data ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN integration_data.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN integration_data.updated_at IS NULL'); + $this->addSql('ALTER TABLE tag_filter_rule ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE tag_filter_rule ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN tag_filter_rule.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN tag_filter_rule.updated_at IS NULL'); + $this->addSql('ALTER TABLE user_preference ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE user_preference ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN user_preference.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN user_preference.updated_at IS NULL'); + $this->addSql('ALTER TABLE attribute_class ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute_class.created_at IS NULL'); + $this->addSql('ALTER TABLE webhook_log ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN webhook_log.created_at IS NULL'); + $this->addSql('ALTER TABLE asset_rendition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_rendition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_rendition.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN asset_rendition.updated_at IS NULL'); + $this->addSql('ALTER TABLE tag ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE tag ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN tag.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN tag.updated_at IS NULL'); + $this->addSql('ALTER TABLE workspace ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace ALTER deleted_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN workspace.updated_at IS NULL'); + $this->addSql('COMMENT ON COLUMN workspace.deleted_at IS NULL'); + $this->addSql('ALTER TABLE template_attribute ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE template_attribute ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN template_attribute.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN template_attribute.updated_at IS NULL'); + $this->addSql('ALTER TABLE workspace_secret ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_secret ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_secret.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN workspace_secret.updated_at IS NULL'); + $this->addSql('ALTER TABLE rendition_class ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_class.created_at IS NULL'); + $this->addSql('ALTER TABLE populate_pass ALTER ended_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE populate_pass ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN populate_pass.ended_at IS NULL'); + $this->addSql('COMMENT ON COLUMN populate_pass.created_at IS NULL'); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS NULL'); + $this->addSql('ALTER TABLE rendition_definition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE rendition_definition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_definition.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN rendition_definition.updated_at IS NULL'); + $this->addSql('ALTER TABLE rendition_rule ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE rendition_rule ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN rendition_rule.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN rendition_rule.updated_at IS NULL'); + $this->addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS NULL'); + $this->addSql('ALTER TABLE asset_data_template ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_data_template ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_data_template.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN asset_data_template.updated_at IS NULL'); + $this->addSql('ALTER TABLE attribute_definition ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE attribute_definition ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute_definition.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN attribute_definition.updated_at IS NULL'); + $this->addSql('ALTER TABLE file ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE file ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN file.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN file.updated_at IS NULL'); + $this->addSql('ALTER TABLE attribute ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE attribute ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN attribute.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN attribute.updated_at IS NULL'); + $this->addSql('ALTER TABLE collection_asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN collection_asset.created_at IS NULL'); + $this->addSql('ALTER TABLE alternate_url ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN alternate_url.created_at IS NULL'); + $this->addSql('ALTER TABLE asset_relationship ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_relationship ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_relationship.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN asset_relationship.updated_at IS NULL'); + $this->addSql('ALTER TABLE workspace_env ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE workspace_env ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN workspace_env.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN workspace_env.updated_at IS NULL'); + $this->addSql('ALTER TABLE asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN asset.updated_at IS NULL'); + $this->addSql('ALTER TABLE asset_file_version ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_file_version.created_at IS NULL'); + } +} diff --git a/databox/api/src/Attribute/Type/DateTimeAttributeType.php b/databox/api/src/Attribute/Type/DateTimeAttributeType.php index c2112d431..c7bb546cd 100644 --- a/databox/api/src/Attribute/Type/DateTimeAttributeType.php +++ b/databox/api/src/Attribute/Type/DateTimeAttributeType.php @@ -33,11 +33,11 @@ public function getGroupValueLabel($value): ?string public function createFilterQuery(string $field, $value): AbstractQuery { - $startFloor = new \DateTime(); - $startFloor->setTimestamp((int) $value[0]); + $startFloor = (new \DateTimeImmutable()) + ->setTimestamp((int) $value[0]); - $endCeil = new \DateTime(); - $endCeil->setTimestamp((int) $value[1]); + $endCeil = (new \DateTimeImmutable()) + ->setTimestamp((int) $value[1]); return new Range($field, [ 'gte' => $startFloor->getTimestamp() * 1000, diff --git a/databox/api/src/Elasticsearch/Mapping/ElasticsearchClient.php b/databox/api/src/Elasticsearch/Mapping/ElasticsearchClient.php index eedaa38e0..e7dc4c13c 100644 --- a/databox/api/src/Elasticsearch/Mapping/ElasticsearchClient.php +++ b/databox/api/src/Elasticsearch/Mapping/ElasticsearchClient.php @@ -9,7 +9,10 @@ readonly class ElasticsearchClient { - public function __construct(private Client $client) + public function __construct( + private Client $client, + private bool $useAlias, + ) { } @@ -29,6 +32,10 @@ public function updateMapping(string $indexName, array $mapping): void */ public function getAliasedIndex(string $aliasName): ?string { + if (!$this->useAlias) { + return $aliasName; + } + $aliasesInfo = $this->client->request('_aliases', 'GET')->getData(); $aliasedIndexes = []; diff --git a/databox/api/src/Elasticsearch/Mapping/IndexMappingUpdater.php b/databox/api/src/Elasticsearch/Mapping/IndexMappingUpdater.php index 517e126c1..1dea51962 100644 --- a/databox/api/src/Elasticsearch/Mapping/IndexMappingUpdater.php +++ b/databox/api/src/Elasticsearch/Mapping/IndexMappingUpdater.php @@ -14,8 +14,13 @@ class IndexMappingUpdater { final public const NO_LOCALE = '_'; - public function __construct(private readonly ElasticsearchClient $client, private readonly Index $index, private readonly EntityManagerInterface $em, private readonly AttributeTypeRegistry $attributeTypeRegistry, private readonly FieldNameResolver $fieldNameResolver) - { + public function __construct( + private readonly ElasticsearchClient $client, + private readonly Index $index, + private readonly EntityManagerInterface $em, + private readonly AttributeTypeRegistry $attributeTypeRegistry, + private readonly FieldNameResolver $fieldNameResolver, + ) { } public function assignAttributeToMapping(array &$mapping, string $locale, AttributeDefinition $definition): void diff --git a/databox/api/src/Entity/FailedEvent.php b/databox/api/src/Entity/FailedEvent.php index 43b21d8b2..f4289dd07 100644 --- a/databox/api/src/Entity/FailedEvent.php +++ b/databox/api/src/Entity/FailedEvent.php @@ -24,11 +24,11 @@ class FailedEvent extends BaseFailedEvent protected $id; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] - private ?\DateTime $createdAt = null; + private ?\DateTimeImmutable $createdAt = null; public function __construct() { - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); } public function getId(): string @@ -36,7 +36,7 @@ public function getId(): string return $this->id->__toString(); } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } diff --git a/databox/api/src/Util/Time.php b/databox/api/src/Util/Time.php index 2e27e8990..a4742dc52 100644 --- a/databox/api/src/Util/Time.php +++ b/databox/api/src/Util/Time.php @@ -12,8 +12,8 @@ public static function time2string(int $time): string return '0 seconds'; } - $t1 = new \DateTime(); - $t2 = new \DateTime("+$time seconds"); + $t1 = new \DateTimeImmutable(); + $t2 = new \DateTimeImmutable("+$time seconds"); $diff = $t1->diff($t2); $units = [ 'days' => 'day', diff --git a/databox/client/src/components/App.tsx b/databox/client/src/components/App.tsx index 4a6a51465..9933b1626 100644 --- a/databox/client/src/components/App.tsx +++ b/databox/client/src/components/App.tsx @@ -94,7 +94,7 @@ export default function App() { switch (status) { case 401: toast.error(t('error.session_expired', 'Your session has expired')); - userContext.logout && userContext.logout(); + userContext.logout && userContext.logout(false); break; case 403: toast.error(t('error.http_unauthorized', 'Unauthorized')); diff --git a/databox/client/src/components/Root.tsx b/databox/client/src/components/Root.tsx index b8302b3dc..1b7dbdb4f 100644 --- a/databox/client/src/components/Root.tsx +++ b/databox/client/src/components/Root.tsx @@ -6,6 +6,12 @@ import {BrowserRouter} from "react-router-dom"; import ModalStack from "../hooks/useModalStack"; import UserPreferencesProvider from "./User/Preferences/UserPreferencesProvider"; import {oauthClient} from "../api/api-client"; +import {toast} from "react-toastify"; +import { + loginEventType, + logoutEventType, + sessionExpiredEventType, +} from 'react-ps'; type Props = {}; @@ -28,8 +34,11 @@ export default function Root({}: Props) { setUser(undefined); }; - oauthClient.registerListener('login', onLogin); - oauthClient.registerListener('logout', onLogout); + oauthClient.registerListener(loginEventType, onLogin); + oauthClient.registerListener(logoutEventType, onLogout); + oauthClient.registerListener(sessionExpiredEventType, async () => { + toast.warning('Session has expired') + }); if (oauthClient.isAuthenticated()) { onLogin(); @@ -38,13 +47,13 @@ export default function Root({}: Props) { } return () => { - oauthClient.unregisterListener('login', onLogin); - oauthClient.unregisterListener('logout', onLogout); + oauthClient.unregisterListener(loginEventType, onLogin); + oauthClient.unregisterListener(logoutEventType, onLogout); } }, [setUser]); - const logout = React.useCallback(() => { - oauthClient.logout(); + const logout = React.useCallback((redirectUri: string|false = '/') => { + oauthClient.logout(redirectUri); }, []); return void | undefined; + logout?: (redirectUri?: string |false) => void | undefined; } export const UserContext = React.createContext({}); diff --git a/expose/api/src/Migrations/Version20230925141126.php b/expose/api/src/Migrations/Version20230925141126.php new file mode 100644 index 000000000..470219e7f --- /dev/null +++ b/expose/api/src/Migrations/Version20230925141126.php @@ -0,0 +1,34 @@ +addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS NULL'); + } +} diff --git a/lib/js/react-ps/src/index.ts b/lib/js/react-ps/src/index.ts index 2c7744ec1..ec8db9bc7 100644 --- a/lib/js/react-ps/src/index.ts +++ b/lib/js/react-ps/src/index.ts @@ -2,11 +2,17 @@ import IdentityProviders from "./components/IdentityProviders"; import FormLayout from "./components/FormLayout"; import DashboardMenu from "./components/DashboardMenu/DashboardMenu"; import OAuthClient, { - authenticationEventType, loginEventType, logoutEventType, + sessionExpiredEventType, + refreshTokenEventType, RequestConfigWithAuth, configureClientAuthentication, + RefreshTokenEvent, + AuthEventHandler, + LoginEvent, + AuthEvent, + LogoutEvent, } from "./lib/oauth-client"; import { @@ -22,11 +28,17 @@ export { OAuthClient, RequestConfigWithAuth, configureClientAuthentication, - authenticationEventType, loginEventType, logoutEventType, + sessionExpiredEventType, + refreshTokenEventType, DashboardMenu, createHttpClient, RequestConfig, useEffectOnce, + RefreshTokenEvent, + AuthEventHandler, + LoginEvent, + AuthEvent, + LogoutEvent, }; diff --git a/lib/js/react-ps/src/lib/oauth-client.ts b/lib/js/react-ps/src/lib/oauth-client.ts index 80c579097..8d6a17592 100644 --- a/lib/js/react-ps/src/lib/oauth-client.ts +++ b/lib/js/react-ps/src/lib/oauth-client.ts @@ -26,25 +26,26 @@ type UserInfoResponse = { sub: string; } -type AuthEvent = { +export type AuthEvent = { type: string; }; -type LoginEvent = { - accessToken: string; +export type LoginEvent = { + response: TokenResponse; } & AuthEvent; -type AuthenticationEvent = { - user: UserInfoResponse; +export type RefreshTokenEvent = { + response: TokenResponse; } & AuthEvent; -type LogoutEvent = AuthEvent; +export type LogoutEvent = AuthEvent; -type AuthEventHandler = (event: AuthEvent) => Promise; +export type AuthEventHandler = (event: E) => Promise; -export const authenticationEventType = 'authentication'; export const loginEventType = 'login'; +export const refreshTokenEventType = 'refreshToken'; export const logoutEventType = 'logout'; +export const sessionExpiredEventType = 'sessionExpired'; export interface IStorage { getItem(key: string): string | null; @@ -61,12 +62,13 @@ type Options = { } export default class OAuthClient { + public tokenPromise: Promise | undefined; private listeners: Record = {}; private clientId: string; private baseUrl: string; private storage: IStorage; private tokensCache: TokenResponse | undefined; - public tokenPromise: Promise | undefined; + private sessionTimeout: ReturnType | undefined; constructor({ clientId, @@ -128,12 +130,14 @@ export default class OAuthClient { return jwtDecode(accessToken); } - logout(redirectPath: string = '/'): void { - this.storage.removeItem(tokenStorageKey); - this.tokensCache = undefined; - this.triggerEvent(logoutEventType); + logout(redirectPath: string | false = '/'): void { + this.clearSessionTimeout(); + + this.doLogout(); - document.location.href = this.createLogoutUrl({redirectPath}); + if (false !== redirectPath) { + document.location.href = this.createLogoutUrl({redirectPath}); + } } registerListener(event: string, callback: AuthEventHandler): void { @@ -154,16 +158,6 @@ export default class OAuthClient { } } - private async triggerEvent(type: string, event: Partial = {}): Promise { - event.type = type; - - if (!this.listeners[type]) { - return Promise.resolve(); - } - - await Promise.all(this.listeners[type].map(func => func(event as E)).filter(f => !!f)); - } - public async getAccessTokenFromAuthCode(code: string, redirectUri: string): Promise { const res = await this.getToken({ code, @@ -173,7 +167,11 @@ export default class OAuthClient { this.persistTokens(res); - await this.triggerEvent(loginEventType); + this.handleSessionTimeout(res); + + await this.triggerEvent(loginEventType, { + response: res, + }); return res; } @@ -185,6 +183,12 @@ export default class OAuthClient { grant_type: 'refresh_token', }); + this.handleSessionTimeout(res); + + await this.triggerEvent(refreshTokenEventType, { + response: res, + }); + return res; } catch (e: any) { console.log('e', e); @@ -244,6 +248,46 @@ export default class OAuthClient { return `${this.baseUrl}/logout?${queryString}`; } + public getTokenResponse(): TokenResponse | undefined { + return this.fetchTokens(); + } + + private doLogout(): void { + this.triggerEvent(logoutEventType); + this.storage.removeItem(tokenStorageKey); + this.tokensCache = undefined; + } + + private async triggerEvent(type: string, event: Partial = {}): Promise { + event.type = type; + + if (!this.listeners[type]) { + return Promise.resolve(); + } + + await Promise.all(this.listeners[type].map(func => func(event as E)).filter(f => !!f)); + } + + private handleSessionTimeout(res: TokenResponse): void { + this.clearSessionTimeout(); + + this.sessionTimeout = setTimeout(() => { + this.sessionExpired(); + }, res.refresh_expires_in * 1000); + } + + private sessionExpired(): void { + this.triggerEvent(sessionExpiredEventType); + this.doLogout(); + } + + private clearSessionTimeout(): void { + if (this.sessionTimeout) { + clearTimeout(this.sessionTimeout); + this.sessionTimeout = undefined; + } + } + private persistTokens(token: TokenResponse): void { const now = Math.ceil(new Date().getTime() / 1000); token.expires_at = now + token.expires_in; diff --git a/lib/php/workflow/src/Executor/Expression/ExpressionParser.php b/lib/php/workflow/src/Executor/Expression/ExpressionParser.php index 7752c70dd..1b2d3f045 100644 --- a/lib/php/workflow/src/Executor/Expression/ExpressionParser.php +++ b/lib/php/workflow/src/Executor/Expression/ExpressionParser.php @@ -32,7 +32,7 @@ public function evaluateJobExpression( return $this->replaceVars($expression, $variables); } - protected function registerFunctions() + protected function registerFunctions(): void { parent::registerFunctions(); diff --git a/notify/api/src/Entity/Contact.php b/notify/api/src/Entity/Contact.php index 96a62fefe..6ee32940f 100644 --- a/notify/api/src/Entity/Contact.php +++ b/notify/api/src/Entity/Contact.php @@ -47,11 +47,11 @@ class Contact implements \Stringable protected $locale; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] - private readonly \DateTime $createdAt; + private readonly \DateTimeImmutable $createdAt; public function __construct() { - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); $this->id = Uuid::uuid4(); } @@ -100,7 +100,7 @@ public function setLocale(?string $locale): void $this->locale = $locale; } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } diff --git a/notify/api/src/Entity/FailedEvent.php b/notify/api/src/Entity/FailedEvent.php index 43b21d8b2..f4289dd07 100644 --- a/notify/api/src/Entity/FailedEvent.php +++ b/notify/api/src/Entity/FailedEvent.php @@ -24,11 +24,11 @@ class FailedEvent extends BaseFailedEvent protected $id; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] - private ?\DateTime $createdAt = null; + private ?\DateTimeImmutable $createdAt = null; public function __construct() { - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); } public function getId(): string @@ -36,7 +36,7 @@ public function getId(): string return $this->id->__toString(); } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } diff --git a/notify/api/src/Entity/TopicSubscriber.php b/notify/api/src/Entity/TopicSubscriber.php index 5dc075f4b..3095702eb 100644 --- a/notify/api/src/Entity/TopicSubscriber.php +++ b/notify/api/src/Entity/TopicSubscriber.php @@ -32,11 +32,11 @@ class TopicSubscriber protected ?Contact $contact = null; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] - private readonly \DateTime $createdAt; + private readonly \DateTimeImmutable $createdAt; public function __construct() { - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); $this->id = Uuid::uuid4(); } @@ -65,7 +65,7 @@ public function getContact(): ?Contact return $this->contact; } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } diff --git a/notify/api/src/Migrations/Version20230925141147.php b/notify/api/src/Migrations/Version20230925141147.php new file mode 100644 index 000000000..6ec9e6ff9 --- /dev/null +++ b/notify/api/src/Migrations/Version20230925141147.php @@ -0,0 +1,42 @@ +addSql('ALTER TABLE contact ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN contact.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE topic_subscriber ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN topic_subscriber.created_at IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE topic_subscriber ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN topic_subscriber.created_at IS NULL'); + $this->addSql('ALTER TABLE contact ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN contact.created_at IS NULL'); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS NULL'); + } +} diff --git a/uploader/api/src/Consumer/Handler/DeleteExpiredAssetsHandler.php b/uploader/api/src/Consumer/Handler/DeleteExpiredAssetsHandler.php index 88b1b41e4..07eb8211a 100644 --- a/uploader/api/src/Consumer/Handler/DeleteExpiredAssetsHandler.php +++ b/uploader/api/src/Consumer/Handler/DeleteExpiredAssetsHandler.php @@ -26,8 +26,8 @@ public function handle(EventMessage $message): void return; } - $date = new \DateTime(); - $date->setTimestamp(time() - $this->deleteAssetGracefulTime); + $date = (new \DateTimeImmutable()) + ->setTimestamp(time() - $this->deleteAssetGracefulTime); $em = $this->getEntityManager(); $commits = $em diff --git a/uploader/api/src/Entity/Asset.php b/uploader/api/src/Entity/Asset.php index bb409289c..9b2cdc28f 100644 --- a/uploader/api/src/Entity/Asset.php +++ b/uploader/api/src/Entity/Asset.php @@ -176,7 +176,7 @@ class Asset extends AbstractUuidEntity #[ApiProperty] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] #[Groups('asset:read')] - private \DateTime $createdAt; + private \DateTimeImmutable $createdAt; #[ORM\Column(type: Types::STRING, length: 255)] private ?string $userId = null; @@ -184,7 +184,7 @@ class Asset extends AbstractUuidEntity public function __construct() { parent::__construct(); - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); } #[Groups('asset:read')] @@ -241,13 +241,13 @@ public function isCommitted(): bool #[Groups('asset:read')] public function getFormData(): ?array { - return $this->commit ? $this->commit->getFormData() : null; + return $this->commit?->getFormData(); } #[ApiProperty] public function getToken(): ?string { - return $this->commit ? $this->commit->getToken() : null; + return $this->commit?->getToken(); } public function getCommit(): ?Commit @@ -260,7 +260,7 @@ public function setCommit(?Commit $commit): void $this->commit = $commit; } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } diff --git a/uploader/api/src/Entity/AssetRepository.php b/uploader/api/src/Entity/AssetRepository.php index 0d2b6f04f..6f96369bb 100644 --- a/uploader/api/src/Entity/AssetRepository.php +++ b/uploader/api/src/Entity/AssetRepository.php @@ -26,8 +26,8 @@ public function attachCommit(array $files, string $commitId): void */ public function findExpiredAssets(int $maxDaysRetention): iterable { - $expirationDate = new \DateTime(); - $expirationDate->sub(new \DateInterval('P'.$maxDaysRetention.'D')); + $expirationDate = (new \DateTimeImmutable()) + ->sub(new \DateInterval('P'.$maxDaysRetention.'D')); return $this ->createQueryBuilder('a') diff --git a/uploader/api/src/Entity/Commit.php b/uploader/api/src/Entity/Commit.php index 9ae240233..b5ccc8637 100644 --- a/uploader/api/src/Entity/Commit.php +++ b/uploader/api/src/Entity/Commit.php @@ -108,12 +108,12 @@ class Commit extends AbstractUuidEntity #[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)] #[Groups(['asset:read', 'commit:read'])] - private ?\DateTime $acknowledgedAt = null; + private ?\DateTimeImmutable $acknowledgedAt = null; #[ApiProperty] #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] #[Groups(['asset:read', 'commit:read'])] - private readonly \DateTime $createdAt; + private readonly \DateTimeImmutable $createdAt; /** * Not mapped. @@ -125,7 +125,7 @@ public function __construct() { parent::__construct(); $this->assets = new ArrayCollection(); - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); } #[Groups(['asset:read', 'commit:read'])] @@ -254,7 +254,7 @@ public static function fromArray(array $data, EntityManagerInterface $em): self return $instance; } - public function getCreatedAt(): \DateTime + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; } @@ -267,7 +267,7 @@ public function isAcknowledged(): bool public function setAcknowledged(bool $acknowledged): void { if ($acknowledged) { - $this->acknowledgedAt = new \DateTime(); + $this->acknowledgedAt = new \DateTimeImmutable(); } $this->acknowledged = $acknowledged; } diff --git a/uploader/api/src/Entity/CommitRepository.php b/uploader/api/src/Entity/CommitRepository.php index a2e983925..1da77965d 100644 --- a/uploader/api/src/Entity/CommitRepository.php +++ b/uploader/api/src/Entity/CommitRepository.php @@ -11,7 +11,7 @@ class CommitRepository extends EntityRepository /** * @return Commit[] */ - public function getAcknowledgedBefore(\DateTime $date): array + public function getAcknowledgedBefore(\DateTimeImmutable $date): array { return $this ->createQueryBuilder('c') diff --git a/uploader/api/src/Entity/FailedEvent.php b/uploader/api/src/Entity/FailedEvent.php index 8393eb4b1..20ab77200 100644 --- a/uploader/api/src/Entity/FailedEvent.php +++ b/uploader/api/src/Entity/FailedEvent.php @@ -24,11 +24,11 @@ class FailedEvent extends BaseFailedEvent protected $id; #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] - private ?\DateTime $createdAt = null; + private ?\DateTimeImmutable $createdAt = null; public function __construct() { - $this->createdAt = new \DateTime(); + $this->createdAt = new \DateTimeImmutable(); } public function getId(): string @@ -36,7 +36,7 @@ public function getId(): string return $this->id->__toString(); } - public function getCreatedAt(): ?\DateTime + public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } diff --git a/uploader/api/src/Migrations/Version20230925141213.php b/uploader/api/src/Migrations/Version20230925141213.php new file mode 100644 index 000000000..908745a5e --- /dev/null +++ b/uploader/api/src/Migrations/Version20230925141213.php @@ -0,0 +1,70 @@ +addSql('ALTER TABLE asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE asset_commit ALTER acknowledged_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_commit ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_commit.acknowledged_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN asset_commit.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE form_schema ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE form_schema ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN form_schema.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN form_schema.updated_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE target ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN target.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('ALTER TABLE target_params ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE target_params ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN target_params.created_at IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN target_params.updated_at IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE asset_commit ALTER acknowledged_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE asset_commit ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset_commit.acknowledged_at IS NULL'); + $this->addSql('COMMENT ON COLUMN asset_commit.created_at IS NULL'); + $this->addSql('ALTER TABLE asset ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN asset.created_at IS NULL'); + $this->addSql('ALTER TABLE form_schema ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE form_schema ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN form_schema.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN form_schema.updated_at IS NULL'); + $this->addSql('ALTER TABLE failed_event ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN failed_event.created_at IS NULL'); + $this->addSql('ALTER TABLE multipart_upload ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN multipart_upload.created_at IS NULL'); + $this->addSql('ALTER TABLE target ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN target.created_at IS NULL'); + $this->addSql('ALTER TABLE target_params ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE target_params ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN target_params.created_at IS NULL'); + $this->addSql('COMMENT ON COLUMN target_params.updated_at IS NULL'); + } +}