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