-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add analytics table for timeseries
Signed-off-by: Guillaume Hivert <[email protected]>
- Loading branch information
Showing
4 changed files
with
121 additions
and
10 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
apps/backend/db/migrations/20240521204341_add_analytics_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- migrate:up | ||
create table analytics ( | ||
id integer primary key generated always as identity, | ||
foreign_id int not null, | ||
table_name text not null, | ||
content jsonb not null, | ||
day timestamptz not null, | ||
created_at timestamptz default current_timestamp not null, | ||
updated_at timestamptz default current_timestamp not null, | ||
unique (foreign_id, table_name, day) | ||
); | ||
|
||
create trigger analytics_moddatetime | ||
before update on analytics | ||
for each row | ||
execute procedure moddatetime (updated_at); | ||
|
||
-- migrate:down | ||
drop trigger analytics_moddatetime on analytics; | ||
drop table analytics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters