diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-02-04 19:58:15 -0500 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-02-04 19:58:15 -0500 |
commit | 97b82520aacacbe600c8918b26b5b29b8d47d4d1 (patch) | |
tree | c130abd56069c0b2a429d590dfb6ec7b54c68585 /migrations | |
parent | ca69f19d0492ae420ba54a158676d246b0307be0 (diff) |
Add entry table and link with raw data
Diffstat (limited to 'migrations')
-rw-r--r-- | migrations/2020-02-04-150559_entry/down.sql | 1 | ||||
-rw-r--r-- | migrations/2020-02-04-150559_entry/up.sql | 9 | ||||
-rw-r--r-- | migrations/2020-02-04-223649_entry_data/down.sql | 1 | ||||
-rw-r--r-- | migrations/2020-02-04-223649_entry_data/up.sql | 15 |
4 files changed, 26 insertions, 0 deletions
diff --git a/migrations/2020-02-04-150559_entry/down.sql b/migrations/2020-02-04-150559_entry/down.sql new file mode 100644 index 0000000..ca787a3 --- /dev/null +++ b/migrations/2020-02-04-150559_entry/down.sql @@ -0,0 +1 @@ +drop table entries; diff --git a/migrations/2020-02-04-150559_entry/up.sql b/migrations/2020-02-04-150559_entry/up.sql new file mode 100644 index 0000000..122dec7 --- /dev/null +++ b/migrations/2020-02-04-150559_entry/up.sql @@ -0,0 +1,9 @@ +create table entries ( + username varchar not null references users(username), + entry_type varchar(16) not null, + id bigserial not null, + timestamp timestamptz, + payload jsonb not null, + + primary key(username, entry_type, id) +); diff --git a/migrations/2020-02-04-223649_entry_data/down.sql b/migrations/2020-02-04-223649_entry_data/down.sql new file mode 100644 index 0000000..a10c419 --- /dev/null +++ b/migrations/2020-02-04-223649_entry_data/down.sql @@ -0,0 +1 @@ +drop table entry_data; diff --git a/migrations/2020-02-04-223649_entry_data/up.sql b/migrations/2020-02-04-223649_entry_data/up.sql new file mode 100644 index 0000000..dde9288 --- /dev/null +++ b/migrations/2020-02-04-223649_entry_data/up.sql @@ -0,0 +1,15 @@ +create table entry_data ( + username varchar not null, + entry_type varchar(16) not null, + entry_id bigint not null, + data_type varchar(8) not null, + data_id bigint not null, + +primary key(username, entry_type, entry_id, data_type, data_id), + +foreign key (username, entry_type, entry_id) +references entries(username, entry_type, id), + +foreign key (data_type, data_id) +references raw_data(data_type, id) +); |