From a775a03035b63855e44bc4569d6b67283c7bb96c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 23:30:04 +0200 Subject: [PATCH] add "granted_by" column to awards instead of "granted" --- files/classes/award.py | 2 +- sql/20220920-award-granted-by.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 sql/20220920-award-granted-by.sql diff --git a/files/classes/award.py b/files/classes/award.py index 60b00664d..d64970e95 100644 --- a/files/classes/award.py +++ b/files/classes/award.py @@ -15,7 +15,7 @@ class AwardRelationship(Base): comment_id = Column(Integer, ForeignKey("comments.id")) kind = Column(String) awarded_utc = Column(Integer) - granted = Column(Boolean) + granted_by = Column(Integer, ForeignKey("users.id")) created_utc = Column(Integer) user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards") diff --git a/sql/20220920-award-granted-by.sql b/sql/20220920-award-granted-by.sql new file mode 100644 index 000000000..662118094 --- /dev/null +++ b/sql/20220920-award-granted-by.sql @@ -0,0 +1,5 @@ +alter table award_relationships add column granted_by int; +ALTER TABLE ONLY public.award_relationships + ADD CONSTRAINT award_granted_by_fkey FOREIGN KEY (granted_by) REFERENCES public.users(id); +update award_relationships set granted_by=1 where granted=true; +alter table award_relationships drop column granted;