Skip to content

Instantly share code, notes, and snippets.

@sheosi
Created November 20, 2024 17:55
Show Gist options
  • Save sheosi/ee3545a1974b9cacb5f3028d937a15b3 to your computer and use it in GitHub Desktop.
Save sheosi/ee3545a1974b9cacb5f3028d937a15b3 to your computer and use it in GitHub Desktop.
documents.hcl
table "documents" {
comment = "Documents"
schema = schema.main
column "hash" {
comment = "An xxhash3 of user_id site_id col_label and doc_label"
type = int
}
column "numeral" {
comment = "A disambiguation for hashes"
type = int
#auto_increment = true
}
primary_key {
columns = [column.hash, column.numeral]
}
column "label" {
comment = "An automatically generated url-safe version of the name"
type = text
}
column "name" {
type = text
}
column "data" {
comment = "The document saved in the postcard binary format"
type = blob
}
column "user_id" {
type = int
}
foreign_key "user_id" {
columns = [column.user_id]
ref_columns = [table.users.column.id]
on_delete = CASCADE
on_update = NO_ACTION
}
column "col_hash" {
comment = "The hash of the collection this document pertains to"
type = int
}
column "col_numeral" {
comment = "The numeral of the collection this document pertains to"
type = int
}
foreign_key "collection" {
columns = [column.col_hash, column.col_numeral]
ref_columns = [table.collections.column.hash, table.collections.column.numeral]
on_delete = CASCADE
on_update = NO_ACTION
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment