v1.0 with SW PWA enabled
This commit is contained in:
25
backend/migrations/000001_init_schema.up.sql
Normal file
25
backend/migrations/000001_init_schema.up.sql
Normal file
@ -0,0 +1,25 @@
|
||||
CREATE TABLE nodes (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
address VARCHAR(50) NOT NULL,
|
||||
status SMALLINT NOT NULL,
|
||||
last_seen TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TABLE services (
|
||||
id SERIAL PRIMARY KEY,
|
||||
node_id INTEGER NOT NULL REFERENCES nodes(id) ON DELETE CASCADE,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
status SMALLINT NOT NULL,
|
||||
command TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE status_records (
|
||||
id SERIAL PRIMARY KEY,
|
||||
service_id INTEGER NOT NULL REFERENCES services(id) ON DELETE CASCADE,
|
||||
status SMALLINT NOT NULL,
|
||||
timestamp TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX idx_services_node_id ON services(node_id);
|
||||
CREATE INDEX idx_status_history ON status_records (service_id, timestamp DESC);
|
||||
Reference in New Issue
Block a user