From aa9075f4846bd8cfc934db90c8618502fd2ed481 Mon Sep 17 00:00:00 2001 From: "Jeremy \"EndenDragon\" Zhang" Date: Mon, 4 Sep 2017 23:54:54 -0700 Subject: [PATCH] Inital postgresql implementation (#46) --- discordbot/titanembeds/bot.py | 2 +- discordbot/titanembeds/database/guilds.py | 8 ++++---- .../2a2f32ac91d6_added_titan_tokens.py | 20 +++++++++---------- ...oved_some_text_columns_to_longtext_type.py | 20 +++++++++---------- ...fe130518448_create_administrators_table.py | 20 +++++++++---------- ..._added_webhook_messages_boolean_column_.py | 20 +++++++++---------- webapp/titanembeds/app.py | 2 +- webapp/titanembeds/blueprints/user/user.py | 2 +- webapp/titanembeds/database/guilds.py | 8 ++++---- .../database/keyvalue_properties.py | 4 ++-- webapp/titanembeds/database/user_css.py | 2 +- 11 files changed, 54 insertions(+), 54 deletions(-) diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py index 7b658af..9271dae 100644 --- a/discordbot/titanembeds/bot.py +++ b/discordbot/titanembeds/bot.py @@ -84,7 +84,7 @@ class Titan(discord.Client): ) try: - await self.database.connect(config["database-uri"] + "?charset=utf8mb4") + await self.database.connect(config["database-uri"]) self.database_connected = True except Exception: self.logger.error("Unable to connect to specified database!") diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py index 06f0040..233cd0b 100644 --- a/discordbot/titanembeds/database/guilds.py +++ b/discordbot/titanembeds/database/guilds.py @@ -11,10 +11,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(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 + roles = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # Guild Roles + channels = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql'))# Guild channels + webhooks = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql'))# Guild webhooks + emojis = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # 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 diff --git a/webapp/alembic/versions/2a2f32ac91d6_added_titan_tokens.py b/webapp/alembic/versions/2a2f32ac91d6_added_titan_tokens.py index 57b8232..cad565c 100644 --- a/webapp/alembic/versions/2a2f32ac91d6_added_titan_tokens.py +++ b/webapp/alembic/versions/2a2f32ac91d6_added_titan_tokens.py @@ -55,7 +55,7 @@ def upgrade(): existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'channels', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'chat_links', existing_type=mysql.TINYINT(display_width=1), @@ -64,11 +64,11 @@ def upgrade(): existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'emojis', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'roles', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'unauth_users', existing_type=mysql.TINYINT(display_width=1), @@ -81,7 +81,7 @@ def upgrade(): existing_nullable=False) op.alter_column(u'guilds', 'webhooks', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'unauthenticated_users', 'revoked', existing_type=mysql.TINYINT(display_width=1), @@ -90,7 +90,7 @@ def upgrade(): existing_server_default=sa.text(u"'0'")) op.alter_column(u'user_css', 'css', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=True) # ### end Alembic commands ### @@ -98,7 +98,7 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column(u'user_css', 'css', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=True) op.alter_column(u'unauthenticated_users', 'revoked', @@ -107,7 +107,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'0'")) op.alter_column(u'guilds', 'webhooks', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'visitor_view', @@ -120,11 +120,11 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'roles', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'emojis', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'chat_links', @@ -133,7 +133,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'channels', - existing_type=sa.Text(length=4294967295), + existing_typesa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'bracket_links', diff --git a/webapp/alembic/versions/40cbd3e0f22d_moved_some_text_columns_to_longtext_type.py b/webapp/alembic/versions/40cbd3e0f22d_moved_some_text_columns_to_longtext_type.py index 93419b3..6f1559d 100644 --- a/webapp/alembic/versions/40cbd3e0f22d_moved_some_text_columns_to_longtext_type.py +++ b/webapp/alembic/versions/40cbd3e0f22d_moved_some_text_columns_to_longtext_type.py @@ -39,7 +39,7 @@ def upgrade(): 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), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'chat_links', existing_type=mysql.TINYINT(display_width=1), @@ -48,11 +48,11 @@ def upgrade(): 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), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'roles', existing_type=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'unauth_users', existing_type=mysql.TINYINT(display_width=1), @@ -65,7 +65,7 @@ def upgrade(): existing_nullable=False) op.alter_column('guilds', 'webhooks', existing_type=mysql.TEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('unauthenticated_users', 'revoked', existing_type=mysql.TINYINT(display_width=1), @@ -74,7 +74,7 @@ def upgrade(): 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), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=True) # ### end Alembic commands ### @@ -82,7 +82,7 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column('user_css', 'css', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=True) op.alter_column('unauthenticated_users', 'revoked', @@ -91,7 +91,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'0'")) op.alter_column('guilds', 'webhooks', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'visitor_view', @@ -104,11 +104,11 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column('guilds', 'roles', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'emojis', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.TEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'chat_links', @@ -117,7 +117,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column('guilds', 'channels', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.MEDIUMTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'bracket_links', diff --git a/webapp/alembic/versions/6fe130518448_create_administrators_table.py b/webapp/alembic/versions/6fe130518448_create_administrators_table.py index 2968436..a143f12 100644 --- a/webapp/alembic/versions/6fe130518448_create_administrators_table.py +++ b/webapp/alembic/versions/6fe130518448_create_administrators_table.py @@ -44,7 +44,7 @@ def upgrade(): existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'channels', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'chat_links', existing_type=mysql.TINYINT(display_width=1), @@ -53,11 +53,11 @@ def upgrade(): existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'emojis', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'roles', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'guilds', 'unauth_users', existing_type=mysql.TINYINT(display_width=1), @@ -70,7 +70,7 @@ def upgrade(): existing_nullable=False) op.alter_column(u'guilds', 'webhooks', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column(u'unauthenticated_users', 'revoked', existing_type=mysql.TINYINT(display_width=1), @@ -79,7 +79,7 @@ def upgrade(): existing_server_default=sa.text(u"'0'")) op.alter_column(u'user_css', 'css', existing_type=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=True) # ### end Alembic commands ### @@ -87,7 +87,7 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column(u'user_css', 'css', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=True) op.alter_column(u'unauthenticated_users', 'revoked', @@ -96,7 +96,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'0'")) op.alter_column(u'guilds', 'webhooks', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'visitor_view', @@ -109,11 +109,11 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'roles', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'emojis', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'chat_links', @@ -122,7 +122,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text(u"'1'")) op.alter_column(u'guilds', 'channels', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation=u'utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column(u'guilds', 'bracket_links', diff --git a/webapp/alembic/versions/dadcb876cdd9_added_webhook_messages_boolean_column_.py b/webapp/alembic/versions/dadcb876cdd9_added_webhook_messages_boolean_column_.py index f51ad78..c3b4503 100644 --- a/webapp/alembic/versions/dadcb876cdd9_added_webhook_messages_boolean_column_.py +++ b/webapp/alembic/versions/dadcb876cdd9_added_webhook_messages_boolean_column_.py @@ -40,7 +40,7 @@ def upgrade(): existing_server_default=sa.text("'1'")) op.alter_column('guilds', 'channels', existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'chat_links', existing_type=mysql.TINYINT(display_width=1), @@ -49,11 +49,11 @@ def upgrade(): existing_server_default=sa.text("'1'")) op.alter_column('guilds', 'emojis', existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'roles', existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('guilds', 'unauth_users', existing_type=mysql.TINYINT(display_width=1), @@ -66,7 +66,7 @@ def upgrade(): existing_nullable=False) op.alter_column('guilds', 'webhooks', existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=False) op.alter_column('unauthenticated_users', 'revoked', existing_type=mysql.TINYINT(display_width=1), @@ -75,7 +75,7 @@ def upgrade(): existing_server_default=sa.text("'0'")) op.alter_column('user_css', 'css', existing_type=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), - type_=sa.Text(length=4294967295), + type_=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), existing_nullable=True) # ### end Alembic commands ### @@ -83,7 +83,7 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.alter_column('user_css', 'css', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), existing_nullable=True) op.alter_column('unauthenticated_users', 'revoked', @@ -92,7 +92,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text("'0'")) op.alter_column('guilds', 'webhooks', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'visitor_view', @@ -105,11 +105,11 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text("'1'")) op.alter_column('guilds', 'roles', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'emojis', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'chat_links', @@ -118,7 +118,7 @@ def downgrade(): existing_nullable=False, existing_server_default=sa.text("'1'")) op.alter_column('guilds', 'channels', - existing_type=sa.Text(length=4294967295), + existing_type=sa.Text().with_variant(sa.Text(length=4294967295), 'mysql'), type_=mysql.LONGTEXT(collation='utf8mb4_unicode_ci'), existing_nullable=False) op.alter_column('guilds', 'bracket_links', diff --git a/webapp/titanembeds/app.py b/webapp/titanembeds/app.py index 837c4d1..72bb0cc 100644 --- a/webapp/titanembeds/app.py +++ b/webapp/titanembeds/app.py @@ -21,7 +21,7 @@ except: os.chdir(config['app-location']) app = Flask(__name__, static_folder="static") -app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri'] + "?charset=utf8mb4" +app.config['SQLALCHEMY_DATABASE_URI'] = config['database-uri'] app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False # Suppress the warning/no need this on for now. app.config['RATELIMIT_HEADERS_ENABLED'] = True app.config['SQLALCHEMY_POOL_RECYCLE'] = 250 diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 9a2b216..a44cbbe 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -231,7 +231,7 @@ def add_bot(guild_id): def prepare_guild_members_list(members, bans): all_users = [] ip_pool = [] - members = sorted(members, key=lambda k: datetime.datetime.strptime(str(k.last_timestamp), "%Y-%m-%d %H:%M:%S"), reverse=True) + members = sorted(members, key=lambda k: datetime.datetime.strptime(str(k.last_timestamp.replace(tzinfo=None)), "%Y-%m-%d %H:%M:%S"), reverse=True) for member in members: user = { "id": member.id, diff --git a/webapp/titanembeds/database/guilds.py b/webapp/titanembeds/database/guilds.py index 72db66a..bf34715 100644 --- a/webapp/titanembeds/database/guilds.py +++ b/webapp/titanembeds/database/guilds.py @@ -11,10 +11,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(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 + roles = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild Roles + channels = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild channels + webhooks = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild webhooks + emojis = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), 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 diff --git a/webapp/titanembeds/database/keyvalue_properties.py b/webapp/titanembeds/database/keyvalue_properties.py index 8cfaa07..89028af 100644 --- a/webapp/titanembeds/database/keyvalue_properties.py +++ b/webapp/titanembeds/database/keyvalue_properties.py @@ -20,14 +20,14 @@ def set_keyvalproperty(key, value, expiration=None): def get_keyvalproperty(key): q = db.session.query(KeyValueProperties).filter(KeyValueProperties.key == key) now = datetime.now() - if q.count() > 0 and (q.first().expiration is None or q.first().expiration > now): + if q.count() > 0 and (q.first().expiration is None or q.first().expiration.replace(tzinfo=None) > now): return q.first().value return None def getexpir_keyvalproperty(key): q = db.session.query(KeyValueProperties).filter(KeyValueProperties.key == key) now = datetime.now() - if q.count() > 0 and (q.first().expiration is not None and q.first().expiration > now): + if q.count() > 0 and (q.first().expiration is not None and q.first().expiration.replace(tzinfo=None) > now): return int(q.first().expiration.strftime('%s')) return 0 diff --git a/webapp/titanembeds/database/user_css.py b/webapp/titanembeds/database/user_css.py index c70154b..2bbe4d9 100644 --- a/webapp/titanembeds/database/user_css.py +++ b/webapp/titanembeds/database/user_css.py @@ -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(4294967295)) # CSS contents + css = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql')) # CSS contents def __init__(self, name, user_id, css=None): self.name = name