Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql key length #459

Merged
merged 2 commits into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions caravel/migrations/versions/4e6a06bad7a8_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def upgrade():
sa.Column('changed_on', sa.DateTime(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('cluster_name', sa.String(length=250), nullable=True),
sa.Column('coordinator_host', sa.String(length=256), nullable=True),
sa.Column('coordinator_host', sa.String(length=255), nullable=True),
sa.Column('coordinator_port', sa.Integer(), nullable=True),
sa.Column('coordinator_endpoint', sa.String(length=256), nullable=True),
sa.Column('broker_host', sa.String(length=256), nullable=True),
sa.Column('coordinator_endpoint', sa.String(length=255), nullable=True),
sa.Column('broker_host', sa.String(length=255), nullable=True),
sa.Column('broker_port', sa.Integer(), nullable=True),
sa.Column('broker_endpoint', sa.String(length=256), nullable=True),
sa.Column('broker_endpoint', sa.String(length=255), nullable=True),
sa.Column('metadata_last_refreshed', sa.DateTime(), nullable=True),
sa.Column('created_by_fk', sa.Integer(), sa.ForeignKey("ab_user.id"), nullable=True),
sa.Column('changed_by_fk', sa.Integer(), sa.ForeignKey("ab_user.id"), nullable=True),
Expand Down Expand Up @@ -58,7 +58,7 @@ def upgrade():
sa.Column('created_on', sa.DateTime(), nullable=False),
sa.Column('changed_on', sa.DateTime(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('datasource_name', sa.String(length=256), nullable=True),
sa.Column('datasource_name', sa.String(length=255), nullable=True),
sa.Column('is_featured', sa.Boolean(), nullable=True),
sa.Column('is_hidden', sa.Boolean(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
Expand Down Expand Up @@ -88,7 +88,7 @@ def upgrade():
sa.Column('changed_on', sa.DateTime(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('datasource_name', sa.String(length=250), nullable=True),
sa.Column('column_name', sa.String(length=256), sa.ForeignKey("datasources.datasource_name"), nullable=True),
sa.Column('column_name', sa.String(length=255), sa.ForeignKey("datasources.datasource_name"), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('type', sa.String(length=32), nullable=True),
sa.Column('groupby', sa.Boolean(), nullable=True),
Expand Down Expand Up @@ -147,7 +147,7 @@ def upgrade():
sa.Column('changed_on', sa.DateTime(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('table_id', sa.Integer(), sa.ForeignKey("tables.id"), nullable=True),
sa.Column('column_name', sa.String(length=256), nullable=True),
sa.Column('column_name', sa.String(length=255), nullable=True),
sa.Column('is_dttm', sa.Boolean(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('type', sa.String(length=32), nullable=True),
Expand Down
102 changes: 102 additions & 0 deletions caravel/migrations/versions/956a063c52b3_adjusting_key_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""adjusting key length

Revision ID: 956a063c52b3
Revises: f0fbf6129e13
Create Date: 2016-05-11 17:28:32.407340

"""

# revision identifiers, used by Alembic.
revision = '956a063c52b3'
down_revision = 'f0fbf6129e13'

from alembic import op
import sqlalchemy as sa


def upgrade():
with op.batch_alter_table('clusters', schema=None) as batch_op:
batch_op.alter_column('broker_endpoint',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)
batch_op.alter_column('broker_host',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)
batch_op.alter_column('coordinator_endpoint',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)
batch_op.alter_column('coordinator_host',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)

with op.batch_alter_table('columns', schema=None) as batch_op:
batch_op.alter_column('column_name',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)

with op.batch_alter_table('datasources', schema=None) as batch_op:
batch_op.alter_column('datasource_name',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)

with op.batch_alter_table('table_columns', schema=None) as batch_op:
batch_op.alter_column('column_name',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)

with op.batch_alter_table('tables', schema=None) as batch_op:
batch_op.alter_column('schema',
existing_type=sa.VARCHAR(length=256),
type_=sa.String(length=255),
existing_nullable=True)


def downgrade():
with op.batch_alter_table('tables', schema=None) as batch_op:
batch_op.alter_column('schema',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)

with op.batch_alter_table('table_columns', schema=None) as batch_op:
batch_op.alter_column('column_name',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)

with op.batch_alter_table('datasources', schema=None) as batch_op:
batch_op.alter_column('datasource_name',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)

with op.batch_alter_table('columns', schema=None) as batch_op:
batch_op.alter_column('column_name',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)

with op.batch_alter_table('clusters', schema=None) as batch_op:
batch_op.alter_column('coordinator_host',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)
batch_op.alter_column('coordinator_endpoint',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)
batch_op.alter_column('broker_host',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)
batch_op.alter_column('broker_endpoint',
existing_type=sa.String(length=255),
type_=sa.VARCHAR(length=256),
existing_nullable=True)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def upgrade():
op.add_column('tables', sa.Column('schema', sa.String(length=256), nullable=True))
op.add_column('tables', sa.Column('schema', sa.String(length=255), nullable=True))


def downgrade():
Expand Down
16 changes: 8 additions & 8 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
'Database', backref='tables', foreign_keys=[database_id])
offset = Column(Integer, default=0)
cache_timeout = Column(Integer)
schema = Column(String(256))
schema = Column(String(255))

baselink = "tablemodelview"

Expand Down Expand Up @@ -856,7 +856,7 @@ class TableColumn(Model, AuditMixinNullable):
table_id = Column(Integer, ForeignKey('tables.id'))
table = relationship(
'SqlaTable', backref='columns', foreign_keys=[table_id])
column_name = Column(String(256))
column_name = Column(String(255))
verbose_name = Column(String(1024))
is_dttm = Column(Boolean, default=False)
is_active = Column(Boolean, default=True)
Expand Down Expand Up @@ -895,13 +895,13 @@ class DruidCluster(Model, AuditMixinNullable):
__tablename__ = 'clusters'
id = Column(Integer, primary_key=True)
cluster_name = Column(String(250), unique=True)
coordinator_host = Column(String(256))
coordinator_host = Column(String(255))
coordinator_port = Column(Integer)
coordinator_endpoint = Column(
String(256), default='druid/coordinator/v1/metadata')
broker_host = Column(String(256))
String(255), default='druid/coordinator/v1/metadata')
broker_host = Column(String(255))
broker_port = Column(Integer)
broker_endpoint = Column(String(256), default='druid/v2')
broker_endpoint = Column(String(255), default='druid/v2')
metadata_last_refreshed = Column(DateTime)

def __repr__(self):
Expand Down Expand Up @@ -937,7 +937,7 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):

__tablename__ = 'datasources'
id = Column(Integer, primary_key=True)
datasource_name = Column(String(256), unique=True)
datasource_name = Column(String(255), unique=True)
is_featured = Column(Boolean, default=False)
is_hidden = Column(Boolean, default=False)
description = Column(Text)
Expand Down Expand Up @@ -1330,7 +1330,7 @@ class DruidColumn(Model, AuditMixinNullable):
# Setting enable_typechecks=False disables polymorphic inheritance.
datasource = relationship('DruidDatasource', backref='columns',
enable_typechecks=False)
column_name = Column(String(256))
column_name = Column(String(255))
is_active = Column(Boolean, default=True)
type = Column(String(32))
groupby = Column(Boolean, default=False)
Expand Down