Adapt some migrations so they can be rolled back

This is useful for people who want to migrate back to Pleroma.
It's also added in the docs, but also noted that this is barely tested and to be used at their own risk.
This commit is contained in:
ilja 2023-06-09 22:02:26 +02:00
parent fb8081e1a3
commit 3a13f91fff
4 changed files with 36 additions and 4 deletions

View file

@ -118,3 +118,15 @@ To fix this, run:
```
which will remove the config from the database. Things should work now.
## Migrating back to Pleroma
Akkoma is a hard fork of Pleroma. As such, migrating back is not guaranteed to always work. But if you want to migrate back to Pleroma, you can always try. Just note that you may run into unexpected issues and you're basically on your own. The following are some tips that may help, but note that these are barely tested, so proceed at your own risk.
First you will need to roll back the database migrations. The latest migration both Akkoma and Pleroma still have in common should be 20210416051708, so roll back to that. If you run from source, that should be
```sh
MIX_ENV=prod mix ecto.rollback --to 20210416051708
```
Then switch back to Pleroma for updates (similar to how was done to migrate to Akkoma), and remove the front-ends. The front-ends are installed in the `frontends` folder in the [static directory](../configuration/static_dir.md). Once you are back to Pleroma, you will need to run the database migrations again. See the Pleroma documentation for this.

View file

@ -1,11 +1,19 @@
defmodule Pleroma.Repo.Migrations.ForcePinnedObjectsToExist do
use Ecto.Migration
def change do
def up do
execute("UPDATE users SET pinned_objects = '{}' WHERE pinned_objects IS NULL")
alter table("users") do
modify(:pinned_objects, :map, null: false, default: %{})
end
end
def down do
alter table("users") do
modify(:pinned_objects, :map, null: true, default: nil)
end
execute("UPDATE users SET pinned_objects = NULL WHERE pinned_objects = '{}'")
end
end

View file

@ -1,9 +1,15 @@
defmodule Pleroma.Repo.Migrations.AddMastofeSettings do
use Ecto.Migration
def change do
def up do
alter table(:users) do
add_if_not_exists(:mastofe_settings, :map)
end
end
def down do
alter table(:users) do
remove_if_exists(:mastofe_settings, :map)
end
end
end

View file

@ -1,9 +1,15 @@
defmodule Pleroma.Repo.Migrations.AddLanguageToUsers do
use Ecto.Migration
def change do
def up do
alter table(:users) do
add_if_not_exists(:language, :string)
end
end
def down do
alter table(:users) do
remove_if_exists(:language, :string)
end
end
end