|
@@ -40,23 +40,8 @@ namespace OhmGraphite
|
|
|
|
|
|
if (_setupTable)
|
|
|
{
|
|
|
- using (var cmd = new NpgsqlCommand(
|
|
|
- "CREATE TABLE IF NOT EXISTS ohm_stats (" +
|
|
|
- " time TIMESTAMPTZ NOT NULL," +
|
|
|
- " host TEXT," +
|
|
|
- " hardware TEXT," +
|
|
|
- " hardware_type TEXT," +
|
|
|
- " identifier TEXT," +
|
|
|
- " sensor TEXT," +
|
|
|
- " sensor_type TEXT," +
|
|
|
- " sensor_index INT," +
|
|
|
- " value REAL" +
|
|
|
- ");" +
|
|
|
- "" +
|
|
|
- @"SELECT create_hypertable('ohm_stats', 'time', if_not_exists => TRUE);" +
|
|
|
- "CREATE INDEX IF NOT EXISTS idx_ohm_host ON ohm_stats (host);" +
|
|
|
- "CREATE INDEX IF NOT EXISTS idx_ohm_identifier ON ohm_stats (identifier);",
|
|
|
- _conn))
|
|
|
+ var setupSql = Resourcer.Resource.AsString("schema.sql");
|
|
|
+ using (var cmd = new NpgsqlCommand(setupSql, _conn))
|
|
|
{
|
|
|
await cmd.ExecuteNonQueryAsync();
|
|
|
}
|