Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
C
CommonsPub Federated Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bonfire
CommonsPub Federated Server
Commits
f500850d
Commit
f500850d
authored
Nov 05, 2020
by
Antonis Kalou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration and schema for claim
parent
aee14626
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
0 deletions
+114
-0
lib/extensions/value_flows/claim/claim.ex
lib/extensions/value_flows/claim/claim.ex
+70
-0
lib/extensions/value_flows/claim/migrations.ex
lib/extensions/value_flows/claim/migrations.ex
+38
-0
priv/repo/migrations/20201105102006_create_claim.exs
priv/repo/migrations/20201105102006_create_claim.exs
+6
-0
No files found.
lib/extensions/value_flows/claim/claim.ex
0 → 100644
View file @
f500850d
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Claim
do
use
Pointers
.
Pointable
,
otp_app:
:commons_pub
,
source:
"vf_claim"
,
table_id:
"C0MM0NSPVBVA1VEF10WSC1A1MS"
import
CommonsPub
.
Common
.
Changeset
,
only:
[
change_public:
1
,
change_disabled:
1
]
alias
Ecto
.
Changeset
alias
CommonsPub
.
Users
.
User
alias
ValueFlows
.
Knowledge
.
Action
alias
ValueFlows
.
Knowledge
.
ResourceSpecification
alias
ValueFlows
.
Observation
.
EconomicEvent
alias
ValueFlows
.
Observation
.
EconomicResource
@type
t
::
%
__MODULE__
{}
pointable_schema
do
field
(
:note
,
:string
)
field
(
:agreed_in
,
:string
)
field
(
:finished
,
:boolean
)
field
(
:created
,
:utc_datetime_usec
)
field
(
:due
,
:utc_datetime_usec
)
field
(
:resource_classified_as
,
{
:array
,
:string
})
belongs_to
(
:action
,
Action
,
type:
:string
)
belongs_to
(
:provider
,
Pointers
.
Pointer
)
belongs_to
(
:receiver
,
Pointers
.
Pointer
)
belongs_to
(
:resource_quantity
,
Measure
,
on_replace:
:nilify
)
belongs_to
(
:effort_quantity
,
Measure
,
on_replace:
:nilify
)
belongs_to
(
:resource_conforms_to
,
ResourceSpecification
)
belongs_to
(
:triggered_by
,
EconomicEvent
)
# a.k.a. in_scope_of
belongs_to
(
:context
,
Pointers
.
Pointer
)
# not defined in spec, used internally
belongs_to
(
:creator
,
User
)
field
(
:is_public
,
:boolean
,
virtual:
true
)
field
(
:published_at
,
:utc_datetime_usec
)
field
(
:is_disabled
,
:boolean
,
virtual:
true
,
default:
false
)
field
(
:disabled_at
,
:utc_datetime_usec
)
field
(
:deleted_at
,
:utc_datetime_usec
)
timestamps
(
inserted_at:
false
)
end
@required
~w(action_id)a
@cast
@required
++
~w(note finished agreed_in created due resource_classified_as is_disabled)a
def
create_changeset
(%
User
{}
=
creator
,
attrs
)
do
%
__MODULE__
{}
|>
Changeset
.
cast
(
attrs
,
@cast
)
|>
Changeset
.
change
(
creator_id:
creator
.
id
,
is_public:
true
)
|>
common_changeset
()
end
defp
common_changeset
(
changeset
)
do
changeset
|>
change_public
()
|>
change_disabled
()
end
end
lib/extensions/value_flows/claim/migrations.ex
0 → 100644
View file @
f500850d
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
ValueFlows
.
Claim
.
Migrations
do
use
Ecto
.
Migration
import
Pointers
.
Migration
alias
ValueFlows
.
Knowledge
.
ResourceSpecification
alias
ValueFlows
.
Observation
.
EconomicEvent
def
up
do
create_pointable_table
(
ValueFlows
.
Claim
)
do
add
(
:note
,
:text
)
add
(
:agreed_in
,
:string
)
add
(
:action_id
,
:string
)
add
(
:created
,
:timestamptz
)
add
(
:due
,
:timestamptz
)
add
(
:provider_id
,
weak_pointer
(),
null:
true
)
add
(
:receiver_id
,
weak_pointer
(),
null:
true
)
add
(
:resource_conforms_to_id
,
weak_pointer
(
ResourceSpecification
),
null:
true
)
add
(
:triggered_by_id
,
weak_pointer
(
EconomicEvent
),
null:
true
)
add
(
:creator_id
,
references
(
"mn_user"
,
on_delete:
:nilify_all
))
add
(
:context_id
,
weak_pointer
(),
null:
true
)
add
(
:published_at
,
:timestamptz
)
add
(
:deleted_at
,
:timestamptz
)
add
(
:disabled_at
,
:timestamptz
)
timestamps
(
inserted_at:
false
,
type:
:utc_datetime_usec
)
end
end
def
down
do
drop_pointable_table
(
ValueFlows
.
Claim
)
end
end
priv/repo/migrations/20201105102006_create_claim.exs
0 → 100644
View file @
f500850d
defmodule
CommonsPub
.
Repo
.
Migrations
.
CreateClaim
do
use
Ecto
.
Migration
def
up
,
do
:
ValueFlows
.
Claim
.
Migrations
.
up
()
def
down
,
do
:
ValueFlows
.
Claim
.
Migrations
.
down
()
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment