possible
This commit is contained in:
parent
d2e55112d4
commit
4eee7f29cb
2 changed files with 30 additions and 7 deletions
|
@ -141,7 +141,7 @@ class Submission(CreatedBase):
|
|||
|
||||
@lazy
|
||||
def flags(self, v):
|
||||
flags = g.db.query(Flag).filter_by(post_id=self.id).order_by(Flag.created_utc).all()
|
||||
flags = g.db.query(Flag).filter_by(post_id=self.id).order_by(Flag.created_datetimez).all()
|
||||
if not (v and (v.shadowbanned or v.admin_level >= 3)):
|
||||
for flag in flags:
|
||||
if flag.user.shadowbanned:
|
||||
|
|
|
@ -7,6 +7,7 @@ Create Date: 2023-07-22 03:05:16.984823+00:00
|
|||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql.functions import now
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
|
@ -16,13 +17,35 @@ branch_labels = None
|
|||
depends_on = None
|
||||
|
||||
|
||||
table_name = 'flags'
|
||||
from_column = 'created_utc'
|
||||
to_column = 'created_datetimez'
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
op.add_column(table_name, sa.Column(to_column, sa.DateTime(timezone=True), server_default=now(), nullable=True))
|
||||
op.execute(f"""
|
||||
UPDATE {table_name}
|
||||
SET {to_column} =
|
||||
CASE
|
||||
WHEN {from_column} > 0 THEN
|
||||
(timestamp 'epoch' + {from_column} * interval '1 second') at time zone 'utc'
|
||||
ELSE NULL
|
||||
END
|
||||
""")
|
||||
|
||||
op.alter_column(table_name, to_column, nullable=False)
|
||||
op.drop_column(table_name, from_column)
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
op.add_column(table_name, sa.Column(from_column, sa.Integer(), server_default=sa.text('0'), nullable=True))
|
||||
op.execute(f"""
|
||||
UPDATE {table_name}
|
||||
SET {from_column} =
|
||||
COALESCE(
|
||||
EXTRACT(EPOCH FROM {to_column})::integer,
|
||||
0
|
||||
)
|
||||
""")
|
||||
op.alter_column(table_name, from_column, nullable=False)
|
||||
op.drop_column(table_name, to_column)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue