Moved some text fields over to longtext type (#21)

This commit is contained in:
Jeremy "EndenDragon" Zhang 2017-07-09 17:15:45 -07:00 committed by Jeremy Zhang
parent 228ebe6684
commit 82db716b61
5 changed files with 153 additions and 10 deletions

View File

@ -10,10 +10,10 @@ class Guilds(Base):
chat_links = db.Column(db.Boolean()) # If users can post links
bracket_links = db.Column(db.Boolean()) # If appending brackets to links to prevent embed
mentions_limit = db.Column(db.Integer) # If there is a limit on the number of mentions in a msg
roles = db.Column(db.Text()) # Guild Roles
channels = db.Column(db.Text()) # Guild channels
webhooks = db.Column(db.Text()) # Guild webhooks
emojis = db.Column(db.Text()) # Guild Emojis
roles = db.Column(db.Text(length=4294967295)) # Guild Roles
channels = db.Column(db.Text(length=4294967295))# Guild channels
webhooks = db.Column(db.Text(length=4294967295))# Guild webhooks
emojis = db.Column(db.Text(length=4294967295)) # Guild Emojis
owner_id = db.Column(db.String(255)) # Snowflake of the owner
icon = db.Column(db.String(255)) # The icon string, null if none
discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link

View File

@ -64,7 +64,8 @@ def run_migrations_online():
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata
target_metadata=target_metadata,
compare_type=True
)
with context.begin_transaction():

View File

@ -0,0 +1,142 @@
"""Moved some text columns to longtext type
Revision ID: 40cbd3e0f22d
Revises: 9bf2adbc33e8
Create Date: 2017-07-10 00:01:53.940034
"""
# revision identifiers, used by Alembic.
revision = '40cbd3e0f22d'
down_revision = '9bf2adbc33e8'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('cosmetics', 'css',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False)
op.alter_column('guild_members', 'active',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guild_members', 'banned',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'0'"))
op.alter_column('guilds', 'bracket_links',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guilds', 'channels',
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
type_=sa.Text(length=4294967295),
existing_nullable=False)
op.alter_column('guilds', 'chat_links',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guilds', 'emojis',
existing_type=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
type_=sa.Text(length=4294967295),
existing_nullable=False)
op.alter_column('guilds', 'roles',
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
type_=sa.Text(length=4294967295),
existing_nullable=False)
op.alter_column('guilds', 'unauth_users',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guilds', 'visitor_view',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False)
op.alter_column('guilds', 'webhooks',
existing_type=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
type_=sa.Text(length=4294967295),
existing_nullable=False)
op.alter_column('unauthenticated_users', 'revoked',
existing_type=mysql.TINYINT(display_width=1),
type_=sa.Boolean(),
existing_nullable=False,
existing_server_default=sa.text(u"'0'"))
op.alter_column('user_css', 'css',
existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
type_=sa.Text(length=4294967295),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('user_css', 'css',
existing_type=sa.Text(length=4294967295),
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
existing_nullable=True)
op.alter_column('unauthenticated_users', 'revoked',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'0'"))
op.alter_column('guilds', 'webhooks',
existing_type=sa.Text(length=4294967295),
type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
existing_nullable=False)
op.alter_column('guilds', 'visitor_view',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False)
op.alter_column('guilds', 'unauth_users',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guilds', 'roles',
existing_type=sa.Text(length=4294967295),
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
existing_nullable=False)
op.alter_column('guilds', 'emojis',
existing_type=sa.Text(length=4294967295),
type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'),
existing_nullable=False)
op.alter_column('guilds', 'chat_links',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guilds', 'channels',
existing_type=sa.Text(length=4294967295),
type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'),
existing_nullable=False)
op.alter_column('guilds', 'bracket_links',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('guild_members', 'banned',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'0'"))
op.alter_column('guild_members', 'active',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False,
existing_server_default=sa.text(u"'1'"))
op.alter_column('cosmetics', 'css',
existing_type=sa.Boolean(),
type_=mysql.TINYINT(display_width=1),
existing_nullable=False)
# ### end Alembic commands ###

View File

@ -10,10 +10,10 @@ class Guilds(db.Model):
chat_links = db.Column(db.Boolean(), nullable=False, default=1) # If users can post links
bracket_links = db.Column(db.Boolean(), nullable=False, default=1) # If appending brackets to links to prevent embed
mentions_limit = db.Column(db.Integer, nullable=False, default=11) # If there is a limit on the number of mentions in a msg
roles = db.Column(db.Text(), nullable=False) # Guild Roles
channels = db.Column(db.Text(), nullable=False) # Guild channels
webhooks = db.Column(db.Text(), nullable=False) # Guild webhooks
emojis = db.Column(db.Text(), nullable=False) # Guild Emojis
roles = db.Column(db.Text(4294967295), nullable=False) # Guild Roles
channels = db.Column(db.Text(4294967295), nullable=False) # Guild channels
webhooks = db.Column(db.Text(4294967295), nullable=False) # Guild webhooks
emojis = db.Column(db.Text(4294967295), nullable=False) # Guild Emojis
owner_id = db.Column(db.String(255), nullable=False) # Snowflake of the owner
icon = db.Column(db.String(255)) # The icon string, null if none
discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link

View File

@ -5,7 +5,7 @@ class UserCSS(db.Model):
id = db.Column(db.Integer, primary_key=True) # Auto increment id
name = db.Column(db.String(255), nullable=False) # CSS Name
user_id = db.Column(db.String(255), nullable=False) # Discord client ID of the owner of the css (can edit)
css = db.Column(db.Text()) # CSS contents
css = db.Column(db.Text(4294967295)) # CSS contents
def __init__(self, name, user_id, css=None):
self.name = name