Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F12551319
data_migration.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
data_migration.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.DataMigration
do
use
Ecto.Schema
alias
Pleroma.DataMigration
alias
Pleroma.DataMigration.State
alias
Pleroma.Repo
import
Ecto.Changeset
import
Ecto.Query
schema
"data_migrations"
do
field
(
:name
,
:string
)
field
(
:state
,
State
,
default
:
:pending
)
field
(
:feature_lock
,
:boolean
,
default
:
false
)
field
(
:params
,
:map
,
default
:
%{})
field
(
:data
,
:map
,
default
:
%{})
timestamps
()
end
def
changeset
(
data_migration
,
params
\\
%{})
do
data_migration
|>
cast
(
params
,
[
:name
,
:state
,
:feature_lock
,
:params
,
:data
])
|>
validate_required
([
:name
])
|>
unique_constraint
(
:name
)
end
def
update_one_by_id
(
id
,
params
\\
%{})
do
with
{
1
,
_
}
<-
from
(
dm
in
DataMigration
,
where
:
dm
.
id
==
^
id
)
|>
Repo
.
update_all
(
set
:
params
)
do
:ok
end
end
def
get_by_name
(
name
)
do
Repo
.
get_by
(
DataMigration
,
name
:
name
)
end
def
populate_hashtags_table
,
do
:
get_by_name
(
"populate_hashtags_table"
)
def
delete_context_objects
,
do
:
get_by_name
(
"delete_context_objects"
)
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Fri, Nov 14, 10:36 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
571131
Default Alt Text
data_migration.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment