Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
7b20b11c
Commit
7b20b11c
authored
2 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
add user_corpus m2m relationship
parent
0bf54ad0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models.py
+18
-2
18 additions, 2 deletions
app/models.py
migrations/versions/4aa88f253dab_.py
+31
-0
31 additions, 0 deletions
migrations/versions/4aa88f253dab_.py
with
49 additions
and
2 deletions
app/models.py
+
18
−
2
View file @
7b20b11c
...
...
@@ -257,7 +257,7 @@ class Avatar(HashidMixin, FileMixin, db.Model):
# Primary key
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
# Foreign keys
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
)
,
unique
=
True
)
user_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
users.id
'
))
@property
def
path
(
self
):
...
...
@@ -276,7 +276,16 @@ class Avatar(HashidMixin, FileMixin, db.Model):
**
self
.
file_mixin_to_json_serializeable
()
}
return
json_serializeable
corpus_followers
=
db
.
Table
(
'
corpus_followers
'
,
db
.
Model
.
metadata
,
db
.
Column
(
'
user_id
'
,
db
.
ForeignKey
(
'
users.id
'
),
primary_key
=
True
),
db
.
Column
(
'
corpus_id
'
,
db
.
ForeignKey
(
'
corpora.id
'
),
primary_key
=
True
)
)
class
User
(
HashidMixin
,
UserMixin
,
db
.
Model
):
__tablename__
=
'
users
'
# Primary key
...
...
@@ -327,6 +336,13 @@ class User(HashidMixin, UserMixin, db.Model):
cascade
=
'
all, delete-orphan
'
,
lazy
=
'
dynamic
'
)
followed_corpora
=
db
.
relationship
(
'
Corpus
'
,
secondary
=
corpus_followers
,
primaryjoin
=
(
corpus_followers
.
c
.
user_id
==
id
),
backref
=
db
.
backref
(
'
followers
'
,
lazy
=
'
dynamic
'
),
lazy
=
'
dynamic
'
)
jobs
=
db
.
relationship
(
'
Job
'
,
backref
=
'
user
'
,
...
...
This diff is collapsed.
Click to expand it.
migrations/versions/4aa88f253dab_.py
0 → 100644
+
31
−
0
View file @
7b20b11c
"""
Add corpus_followers table
Revision ID: 4aa88f253dab
Revises: 5b2a6e590166
Create Date: 2023-01-12 14:47:39.492875
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'
4aa88f253dab
'
down_revision
=
'
5b2a6e590166
'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
op
.
create_table
(
'
corpus_followers
'
,
sa
.
Column
(
'
user_id
'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
Column
(
'
corpus_id
'
,
sa
.
Integer
(),
nullable
=
False
),
sa
.
ForeignKeyConstraint
([
'
corpus_id
'
],
[
'
corpora.id
'
],
),
sa
.
ForeignKeyConstraint
([
'
user_id
'
],
[
'
users.id
'
],
),
sa
.
PrimaryKeyConstraint
(
'
user_id
'
,
'
corpus_id
'
)
)
def
downgrade
():
op
.
drop_table
(
'
corpus_followers
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment