Rework tables

This commit is contained in:
2024-10-27 17:39:09 +01:00
parent af7fc09078
commit beec0ca989
2 changed files with 34 additions and 17 deletions

14
ddl.sql
View File

@@ -2,16 +2,26 @@ create table guild (
id integer primary key,
name text
);
create unique index idx_guild_name on guild(name);
create table stinky (
create table player (
id integer primary key,
name text,
guild integer references guild(id)
);
create unique index idx_player_name on player(name);
create table association (
id integer primary key,
lhs integer references player(id),
rhs integer references player(id),
note text
);
create table note (
id integer primary key,
content text,
timestamp string,
stinky integer references stinky(id)
player integer references player(id)
);
create unique index idx_note_content on note(timestamp, player);

View File

@@ -5,28 +5,35 @@ import "time"
type (
Guild struct {
ID int
Name string
Name string `json:"name"`
}
Stinky struct {
Player struct {
ID int
Name string
Guild Guild
Name string `json:"name"`
Guild Guild `json:"guild"`
}
Association struct {
ID int
LHS Player
RHS Player
Note string
}
Note struct {
ID int
Content string
Timestamp time.Time
Stinky Stinky
Player Player
}
)
type NoteData struct {
Player string
PlayerID int
Date time.Time
Guild string
GuildID int
Note string
Associations []NoteAssociationData
}
type NoteAssociationData struct {
Player string
Note string
}