Skip to content
Snippets Groups Projects
Commit e8e8eb47 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

DB: Zprávičky

parent af17ab2c
No related branches found
No related tags found
1 merge request!57Zprávičky
...@@ -107,6 +107,7 @@ CREATE TABLE rounds ( ...@@ -107,6 +107,7 @@ CREATE TABLE rounds (
score_mode score_mode NOT NULL DEFAULT 'basic', -- mód výsledkovky score_mode score_mode NOT NULL DEFAULT 'basic', -- mód výsledkovky
score_winner_limit int DEFAULT NULL, -- bodový limit na označení za vítěze score_winner_limit int DEFAULT NULL, -- bodový limit na označení za vítěze
score_successful_limit int DEFAULT NULL, -- bodový limit na označení za úspěšného řešitele score_successful_limit int DEFAULT NULL, -- bodový limit na označení za úspěšného řešitele
has_messages boolean NOT NULL DEFAULT false, -- má zprávičky
UNIQUE (year, category, seq, part) UNIQUE (year, category, seq, part)
); );
...@@ -298,3 +299,15 @@ CREATE TABLE jobs ( ...@@ -298,3 +299,15 @@ CREATE TABLE jobs (
in_file varchar(255) DEFAULT NULL, in_file varchar(255) DEFAULT NULL,
out_file varchar(255) DEFAULT NULL out_file varchar(255) DEFAULT NULL
); );
-- Zprávičky k soutěžím
CREATE TABLE messages (
message_id serial PRIMARY KEY,
round_id int NOT NULL REFERENCES rounds(round_id),
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- čas publikování zprávičky
created_by int NOT NULL REFERENCES users(user_id), -- autor zprávičky
title text NOT NULL,
markdown text NOT NULL,
html text NOT NULL
);
SET ROLE 'mo_osmo';
-- Zprávičky k soutěžím
ALTER TABLE rounds
ADD COLUMN has_messages boolean NOT NULL DEFAULT false; -- má zprávičky
CREATE TABLE messages (
message_id serial PRIMARY KEY,
round_id int NOT NULL REFERENCES rounds(round_id),
created_at timestamp with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- čas publikování zprávičky
created_by int NOT NULL REFERENCES users(user_id), -- autor zprávičky
title text NOT NULL,
markdown text NOT NULL,
html text NOT NULL
);
...@@ -209,6 +209,7 @@ class Round(Base): ...@@ -209,6 +209,7 @@ class Round(Base):
score_mode = Column(Enum(RoundScoreMode, name='score_mode'), nullable=False, server_default=text("'basic'::score_mode")) score_mode = Column(Enum(RoundScoreMode, name='score_mode'), nullable=False, server_default=text("'basic'::score_mode"))
score_winner_limit = Column(Integer) score_winner_limit = Column(Integer)
score_successful_limit = Column(Integer) score_successful_limit = Column(Integer)
has_messages = Column(Boolean, nullable=False, server_default=text("false"))
master = relationship('Round', primaryjoin='Round.master_round_id == Round.round_id', remote_side='Round.round_id', post_update=True) master = relationship('Round', primaryjoin='Round.master_round_id == Round.round_id', remote_side='Round.round_id', post_update=True)
...@@ -592,6 +593,20 @@ class Job(Base): ...@@ -592,6 +593,20 @@ class Job(Base):
user = relationship('User') user = relationship('User')
class Message(Base):
__tablename__ = 'messages'
message_id = Column(Integer, primary_key=True, server_default=text("nextval('messages_message_id_seq'::regclass)"))
round_id = Column(Integer, ForeignKey('rounds.round_id'), nullable=False)
created_at = Column(DateTime(True), nullable=False, server_default=text("CURRENT_TIMESTAMP"))
created_by = Column(Integer, ForeignKey('users.user_id'))
title = Column(Text, nullable=False)
markdown = Column(Text, nullable=False)
html = Column(Text, nullable=False)
created_by_user = relationship('User')
_engine: Optional[Engine] = None _engine: Optional[Engine] = None
_session: Optional[Session] = None _session: Optional[Session] = None
flask_db: Any = None flask_db: Any = None
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment