mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2025-04-08 12:04:10 +00:00
Merge branch 'rebased-migration' into 'develop'
Add rollback migrations for Rebased See merge request pleroma/pleroma!4308
This commit is contained in:
commit
d7c1cea936
10 changed files with 177 additions and 0 deletions
1
changelog.d/rebased-migration.change
Normal file
1
changelog.d/rebased-migration.change
Normal file
|
@ -0,0 +1 @@
|
|||
Add optional migrations for rollback from Rebased
|
44
docs/installation/migrating_from_rebased.md
Normal file
44
docs/installation/migrating_from_rebased.md
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Migrating from Rebased
|
||||
|
||||
## Code migration
|
||||
|
||||
As Rebased only officially supported running from source code, we assume you're running it from source as well. To migrate source from upstream, you need to set the origin repository URL to upstream and pull the changes.
|
||||
|
||||
```bash
|
||||
git remote set-url origin https://git.pleroma.social/pleroma/pleroma
|
||||
git pull -r
|
||||
```
|
||||
|
||||
Then, install the dependencies and compile as usual:
|
||||
|
||||
```bash
|
||||
MIX_ENV=prod mix deps.get
|
||||
MIX_ENV=prod mix compile
|
||||
```
|
||||
|
||||
As Rebased recommends using [`asdf` version manager](https://asdf-vm.com/), you might want to either keep using it or switch to system Elixir installation. If you choose the latter, follow Pleroma installation instructions for your distribution and replace the Pleroma systemd service with one provided by Pleroma upstream.
|
||||
|
||||
```bash
|
||||
sudo cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
||||
sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
Because Rebased doesn't come with a bundled frontend, you most likely have one installed in thhe `instance/static` directory. You can remove it, as Pleroma comes with a bundled frontend. Be sure not to remove other files you might have there, like custom emojis.
|
||||
|
||||
## Database migration
|
||||
|
||||
> Note: While it is not necessary to rollback Rebased-specific migrations because they don't include breaking changes, it is recommended to do so to keep the database clean. You will lose data related to Rebased-specific features, like the configured webhooks or user-defined location. Consider taking a backup.
|
||||
|
||||
To rollback Rebased-specific migrations:
|
||||
|
||||
```bash
|
||||
MIX_ENV=prod mix ecto.rollback --migrations-path priv/repo/optional_migrations/rebased_rollbacks --all
|
||||
```
|
||||
|
||||
Then, just
|
||||
|
||||
```bash
|
||||
MIX_ENV=prod mix ecto.migrate
|
||||
```
|
||||
|
||||
to apply Pleroma database migrations.
|
|
@ -0,0 +1,14 @@
|
|||
# Adapted from Rebased
|
||||
# https://gitlab.com/soapbox-pub/rebased/-/blob/main/priv/repo/migrations/20210612185407_add_email_list_field_to_users.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddEmailListFieldToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:accepts_email_list, :boolean)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddActivityAssignedAccountIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
drop_if_exists(
|
||||
index(:activities, ["(data->>'assigned_account')"],
|
||||
name: :activities_assigned_account_index
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddLocationToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:location, :string)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
defmodule Pleroma.Repo.Migrations.CreateWebhooks do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
drop_if_exists(unique_index(:webhooks, [:url]))
|
||||
drop_if_exists(table(:webhooks))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddPleromaParticipationAcceptedToNotificationsEnum do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
alter table(:notifications) do
|
||||
modify(:type, :string)
|
||||
end
|
||||
|
||||
"""
|
||||
delete from notifications where type in ('pleroma:participation_accepted', 'pleroma:participation_request', 'pleroma:event_reminder', 'pleroma:event_update')
|
||||
"""
|
||||
|> execute()
|
||||
|
||||
"""
|
||||
drop type if exists notification_type
|
||||
"""
|
||||
|> execute()
|
||||
|
||||
"""
|
||||
create type notification_type as enum (
|
||||
'follow',
|
||||
'follow_request',
|
||||
'mention',
|
||||
'move',
|
||||
'pleroma:emoji_reaction',
|
||||
'pleroma:chat_mention',
|
||||
'reblog',
|
||||
'favourite',
|
||||
'pleroma:report',
|
||||
'poll',
|
||||
'status',
|
||||
'update'
|
||||
)
|
||||
"""
|
||||
|> execute()
|
||||
|
||||
"""
|
||||
alter table notifications
|
||||
alter column type type notification_type using (type::notification_type)
|
||||
"""
|
||||
|> execute()
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddLastMoveAtToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:last_move_at, :naive_datetime)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddInternalToWebhooks do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
alter table(:webhooks) do
|
||||
remove_if_exists(:internal, :boolean)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
# Adapted from Rebased
|
||||
# https://gitlab.com/soapbox-pub/rebased/-/blob/main/priv/repo/migrations/20221207235104_add_events_index.exs
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AddEventsIndex do
|
||||
use Ecto.Migration
|
||||
|
||||
def up, do: :noop
|
||||
|
||||
def down do
|
||||
drop_if_exists(
|
||||
index(:objects, ["(data->>'type')"],
|
||||
where: "data->>'type' = 'Event'",
|
||||
name: :objects_events
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue