regroup backend and frontend in app folder
This commit is contained in:
25
app/backend/migrations/000001_init_schema.up.sql
Normal file
25
app/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);
|
||||
17
app/backend/migrations/000002_auth_features.up.sql
Normal file
17
app/backend/migrations/000002_auth_features.up.sql
Normal file
@ -0,0 +1,17 @@
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username VARCHAR(50) UNIQUE NOT NULL,
|
||||
email VARCHAR(255) UNIQUE NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
role VARCHAR(20) DEFAULT 'user',
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
last_login TIMESTAMP WITH TIME ZONE
|
||||
);
|
||||
|
||||
CREATE TABLE sessions (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
|
||||
token TEXT UNIQUE NOT NULL,
|
||||
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
7
app/backend/migrations/000003_api_keys.up.sql
Normal file
7
app/backend/migrations/000003_api_keys.up.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE node_api_keys (
|
||||
id SERIAL PRIMARY KEY,
|
||||
key_name VARCHAR(100),
|
||||
key_value VARCHAR(64) UNIQUE NOT NULL,
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
Reference in New Issue
Block a user