2021-12-28 11:42:08 +01:00
|
|
|
defmodule Mobilizon.Storage.Repo.Migrations.AddInstanceMaterializedView do
|
|
|
|
use Ecto.Migration
|
2023-08-31 18:29:28 +02:00
|
|
|
alias Mobilizon.Storage.Views.Instances
|
2021-12-28 11:42:08 +01:00
|
|
|
|
|
|
|
def up do
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.create_materialized_view())
|
2021-12-28 11:42:08 +01:00
|
|
|
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.refresh_instances())
|
2021-12-28 11:42:08 +01:00
|
|
|
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.drop_trigger())
|
2021-12-28 11:42:08 +01:00
|
|
|
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.create_trigger())
|
2021-12-28 11:42:08 +01:00
|
|
|
|
|
|
|
create_if_not_exists(unique_index("instances", [:domain]))
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
|
|
|
drop_if_exists(unique_index("instances", [:domain]))
|
|
|
|
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.drop_refresh_instances())
|
2021-12-28 11:42:08 +01:00
|
|
|
|
2023-08-31 18:29:28 +02:00
|
|
|
execute(Instances.drop_view())
|
2021-12-28 11:42:08 +01:00
|
|
|
end
|
|
|
|
end
|