Add record migration

This commit is contained in:
Ellie Huxtable 2023-06-23 08:22:29 +01:00
parent 6c6f5f8187
commit 5eb07c722e
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,5 @@
// generated by `sqlx migrate build-script`
fn main() {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
}

View File

@ -0,0 +1,13 @@
-- Add migration script here
create table records (
id uuid primary key, -- remember to use uuidv7 for happy indices <3
host uuid not null, -- a unique identifier for the host
parent uuid not null, -- the ID of the parent record, bearing in mind this is a linked list
timestamp bigint not null, -- not a timestamp type, as those do not have nanosecond precision
version text not null,
tag text not null, -- what is this? history, kv, whatever. Remember clients get a log per tag per host
data bytea not null, -- store the actual history data, encrypted. I don't wanna know!
user_id bigint not null, -- allow multiple users
created_at timestamp not null default current_timestamp
);