ids.alfacom.it/database-schema/create_routers.sql
marco370 253df0e6bc Add table for managing MikroTik router configurations
Create a new SQL table named 'routers' to store MikroTik router configuration details, including IP addresses, credentials, and status, with example data.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 4b47610c-d428-476f-95dd-d18864bbda27
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/1P26v7M
2025-11-17 18:26:01 +00:00

38 lines
1.3 KiB
SQL

-- =========================================================
-- SCHEMA: Tabella routers per gestione router MikroTik
-- =========================================================
-- Memorizza configurazione router per comunicazione API REST
-- =========================================================
-- Drop tabella se esiste (solo per ambiente di sviluppo)
DROP TABLE IF EXISTS routers CASCADE;
-- Crea tabella routers
CREATE TABLE routers (
id VARCHAR PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
ip_address TEXT NOT NULL UNIQUE,
username TEXT NOT NULL,
password TEXT NOT NULL,
api_port INTEGER NOT NULL DEFAULT 443,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
last_check TIMESTAMP,
status TEXT,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
-- Indici per performance
CREATE INDEX IF NOT EXISTS routers_ip_idx ON routers(ip_address);
CREATE INDEX IF NOT EXISTS routers_enabled_idx ON routers(enabled);
-- Commento tabella
COMMENT ON TABLE routers IS 'Configurazione router MikroTik per comunicazione API REST';
-- Inserisci router di esempio (FIBRA)
INSERT INTO routers (name, ip_address, username, password, api_port, enabled)
VALUES ('Router FIBRA', '192.178.204.1', 'admin', 'change_me', 443, true)
ON CONFLICT (ip_address) DO NOTHING;
-- Verifica
SELECT 'Tabella routers creata con successo!' AS status;