Add operational schema and identity roles

This commit is contained in:
lussierj committed 2026-07-28 13:46:10 +00:00
1 parent f5af75f305
commit f181482463
11 files changed
+2068 -284

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
INSERT INTO miner_status_daily_rollups (
miner_id,
bucket_date,
sample_count,
avg_mhs_av,
max_mhs_av,
avg_power_w,
max_chip_temp_c,
avg_chip_temp_c,
avg_pool_rejected_percent,
updated_at
)
SELECT
miner_id,
observed_at::date AS bucket_date,
COUNT(*) AS sample_count,
AVG(mhs_av)::double precision,
MAX(mhs_av)::double precision,
AVG(power_w)::double precision,
MAX(chip_temp_max_c)::double precision,
AVG(chip_temp_avg_c)::double precision,
AVG(pool_rejected_percent)::double precision,
now()
FROM miner_status_snapshots
GROUP BY miner_id, observed_at::date
ON CONFLICT (miner_id, bucket_date) DO UPDATE
SET sample_count = EXCLUDED.sample_count,
avg_mhs_av = EXCLUDED.avg_mhs_av,
max_mhs_av = EXCLUDED.max_mhs_av,
avg_power_w = EXCLUDED.avg_power_w,
max_chip_temp_c = EXCLUDED.max_chip_temp_c,
avg_chip_temp_c = EXCLUDED.avg_chip_temp_c,
avg_pool_rejected_percent = EXCLUDED.avg_pool_rejected_percent,
updated_at = now();
+34
View File
@@ -0,0 +1,34 @@
INSERT INTO miner_status_hourly_rollups (
miner_id,
bucket_at,
sample_count,
avg_mhs_av,
max_mhs_av,
avg_power_w,
max_chip_temp_c,
avg_chip_temp_c,
avg_pool_rejected_percent,
updated_at
)
SELECT
miner_id,
date_trunc('hour', observed_at) AS bucket_at,
COUNT(*) AS sample_count,
AVG(mhs_av)::double precision,
MAX(mhs_av)::double precision,
AVG(power_w)::double precision,
MAX(chip_temp_max_c)::double precision,
AVG(chip_temp_avg_c)::double precision,
AVG(pool_rejected_percent)::double precision,
now()
FROM miner_status_snapshots
GROUP BY miner_id, date_trunc('hour', observed_at)
ON CONFLICT (miner_id, bucket_at) DO UPDATE
SET sample_count = EXCLUDED.sample_count,
avg_mhs_av = EXCLUDED.avg_mhs_av,
max_mhs_av = EXCLUDED.max_mhs_av,
avg_power_w = EXCLUDED.avg_power_w,
max_chip_temp_c = EXCLUDED.max_chip_temp_c,
avg_chip_temp_c = EXCLUDED.avg_chip_temp_c,
avg_pool_rejected_percent = EXCLUDED.avg_pool_rejected_percent,
updated_at = now();
+30
View File
@@ -0,0 +1,30 @@
WITH expected(table_name) AS (
VALUES
('roles'),
('permissions'),
('users'),
('miners'),
('miner_status_snapshots'),
('miner_status_hourly_rollups'),
('miner_status_daily_rollups'),
('minerops_retention_runs'),
('miner_maintenance_events'),
('location_positions'),
('miner_location_states'),
('location_import_issues'),
('miner_command_events'),
('miner_api_credentials'),
('miner_pool_snapshots'),
('miner_api3_enrichment_snapshots'),
('miner_api3_hashboard_snapshots'),
('minerops_site_agents'),
('minerops_agent_snapshots'),
('minerops_agent_command_results'),
('minerops_agent_command_queue'),
('minerops_agent_discoveries'),
('minerops_scheduled_bulk_actions')
)
SELECT table_name
FROM expected
WHERE to_regclass('public.' || table_name) IS NULL
ORDER BY table_name;