Skip to content

Commit

Permalink
adding indexed created_at column to lineage events table (#2299)
Browse files Browse the repository at this point in the history
* adding indexed created_at column to lineage events table

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>

* populate default values in lineage_events.created_at column

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>

* removing backfill step

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>

* altering type to TIMESTAMP WITH TIME ZONE

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>

* adding NULLS LAST in desc index on lineage_events.created_at

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>

Signed-off-by: Prachi Mishra <prachi.mishra@astronomer.io>
  • Loading branch information
prachim-collab authored Dec 12, 2022
1 parent e501e36 commit b1ff80e
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- new column will be created with 'null' filled for existing rows
ALTER TABLE lineage_events ADD created_at TIMESTAMP WITH TIME ZONE;

create index lineage_events_created_at_index on lineage_events (created_at desc NULLS LAST);

-- The new default set to UTC now() will only apply in subsequent INSERT or UPDATE commands; it does not cause rows already in the table to change.
ALTER TABLE lineage_events ALTER COLUMN created_at SET DEFAULT (now() AT TIME ZONE 'UTC')::timestamptz;

0 comments on commit b1ff80e

Please sign in to comment.