Altinn / altinn-platform

Altinn Platform infrastructure
7 stars 1 forks source link

Copy Timescale data to new table for Auditlog #983

Open ootneim opened 1 month ago

ootneim commented 1 month ago

Copy data from Timescale to a new Table for Auditlog

Procedure is located here: https://github.com/Altinn/altinn-platform/issues/906

Performed in

SQL Commands:

CREATE TABLE authentication.eventlogv0 (LIKE authentication.eventlog INCLUDING ALL);

INSERT INTO authentication.eventlogv0
SELECT * FROM authentication.eventlog;

CREATE INDEX authentication_eventlogv0_created_idx ON authentication.eventlogv0 (created);
CREATE TABLE authz.eventlogv0 (LIKE authz.eventlog INCLUDING ALL);

INSERT INTO authz.eventlogv0
SELECT * FROM authz.eventlog;

CREATE INDEX authz_eventlogv0_created_idx ON authz.eventlogv0 (created);
acn-dgopa commented 4 days ago

We have now decided to remove the use of timescaledb from the auditlog database. A background service part of auditlog application will create necessary partitions automatically. It will use the native postgres partition and it will be a new table. The existing data on the table that uses timescale partitioning should be migrated to a new table without timescale. This will be done by the infra team.

ootneim commented 2 days ago

@acn-dgopa What are the names of the new tables?

acn-dgopa commented 2 days ago

The old data must be migrated as follows authentication.eventlog --->authentication.eventlogv0 authz.eventlog -----> authz.eventlogv0