From c24ee63f6da800d8091bebe26dd6fcc7264a7300 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 13 Feb 2025 16:12:37 +1300 Subject: [PATCH 1/3] Remove some unused indexes and deprecated columns --- ...0301_remove_unused_indexes_and_columns.exs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs diff --git a/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs new file mode 100644 index 000000000..39f426dcd --- /dev/null +++ b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs @@ -0,0 +1,22 @@ +defmodule NervesHub.Repo.Migrations.RemoveUnusedIndexesAndColumns do + use Ecto.Migration + + def up do + drop(index(:devices, [:connection_status])) + + alter table("device") do + remove(:connection_status) + remove(:connection_established_at) + remove(:connection_disconnected_at) + remove(:connection_last_seen_at) + remove(:connection_metadata) + remove(:connection_types) + end + + drop(index(:device_connections, [:device_id, :established_at])) + end + + def down do + raise "One way migration" + end +end From ca8cc9049b9cb67e70f1df4b873462c76e65d014 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Sun, 16 Feb 2025 12:14:12 +1300 Subject: [PATCH 2/3] Use the correct table name for the `Device` schema --- .../20250213030301_remove_unused_indexes_and_columns.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs index 39f426dcd..2c5785545 100644 --- a/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs +++ b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs @@ -4,7 +4,7 @@ defmodule NervesHub.Repo.Migrations.RemoveUnusedIndexesAndColumns do def up do drop(index(:devices, [:connection_status])) - alter table("device") do + alter table("devics") do remove(:connection_status) remove(:connection_established_at) remove(:connection_disconnected_at) From d6242d1a2661961eaea38d1e148a69a8cb95216e Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Sun, 16 Feb 2025 13:30:59 +1300 Subject: [PATCH 3/3] Can't believe I messed that up! --- .../20250213030301_remove_unused_indexes_and_columns.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs index 2c5785545..d5d9f6172 100644 --- a/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs +++ b/priv/repo/migrations/20250213030301_remove_unused_indexes_and_columns.exs @@ -4,7 +4,7 @@ defmodule NervesHub.Repo.Migrations.RemoveUnusedIndexesAndColumns do def up do drop(index(:devices, [:connection_status])) - alter table("devics") do + alter table("devices") do remove(:connection_status) remove(:connection_established_at) remove(:connection_disconnected_at)