Remove all TimescaleDB features from monitoring_checks
Convert to standard PostgreSQL table. TimescaleDB Apache license doesn't support hypertables or time-series features.
This commit is contained in:
parent
c1ed04f322
commit
b99c4020a8
1 changed files with 5 additions and 16 deletions
|
|
@ -2,14 +2,9 @@ defmodule Towerops.Repo.Migrations.CreateMonitoringChecks do
|
|||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
# Enable TimescaleDB extension first
|
||||
execute("CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE")
|
||||
|
||||
# Create the table with composite primary key (id, checked_at)
|
||||
# This is required for TimescaleDB hypertables
|
||||
create table(:monitoring_checks, primary_key: false) do
|
||||
add :id, :binary_id, null: false
|
||||
|
||||
# Note: TimescaleDB features removed due to Apache license restrictions
|
||||
# Using standard PostgreSQL table instead
|
||||
create table(:monitoring_checks) do
|
||||
add :equipment_id, references(:equipment, type: :binary_id, on_delete: :delete_all),
|
||||
null: false
|
||||
|
||||
|
|
@ -20,15 +15,10 @@ defmodule Towerops.Repo.Migrations.CreateMonitoringChecks do
|
|||
timestamps(type: :utc_datetime, updated_at: false)
|
||||
end
|
||||
|
||||
# Add composite primary key
|
||||
execute("ALTER TABLE monitoring_checks ADD PRIMARY KEY (id, checked_at)")
|
||||
|
||||
# Convert to TimescaleDB hypertable (partitioned by checked_at)
|
||||
execute("SELECT create_hypertable('monitoring_checks', 'checked_at')")
|
||||
|
||||
# Create indexes
|
||||
# Create indexes for query performance
|
||||
create index(:monitoring_checks, [:equipment_id])
|
||||
create index(:monitoring_checks, [:equipment_id, :checked_at])
|
||||
create index(:monitoring_checks, [:checked_at])
|
||||
|
||||
# Note: Retention and compression policies require TimescaleDB commercial license
|
||||
# Commented out for Apache-licensed version
|
||||
|
|
@ -50,6 +40,5 @@ defmodule Towerops.Repo.Migrations.CreateMonitoringChecks do
|
|||
|
||||
def down do
|
||||
drop table(:monitoring_checks)
|
||||
execute("DROP EXTENSION IF EXISTS timescaledb CASCADE")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue