Skip to content

Commit

Permalink
Use TIMESTAMPTZ (#2924)
Browse files Browse the repository at this point in the history
* Use `TIMESTAMPTZ`

Signed-off-by: Willy Lulciuc <[email protected]>

* Recreate `job` and `dataset` views

Signed-off-by: Willy Lulciuc <[email protected]>

* Only drop views and trigger

Signed-off-by: Willy Lulciuc <[email protected]>

* Fix migration for repeatable scripts

Signed-off-by: Willy Lulciuc <[email protected]>

* Use `CREATE VIEW OR REPLACE` on `datasets_view`

Signed-off-by: Willy Lulciuc <[email protected]>

* Fix repeatable view query syntax

Signed-off-by: Willy Lulciuc <[email protected]>

---------

Signed-off-by: Willy Lulciuc <[email protected]>
Co-authored-by: Peter Hicks <[email protected]>
  • Loading branch information
wslulciuc and phixMe authored Oct 11, 2024
1 parent 24fab4b commit db4fbfa
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DROP VIEW IF EXISTS datasets_view;
CREATE VIEW datasets_view AS
CREATE OR REPLACE VIEW datasets_view AS
SELECT d.uuid,
d.type,
d.created_at,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ALTER TABLE namespaces ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE namespaces ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE sources ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE sources ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

-- Drop view 'datasets_view' before applying time zone to table 'datasets'.
DROP VIEW IF EXISTS datasets_view CASCADE;

ALTER TABLE datasets ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE datasets ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE dataset_fields ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE dataset_fields ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE dataset_versions ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';

-- Drop view 'jobs_view' (and trigger) before applying time zone to table 'jobs'.
DROP TRIGGER IF EXISTS update_symlinks ON jobs_view;
DROP VIEW IF EXISTS jobs_view CASCADE;

ALTER TABLE jobs ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE jobs ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE job_versions ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE job_versions ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE runs ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE runs ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

ALTER TABLE run_states ALTER COLUMN transitioned_at TYPE TIMESTAMPTZ
USING transitioned_at AT TIME ZONE 'UTC';

ALTER TABLE tags ALTER COLUMN created_at TYPE TIMESTAMPTZ
USING created_at AT TIME ZONE 'UTC';
ALTER TABLE tags ALTER COLUMN updated_at TYPE TIMESTAMPTZ
USING updated_at AT TIME ZONE 'UTC';

0 comments on commit db4fbfa

Please sign in to comment.