13 lines
574 B
MySQL
13 lines
574 B
MySQL
|
|
CREATE TABLE computer_file_events (
|
||
|
|
computer_id TEXT NOT NULL REFERENCES computers(id) ON DELETE CASCADE,
|
||
|
|
provider_ref TEXT NOT NULL,
|
||
|
|
generation INTEGER NOT NULL,
|
||
|
|
local_id BIGINT NOT NULL CHECK(local_id > 0),
|
||
|
|
operation_id TEXT NOT NULL REFERENCES computer_operations(id) ON DELETE CASCADE,
|
||
|
|
status TEXT NOT NULL,
|
||
|
|
payload JSONB NOT NULL,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||
|
|
PRIMARY KEY(computer_id, provider_ref, generation, local_id)
|
||
|
|
);
|
||
|
|
CREATE INDEX computer_file_event_sequence ON computer_file_events(operation_id, local_id);
|