Skip to content

Commit

Permalink
fix dataset title length
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaujp committed Jan 28, 2021
1 parent 6a38f42 commit 6efc2b4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
url=url, target_metadata=target_metadata, literal_binds=True, compare_type=True
)

with context.begin_transaction():
Expand All @@ -68,7 +68,7 @@ def run_migrations_online():

with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
connection=connection, target_metadata=target_metadata, compare_type=True
)

with context.begin_transaction():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""change dataset title length
Revision ID: 777453724560
Revises: bad466dcd0cd
Create Date: 2021-01-29 04:06:38.055487
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '777453724560'
down_revision = 'bad466dcd0cd'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('data_sets', 'title',
existing_type=mysql.VARCHAR(collation='utf8mb4_bin', length=32),
type_=sa.String(length=64),
existing_nullable=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('data_sets', 'title',
existing_type=sa.String(length=64),
type_=mysql.VARCHAR(collation='utf8mb4_bin', length=32),
existing_nullable=False)
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion server/dbcls/api/resources/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def patch(self, id):

# DataSet更新
if args.get('title') is not None:
data_set.title = args['title'][:32]
data_set.title = args['title'][:64]
if args.get('is_public') is not None:
data_set.is_public = args['is_public']
db.session.add(data_set)
Expand Down
3 changes: 1 addition & 2 deletions server/dbcls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class User(db.Model):
firebase_uid = db.Column(db.String(255), unique=True, nullable=False)
display_name = db.Column(db.String(30), default='', nullable=False)
contact_uri = db.Column(db.String(255), default='', nullable=False)

def __repr__(self):
return f'<User id={self.id} firebase_uid={self.firebase_uid}>'

Expand Down Expand Up @@ -60,7 +59,7 @@ class DataSet(db.Model):

id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
title = db.Column(db.String(32), default='', nullable=False)
title = db.Column(db.String(64), default='', nullable=False)
path = db.Column(db.String(255), unique=True, nullable=False)
content = deferred(db.Column(db.JSON))
upload_at = db.Column(db.DateTime, nullable=False)
Expand Down

0 comments on commit 6efc2b4

Please sign in to comment.