17 lines
629 B
MySQL
17 lines
629 B
MySQL
|
CREATE TABLE governors (
|
||
|
id UUID PRIMARY KEY NOT NULL,
|
||
|
team_id UUID NOT NULL REFERENCES teams(id) ON DELETE CASCADE,
|
||
|
project_id UUID REFERENCES projects(id) ON DELETE CASCADE,
|
||
|
window_size INTERVAL NOT NULL DEFAULT '1 hour',
|
||
|
max_count INT NOT NULL,
|
||
|
-- incremented when an entry is created; decremented when an entry expires
|
||
|
rolling_count INT NOT NULL DEFAULT 0
|
||
|
);
|
||
|
|
||
|
CREATE TABLE governor_entries (
|
||
|
id UUID PRIMARY KEY NOT NULL,
|
||
|
governor_id UUID NOT NULL REFERENCES governors(id) ON DELETE CASCADE,
|
||
|
timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||
|
);
|
||
|
CREATE INDEX ON governor_entries(timestamp);
|