support infinite length posts and comments (fixes #229)

This commit is contained in:
justcool393 2023-02-25 02:18:30 -08:00 committed by GitHub
parent 44919507e9
commit bfe8fb70f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 99 additions and 32 deletions

View file

@ -42,8 +42,8 @@ class Comment(Base):
downvotes = Column(Integer, default=0, nullable=False) downvotes = Column(Integer, default=0, nullable=False)
realupvotes = Column(Integer, default=1, nullable=False) realupvotes = Column(Integer, default=1, nullable=False)
descendant_count = Column(Integer, default=0, nullable=False) descendant_count = Column(Integer, default=0, nullable=False)
body = Column(String) body = Column(Text)
body_html = Column(String) body_html = Column(Text, nullable=False)
ban_reason = Column(String) ban_reason = Column(String)
filter_state = Column(String, nullable=False) filter_state = Column(String, nullable=False)

View file

@ -47,8 +47,8 @@ class Submission(Base):
title = Column(String, nullable=False) title = Column(String, nullable=False)
title_html = Column(String, nullable=False) title_html = Column(String, nullable=False)
url = Column(String) url = Column(String)
body = Column(String) body = Column(Text)
body_html = Column(String) body_html = Column(Text)
flair = Column(String) flair = Column(String)
ban_reason = Column(String) ban_reason = Column(String)
embed_url = Column(String) embed_url = Column(String)

View file

@ -59,6 +59,10 @@ PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
DEFAULT_COLOR = environ.get("DEFAULT_COLOR", "fff").strip() DEFAULT_COLOR = environ.get("DEFAULT_COLOR", "fff").strip()
COLORS = {'ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58','8cdbe6', DEFAULT_COLOR} COLORS = {'ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58','8cdbe6', DEFAULT_COLOR}
SUBMISSION_BODY_LENGTH_MAXIMUM: Final[int] = 20000
COMMENT_BODY_LENGTH_MAXIMUM: Final[int] = 10000
MESSAGE_BODY_LENGTH_MAXIMUM: Final[int] = 10000
ERROR_MESSAGES = { ERROR_MESSAGES = {
400: "That request was bad and you should feel bad", 400: "That request was bad and you should feel bad",
401: "You need an account for this. Please make one!", 401: "You need an account for this. Please make one!",

View file

@ -81,6 +81,8 @@ def inject_constants():
"CC_TITLE":CC_TITLE, "CC_TITLE":CC_TITLE,
"listdir":listdir, "listdir":listdir,
"config":app.config.get, "config":app.config.get,
"COMMENT_BODY_LENGTH_MAXIMUM":COMMENT_BODY_LENGTH_MAXIMUM,
"SUBMISSION_BODY_LENGTH_MAXIMUM":SUBMISSION_BODY_LENGTH_MAXIMUM,
"DEFAULT_COLOR":DEFAULT_COLOR, "DEFAULT_COLOR":DEFAULT_COLOR,
"COLORS":COLORS, "COLORS":COLORS,
"THEMES":THEMES, "THEMES":THEMES,

View file

@ -134,7 +134,7 @@ def api_comment(v):
sub = parent_post.sub sub = parent_post.sub
if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}") if sub and v.exiled_from(sub): abort(403, f"You're exiled from /h/{sub}")
body = sanitize_raw(request.values.get("body"), allow_newlines=True, length_limit=10000) body = sanitize_raw(request.values.get("body"), allow_newlines=True, length_limit=COMMENT_BODY_LENGTH_MAXIMUM)
if not body and not request.files.get('file'): if not body and not request.files.get('file'):
abort(400, "You need to actually write something!") abort(400, "You need to actually write something!")
@ -209,8 +209,6 @@ def api_comment(v):
abort(403, "Too much spam!") abort(403, "Too much spam!")
if len(body_html) > 20000: abort(400)
is_filtered = v.should_comments_be_filtered() is_filtered = v.should_comments_be_filtered()
c = Comment(author_id=v.id, c = Comment(author_id=v.id,
@ -221,7 +219,7 @@ def api_comment(v):
is_bot=is_bot, is_bot=is_bot,
app_id=v.client.application.id if v.client else None, app_id=v.client.application.id if v.client else None,
body_html=body_html, body_html=body_html,
body=body[:10000], body=body[:COMMENT_BODY_LENGTH_MAXIMUM],
ghost=parent_post.ghost, ghost=parent_post.ghost,
filter_state='filtered' if is_filtered else 'normal' filter_state='filtered' if is_filtered else 'normal'
) )
@ -261,7 +259,7 @@ def api_comment(v):
def edit_comment(cid, v): def edit_comment(cid, v):
c = get_comment(cid, v=v) c = get_comment(cid, v=v)
if c.author_id != v.id: abort(403) if c.author_id != v.id: abort(403)
body = sanitize_raw(request.values.get("body"), allow_newlines=True, length_limit=10000) body = sanitize_raw(request.values.get("body"), allow_newlines=True, length_limit=COMMENT_BODY_LENGTH_MAXIMUM)
if len(body) < 1 and not (request.files.get("file") and request.headers.get("cf-ipcountry") != "T1"): if len(body) < 1 and not (request.files.get("file") and request.headers.get("cf-ipcountry") != "T1"):
abort(400, "You have to actually type something!") abort(400, "You have to actually type something!")
@ -316,9 +314,7 @@ def edit_comment(cid, v):
body_html = sanitize(body, edit=True) body_html = sanitize(body, edit=True)
if len(body_html) > 20000: abort(400) c.body = body[:COMMENT_BODY_LENGTH_MAXIMUM]
c.body = body[:10000]
c.body_html = body_html c.body_html = body_html
if int(time.time()) - c.created_utc > 60 * 3: c.edited_utc = int(time.time()) if int(time.time()) - c.created_utc > 60 * 3: c.edited_utc = int(time.time())

View file

@ -40,7 +40,7 @@ titleheaders = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWe
MAX_TITLE_LENGTH = 500 MAX_TITLE_LENGTH = 500
MAX_URL_LENGTH = 2048 MAX_URL_LENGTH = 2048
MAX_BODY_LENGTH = 20000 MAX_BODY_LENGTH = SUBMISSION_BODY_LENGTH_MAXIMUM
def guarded_value(val, min_len, max_len) -> str: def guarded_value(val, min_len, max_len) -> str:
@ -329,9 +329,6 @@ def edit_post(pid, v):
body_html = sanitize(body, edit=True) body_html = sanitize(body, edit=True)
p.body = body p.body = body
if len(body_html) > 40000: abort(400, "Submission body_html too long! (max 40k characters)")
p.body_html = body_html p.body_html = body_html
if not p.private and not p.ghost: if not p.private and not p.ghost:
@ -737,8 +734,6 @@ def submit_post(v, sub=None):
body_html = sanitize(body) body_html = sanitize(body)
if len(body_html) > 40000: return error("Submission body_html too long! (max 40k characters)")
club = bool(request.values.get("club","")) club = bool(request.values.get("club",""))
if embed and len(embed) > 1500: embed = None if embed and len(embed) > 1500: embed = None

View file

@ -437,7 +437,7 @@ def message2(v, username):
if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked: if v.admin_level <= 1 and hasattr(user, 'is_blocked') and user.is_blocked:
abort(403, "This user is blocking you.") abort(403, "This user is blocking you.")
message = request.values.get("message", "").strip()[:10000].strip() message = request.values.get("message", "").strip()[:MESSAGE_BODY_LENGTH_MAXIMUM].strip()
if not message: abort(400, "Message is empty!") if not message: abort(400, "Message is empty!")
body_html = sanitize(message) body_html = sanitize(message)
@ -482,7 +482,7 @@ def message2(v, username):
@auth_required @auth_required
def messagereply(v): def messagereply(v):
message = request.values.get("body", "").strip()[:10000].strip() message = request.values.get("body", "").strip()[:MESSAGE_BODY_LENGTH_MAXIMUM].strip()
if not message and not request.files.get("file"): abort(400, "Message is empty!") if not message and not request.files.get("file"): abort(400, "Message is empty!")

View file

@ -259,7 +259,7 @@
<div id="comment-edit-{{c.id}}" class="d-none comment-write collapsed child"> <div id="comment-edit-{{c.id}}" class="d-none comment-write collapsed child">
<form id="comment-edit-form-{{c.id}}" action="/edit_comment/{{c.id}}" method="post" enctype="multipart/form-data"> <form id="comment-edit-form-{{c.id}}" action="/edit_comment/{{c.id}}" method="post" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" maxlength="10000" oninput="markdown('comment-edit-body-{{c.id}}', 'preview-edit-{{c.id}}');charLimit('comment-edit-body-{{c.id}}','charcount-edit-{{c.id}}')" id="comment-edit-body-{{c.id}}" data-id="{{c.id}}" name="body" form="comment-edit-form-{{c.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add your comment..." rows="3">{{c.body}}</textarea> <textarea autocomplete="off" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" oninput="markdown('comment-edit-body-{{c.id}}', 'preview-edit-{{c.id}}');charLimit('comment-edit-body-{{c.id}}','charcount-edit-{{c.id}}')" id="comment-edit-body-{{c.id}}" data-id="{{c.id}}" name="body" form="comment-edit-form-{{c.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add your comment..." rows="3">{{c.body}}</textarea>
<div class="text-small font-weight-bold mt-1" id="charcount-edit-{{c.id}}" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div> <div class="text-small font-weight-bold mt-1" id="charcount-edit-{{c.id}}" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
@ -508,7 +508,7 @@
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="parent_fullname" value="{{c.fullname}}"> <input type="hidden" name="parent_fullname" value="{{c.fullname}}">
<input autocomplete="off" id="reply-form-submission-{{c.fullname}}" type="hidden" name="submission" value="{{c.post.id}}"> <input autocomplete="off" id="reply-form-submission-{{c.fullname}}" type="hidden" name="submission" value="{{c.post.id}}">
<textarea required autocomplete="off" minlength="1" maxlength="10000" oninput="markdown('reply-form-body-{{c.fullname}}', 'reply-edit-{{c.id}}');charLimit('reply-form-body-{{c.fullname}}','charcount-{{c.id}}')" id="reply-form-body-{{c.fullname}}" data-fullname="{{c.fullname}}" name="body" form="reply-to-t3_{{c.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea> <textarea required autocomplete="off" minlength="1" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" oninput="markdown('reply-form-body-{{c.fullname}}', 'reply-edit-{{c.id}}');charLimit('reply-form-body-{{c.fullname}}','charcount-{{c.id}}')" id="reply-form-body-{{c.fullname}}" data-fullname="{{c.fullname}}" name="body" form="reply-to-t3_{{c.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea>
<div class="text-small font-weight-bold mt-1" id="charcount-{{c.id}}" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div> <div class="text-small font-weight-bold mt-1" id="charcount-{{c.id}}" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
@ -553,7 +553,7 @@
<div id="comment-form-space-{{c.id}}" class="comment-write collapsed child"> <div id="comment-form-space-{{c.id}}" class="comment-write collapsed child">
<form id="reply-to-message-{{c.id}}" action="/reply" method="post" class="input-group" enctype="multipart/form-data"> <form id="reply-to-message-{{c.id}}" action="/reply" method="post" class="input-group" enctype="multipart/form-data">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<textarea required autocomplete="off" minlength="1" maxlength="10000" name="body" form="reply-to-t3_{{c.id}}" data-id="{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" aria-label="With textarea" rows="3" oninput="markdown('reply-form-body-{{c.id}}', 'message-reply-{{c.id}}')"></textarea> <textarea required autocomplete="off" minlength="1" maxlength="{{MESSAGE_BODY_LENGTH_MAXIMUM}}" name="body" form="reply-to-t3_{{c.id}}" data-id="{{c.id}}" class="comment-box form-control rounded" id="reply-form-body-{{c.id}}" aria-label="With textarea" rows="3" oninput="markdown('reply-form-body-{{c.id}}', 'message-reply-{{c.id}}')"></textarea>
<div class="comment-format" id="comment-format-bar-{{c.id}}"> <div class="comment-format" id="comment-format-bar-{{c.id}}">
{% if c.sentto == MODMAIL_ID %} {% if c.sentto == MODMAIL_ID %}

View file

@ -25,7 +25,7 @@
{% endif %} {% endif %}
<label for="input-message" class="mt-3">Your message</label> <label for="input-message" class="mt-3">Your message</label>
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" maxlength="10000" id="input-message" form="contactform" name="message" class="form-control" required></textarea> <textarea autocomplete="off" maxlength="{{MESSAGE_BODY_LENGTH_MAXIMUM}}" id="input-message" form="contactform" name="message" class="form-control" required></textarea>
<label class="btn btn-secondary m-0 mt-3" for="file-upload"> <label class="btn btn-secondary m-0 mt-3" for="file-upload">
<div id="filename"><i class="far fa-image"></i></div> <div id="filename"><i class="far fa-image"></i></div>
<input autocomplete="off" id="file-upload" type="file" name="file" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} onchange="changename('filename','file-upload')" hidden> <input autocomplete="off" id="file-upload" type="file" name="file" accept="image/*" {% if request.headers.get('cf-ipcountry')=="T1" %}disabled{% endif %} onchange="changename('filename','file-upload')" hidden>

View file

@ -283,7 +283,7 @@
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="current_page" value="{{request.path}}"> <input type="hidden" name="current_page" value="{{request.path}}">
<input type="text" autocomplete="off" maxlength="500" name="title" class="comment-box form-control rounded" required placeholder="title" value="{{p.title}}"\> <input type="text" autocomplete="off" maxlength="500" name="title" class="comment-box form-control rounded" required placeholder="title" value="{{p.title}}"\>
<textarea autocomplete="off" name="body" maxlength="20000" oninput="markdown('post-edit-box-{{p.id}}', 'post-edit-{{p.id}}');charLimit('post-edit-box-{{p.id}}','charcount-post-edit')" id="post-edit-box-{{p.id}}" form="post-edit-form-{{p.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add text to your post..." rows="10" data-id="{{p.id}}">{{p.body}}</textarea> <textarea autocomplete="off" name="body" maxlength="{{SUBMISSION_BODY_LENGTH_MAXIMUM}}" oninput="markdown('post-edit-box-{{p.id}}', 'post-edit-{{p.id}}');charLimit('post-edit-box-{{p.id}}','charcount-post-edit')" id="post-edit-box-{{p.id}}" form="post-edit-form-{{p.id}}" class="comment-box form-control rounded" aria-label="With textarea" placeholder="Add text to your post..." rows="10" data-id="{{p.id}}">{{p.body}}</textarea>
<div class="text-small font-weight-bold mt-1" id="charcount-post-edit" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div> <div class="text-small font-weight-bold mt-1" id="charcount-post-edit" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
@ -442,7 +442,7 @@
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<input type="hidden" name="parent_fullname" value="t2_{{p.id}}"> <input type="hidden" name="parent_fullname" value="t2_{{p.id}}">
<input autocomplete="off" id="reply-form-submission-{{p.fullname}}" type="hidden" name="submission" value="{{p.id}}"> <input autocomplete="off" id="reply-form-submission-{{p.fullname}}" type="hidden" name="submission" value="{{p.id}}">
<textarea required autocomplete="off" minlength="1" maxlength="10000" oninput="markdown('reply-form-body-{{p.fullname}}', 'form-preview-{{p.id}}');charLimit('reply-form-body-{{p.fullname}}','charcount-reply')" id="reply-form-body-{{p.fullname}}" data-fullname="{{p.fullname}}" class="comment-box form-control rounded" id="comment-form" name="body" form="reply-to-{{p.fullname}}" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea> <textarea required autocomplete="off" minlength="1" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" oninput="markdown('reply-form-body-{{p.fullname}}', 'form-preview-{{p.id}}');charLimit('reply-form-body-{{p.fullname}}','charcount-reply')" id="reply-form-body-{{p.fullname}}" data-fullname="{{p.fullname}}" class="comment-box form-control rounded" id="comment-form" name="body" form="reply-to-{{p.fullname}}" aria-label="With textarea" placeholder="Add your comment..." rows="3"></textarea>
<div class="text-small font-weight-bold mt-1" id="charcount-reply" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div> <div class="text-small font-weight-bold mt-1" id="charcount-reply" style="right: 1rem; bottom: 0.5rem; z-index: 3;"></div>
@ -465,7 +465,7 @@
</div> </div>
{% else %} {% else %}
<div class="comment-write mb-3"> <div class="comment-write mb-3">
<textarea autocomplete="off" maxlength="10000" class="comment-box form-control rounded" name="body" aria-label="With textarea" placeholder="Add your comment..." rows="3" onclick="location.href='/login?redirect={{request.path | urlencode}}';"></textarea> <textarea autocomplete="off" maxlength="{{COMMENT_BODY_LENGTH_MAXIMUM}}" class="comment-box form-control rounded" name="body" aria-label="With textarea" placeholder="Add your comment..." rows="3" onclick="location.href='/login?redirect={{request.path | urlencode}}';"></textarea>
</div> </div>
<div class="card border-0 mt-4"> <div class="card border-0 mt-4">

View file

@ -79,10 +79,10 @@
</div> </div>
</div> </div>
<label for="body" class="mt-3">Text<i class="fas fa-info-circle text-gray-400 ml-1" data-bs-toggle="tooltip" data-bs-placement="top" title="Uses markdown. Limited to 20000 characters."></i></label> <label for="body" class="mt-3">Text<i class="fas fa-info-circle text-gray-400 ml-1" data-bs-toggle="tooltip" data-bs-placement="top" title="Uses markdown. Limited to {{SUBMISSION_BODY_LENGTH_MAXIMUM}} characters."></i></label>
<div> <div>
<textarea form="submitform" id="post-text" class="form-control rounded" aria-label="With textarea" placeholder="Optional if you have a link or an image." rows="7" name="body" oninput="markdown('post-text','preview');charLimit('post-text','character-count-submit-text-form');checkForRequired();savetext()" maxlength="20000" required></textarea> <textarea form="submitform" id="post-text" class="form-control rounded" aria-label="With textarea" placeholder="Optional if you have a link or an image." rows="7" name="body" oninput="markdown('post-text','preview');charLimit('post-text','character-count-submit-text-form');checkForRequired();savetext()" maxlength="{{SUBMISSION_BODY_LENGTH_MAXIMUM}}" required></textarea>
<div class="btn btn-secondary fl-r mt-3" onclick="document.getElementById('preview').classList.toggle('d-none');"> <div class="btn btn-secondary fl-r mt-3" onclick="document.getElementById('preview').classList.toggle('d-none');">
Toggle preview Toggle preview

View file

@ -172,7 +172,7 @@
<form class="d-none toggleable" id="message" action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)"> <form class="d-none toggleable" id="message" action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)">
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<pre></pre> <pre></pre>
<textarea autocomplete="off" id="input-message" form="message" name="message" rows="3" minlength="1" maxlength="10000" class="form-control b2" oninput="markdown('input-message', 'message-preview')" required></textarea> <textarea autocomplete="off" id="input-message" form="message" name="message" rows="3" minlength="1" maxlength="{{MESSAGE_BODY_LENGTH_MAXIMUM}}" class="form-control b2" oninput="markdown('input-message', 'message-preview')" required></textarea>
<pre></pre> <pre></pre>
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-bold" aria-hidden="true" onclick="makeBold('input-message')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bold"></pre> <pre class="btn btn-secondary format d-inline-block m-0 fas fa-bold" aria-hidden="true" onclick="makeBold('input-message')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bold"></pre>
&nbsp; &nbsp;
@ -429,7 +429,7 @@
<form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)"> <form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)">
<pre></pre> <pre></pre>
<input type="hidden" name="formkey" value="{{v.formkey}}"> <input type="hidden" name="formkey" value="{{v.formkey}}">
<textarea autocomplete="off" id="input-message-mobile" form="message-mobile" name="message" rows="3" minlength="1" maxlength="10000" class="form-control" oninput="markdown('input-message-mobile', 'message-preview-mobile')" required></textarea> <textarea autocomplete="off" id="input-message-mobile" form="message-mobile" name="message" rows="3" minlength="1" maxlength="{{MESSAGE_BODY_LENGTH_MAXIMUM}}" class="form-control" oninput="markdown('input-message-mobile', 'message-preview-mobile')" required></textarea>
<pre></pre> <pre></pre>
<pre class="btn btn-secondary format d-inline-block m-0 fas fa-bold" aria-hidden="true" onclick="makeBold('input-message-mobile')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bold"></pre> <pre class="btn btn-secondary format d-inline-block m-0 fas fa-bold" aria-hidden="true" onclick="makeBold('input-message-mobile')" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Bold"></pre>
&nbsp; &nbsp;

View file

@ -50,7 +50,10 @@ def run_migrations_offline():
""" """
url = config.get_main_option("sqlalchemy.url") url = config.get_main_option("sqlalchemy.url")
context.configure( context.configure(
url=url, target_metadata=target_metadata, literal_binds=True url=url, target_metadata=target_metadata, literal_binds=True,
#compare_type=True,
# compare_type is commented out here in order to make tests pass
# this should be uncommented when migrations are completely up to date
) )
with context.begin_transaction(): with context.begin_transaction():
@ -81,6 +84,7 @@ def run_migrations_online():
context.configure( context.configure(
connection=connection, connection=connection,
target_metadata=target_metadata, target_metadata=target_metadata,
#compare_type=True,
process_revision_directives=process_revision_directives, process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args **current_app.extensions['migrate'].configure_args
) )

View file

@ -0,0 +1,66 @@
"""support infinite length submission and comment bodies
Revision ID: 85458909736a
Revises: ba8a214736eb
Create Date: 2023-02-17 03:03:40.358958+00:00
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '85458909736a'
down_revision = 'ba8a214736eb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('comments', 'body',
existing_type=sa.VARCHAR(length=40000),
type_=sa.Text(),
existing_nullable=True)
op.alter_column('comments', 'body_html',
existing_type=sa.VARCHAR(length=40000),
type_=sa.Text(),
nullable=False)
op.alter_column('submissions', 'body',
existing_type=sa.VARCHAR(length=40000),
type_=sa.Text(),
existing_nullable=True)
op.alter_column('submissions', 'body_html',
existing_type=sa.VARCHAR(length=40000),
type_=sa.Text(),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('submissions', 'body_html',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=40000),
existing_nullable=True)
op.alter_column('submissions', 'body',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=40000),
existing_nullable=True)
op.alter_column('oauth_apps', 'redirect_uri',
existing_type=sa.String(length=50),
type_=sa.VARCHAR(length=4096),
existing_nullable=False)
op.alter_column('oauth_apps', 'client_id',
existing_type=sa.String(),
type_=sa.CHAR(length=64),
existing_nullable=True)
op.alter_column('comments', 'body_html',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=40000),
nullable=True)
op.alter_column('comments', 'body',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=40000),
existing_nullable=True)
# ### end Alembic commands ###