From fa058de5a79d93eef1a32fd4774b558b63a4acd1 Mon Sep 17 00:00:00 2001 From: Kathleen Tuite Date: Wed, 15 May 2024 12:50:29 -0700 Subject: [PATCH] Change entities deletedAt precision and add timezone --- lib/model/frames/entity.js | 2 +- .../20240515-01-entity-tz-precision.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/model/migrations/20240515-01-entity-tz-precision.js diff --git a/lib/model/frames/entity.js b/lib/model/frames/entity.js index d8ec94918..28443611e 100644 --- a/lib/model/frames/entity.js +++ b/lib/model/frames/entity.js @@ -27,7 +27,7 @@ class Entity extends Frame.define( 'int4', 'int4', 'conflictType', 'timestamptz', - 'timestamptz', 'timestamp', + 'timestamptz', 'timestampz', ]) ) { get def() { return this.aux.def; } diff --git a/lib/model/migrations/20240515-01-entity-tz-precision.js b/lib/model/migrations/20240515-01-entity-tz-precision.js new file mode 100644 index 000000000..f0124fdbd --- /dev/null +++ b/lib/model/migrations/20240515-01-entity-tz-precision.js @@ -0,0 +1,18 @@ +// Copyright 2024 ODK Central Developers +// See the NOTICE file at the top-level directory of this distribution and at +// https://github.com/getodk/central-backend/blob/master/NOTICE. +// This file is part of ODK Central. It is subject to the license terms in +// the LICENSE file found in the top-level directory of this distribution and at +// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, +// including this file, may be copied, modified, propagated, or distributed +// except according to the terms contained in the LICENSE file. + +const up = async (db) => { + await db.raw('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamptz(3)'); +}; + +const down = async (db) => { + await db.raw('ALTER TABLE entities ALTER COLUMN "deletedAt" TYPE timestamp(3)'); +}; + +module.exports = { up, down };