1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.DataMigration do
8 alias Pleroma.DataMigration
9 alias Pleroma.DataMigration.State
15 schema "data_migrations" do
17 field(:state, State, default: :pending)
18 field(:feature_lock, :boolean, default: false)
19 field(:params, :map, default: %{})
20 field(:data, :map, default: %{})
25 def changeset(data_migration, params \\ %{}) do
27 |> cast(params, [:name, :state, :feature_lock, :params, :data])
28 |> validate_required([:name])
29 |> unique_constraint(:name)
32 def update_one_by_id(id, params \\ %{}) do
34 from(dm in DataMigration, where: dm.id == ^id)
35 |> Repo.update_all(set: params) do
40 def get_by_name(name) do
41 Repo.get_by(DataMigration, name: name)
44 def populate_hashtags_table, do: get_by_name("populate_hashtags_table")
45 def delete_context_objects, do: get_by_name("delete_context_objects")