]> git.lizzy.rs Git - cheatdb.git/commitdiff
Fix username being case-sensitive v1.4.0
authorrubenwardy <rw@rubenwardy.com>
Sun, 3 Jun 2018 00:50:14 +0000 (01:50 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sun, 3 Jun 2018 00:50:58 +0000 (01:50 +0100)
app/models.py
migrations/versions/28a427cbd4cf_.py [new file with mode: 0644]

index 5780aa0705ade604ddc16a585c8e4176bcd9734a..e5aafd4cb082c6ef188e51cc24ec973e36b1e441 100644 (file)
@@ -96,15 +96,15 @@ class User(db.Model, UserMixin):
        id = db.Column(db.Integer, primary_key=True)
 
        # User authentication information
-       username = db.Column(db.String(50), nullable=False, unique=True)
+       username = db.Column(db.String(50, collation="NOCASE"), nullable=False, unique=True, index=True)
        password = db.Column(db.String(255), nullable=True)
        reset_password_token = db.Column(db.String(100), nullable=False, server_default="")
 
        rank = db.Column(db.Enum(UserRank))
 
        # Account linking
-       github_username = db.Column(db.String(50), nullable=True, unique=True)
-       forums_username = db.Column(db.String(50), nullable=True, unique=True)
+       github_username = db.Column(db.String(50, collation="NOCASE"), nullable=True, unique=True)
+       forums_username = db.Column(db.String(50, collation="NOCASE"), nullable=True, unique=True)
 
        # User email information
        email = db.Column(db.String(255), nullable=True, unique=True)
diff --git a/migrations/versions/28a427cbd4cf_.py b/migrations/versions/28a427cbd4cf_.py
new file mode 100644 (file)
index 0000000..9a59c75
--- /dev/null
@@ -0,0 +1,35 @@
+"""empty message
+
+Revision ID: 28a427cbd4cf
+Revises: e9f534df23a8
+Create Date: 2018-06-03 01:47:33.006039
+
+"""
+from alembic import op
+import sqlalchemy as sa
+import sqlalchemy.types as ty
+
+
+# revision identifiers, used by Alembic.
+revision = '28a427cbd4cf'
+down_revision = 'e9f534df23a8'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column('user','username', type_=ty.VARCHAR(50, collation='NOCASE'))
+    op.alter_column('user','github_username', type_=ty.VARCHAR(50, collation='NOCASE'))
+    op.alter_column('user','forums_username', type_=ty.VARCHAR(50, collation='NOCASE'))
+    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column('user','username', type_=ty.VARCHAR(50))
+    op.alter_column('user','github_username', type_=ty.VARCHAR(50))
+    op.alter_column('user','forums_username', type_=ty.VARCHAR(50))
+    op.drop_index(op.f('ix_user_username'), table_name='user')
+    # ### end Alembic commands ###