mirror of https://github.com/apache/superset.git
Fixing mysql install
This commit is contained in:
parent
4a0ea5fff7
commit
26c725171b
|
@ -267,78 +267,78 @@ def load_world_bank_health_n_pop():
|
|||
dash_name = "World's Health Bank Dashboard"
|
||||
dash = db.session.query(Dash).filter_by(dashboard_title=dash_name).first()
|
||||
|
||||
if dash:
|
||||
db.session.delete(dash)
|
||||
js = """\
|
||||
[
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 3,
|
||||
"col": 1,
|
||||
"slice_id": "1",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 1,
|
||||
"slice_id": "2",
|
||||
"row": 3
|
||||
},
|
||||
{
|
||||
"size_y": 8,
|
||||
"size_x": 3,
|
||||
"col": 10,
|
||||
"slice_id": "3",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 6,
|
||||
"col": 1,
|
||||
"slice_id": "4",
|
||||
"row": 6
|
||||
},
|
||||
{
|
||||
"size_y": 5,
|
||||
"size_x": 6,
|
||||
"col": 4,
|
||||
"slice_id": "5",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 6,
|
||||
"col": 7,
|
||||
"slice_id": "6",
|
||||
"row": 9
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 7,
|
||||
"slice_id": "7",
|
||||
"row": 6
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 6,
|
||||
"col": 1,
|
||||
"slice_id": "8",
|
||||
"row": 9
|
||||
}
|
||||
]
|
||||
"""
|
||||
if not dash:
|
||||
dash = Dash()
|
||||
js = textwrap.dedent("""\
|
||||
[
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 3,
|
||||
"col": 1,
|
||||
"slice_id": "1",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 1,
|
||||
"slice_id": "2",
|
||||
"row": 3
|
||||
},
|
||||
{
|
||||
"size_y": 8,
|
||||
"size_x": 3,
|
||||
"col": 10,
|
||||
"slice_id": "3",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 6,
|
||||
"col": 1,
|
||||
"slice_id": "4",
|
||||
"row": 6
|
||||
},
|
||||
{
|
||||
"size_y": 5,
|
||||
"size_x": 6,
|
||||
"col": 4,
|
||||
"slice_id": "5",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 6,
|
||||
"col": 7,
|
||||
"slice_id": "6",
|
||||
"row": 9
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 7,
|
||||
"slice_id": "7",
|
||||
"row": 6
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 6,
|
||||
"col": 1,
|
||||
"slice_id": "8",
|
||||
"row": 9
|
||||
}
|
||||
]
|
||||
""")
|
||||
l = json.loads(js)
|
||||
for i, pos in enumerate(l):
|
||||
pos['slice_id'] = str(slices[i].id)
|
||||
dash = Dash(
|
||||
dashboard_title=dash_name,
|
||||
position_json=json.dumps(l, indent=4),
|
||||
slug="world_health",
|
||||
)
|
||||
for s in slices:
|
||||
dash.slices.append(s)
|
||||
|
||||
dash.dashboard_title = dash_name
|
||||
dash.position_json = json.dumps(l, indent=4)
|
||||
dash.slug = "world_health"
|
||||
|
||||
dash.slices = slices
|
||||
db.session.merge(dash)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
@ -600,83 +600,81 @@ def load_birth_names():
|
|||
print("Creating a dashboard")
|
||||
dash = db.session.query(Dash).filter_by(dashboard_title="Births").first()
|
||||
|
||||
if dash:
|
||||
db.session.delete(dash)
|
||||
js = """
|
||||
[
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 2,
|
||||
"col": 8,
|
||||
"slice_id": "85",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 2,
|
||||
"col": 10,
|
||||
"slice_id": "86",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 2,
|
||||
"col": 1,
|
||||
"slice_id": "87",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 2,
|
||||
"col": 3,
|
||||
"slice_id": "88",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 7,
|
||||
"col": 5,
|
||||
"slice_id": "89",
|
||||
"row": 4
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 7,
|
||||
"col": 1,
|
||||
"slice_id": "90",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 9,
|
||||
"slice_id": "91",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 4,
|
||||
"col": 5,
|
||||
"slice_id": "92",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 4,
|
||||
"col": 1,
|
||||
"slice_id": "93",
|
||||
"row": 3
|
||||
}
|
||||
]
|
||||
"""
|
||||
if not dash:
|
||||
dash = Dash()
|
||||
js = textwrap.dedent("""\
|
||||
[
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 2,
|
||||
"col": 8,
|
||||
"slice_id": "85",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 2,
|
||||
"col": 10,
|
||||
"slice_id": "86",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 2,
|
||||
"col": 1,
|
||||
"slice_id": "87",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 2,
|
||||
"size_x": 2,
|
||||
"col": 3,
|
||||
"slice_id": "88",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 7,
|
||||
"col": 5,
|
||||
"slice_id": "89",
|
||||
"row": 4
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 7,
|
||||
"col": 1,
|
||||
"slice_id": "90",
|
||||
"row": 7
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 3,
|
||||
"col": 9,
|
||||
"slice_id": "91",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 3,
|
||||
"size_x": 4,
|
||||
"col": 5,
|
||||
"slice_id": "92",
|
||||
"row": 1
|
||||
},
|
||||
{
|
||||
"size_y": 4,
|
||||
"size_x": 4,
|
||||
"col": 1,
|
||||
"slice_id": "93",
|
||||
"row": 3
|
||||
}
|
||||
]
|
||||
""")
|
||||
l = json.loads(js)
|
||||
for i, pos in enumerate(l):
|
||||
pos['slice_id'] = str(slices[i].id)
|
||||
dash = Dash(
|
||||
dashboard_title="Births",
|
||||
position_json=json.dumps(l, indent=4),
|
||||
slug="births",
|
||||
)
|
||||
for s in slices:
|
||||
dash.slices.append(s)
|
||||
dash.dashboard_title = "Births"
|
||||
dash.position_json = json.dumps(l, indent=4)
|
||||
dash.slug = "births"
|
||||
dash.slices = slices
|
||||
db.session.merge(dash)
|
||||
db.session.commit()
|
||||
|
|
|
@ -15,150 +15,156 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('css_templates', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('css_templates', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dashboards', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dashboards', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'changed_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'created_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dbs', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dbs', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.add_column('metrics', sa.Column('changed_by_fk', sa.Integer(), nullable=True))
|
||||
op.add_column('metrics', sa.Column('changed_on', sa.DateTime(), nullable=True))
|
||||
op.add_column('metrics', sa.Column('created_by_fk', sa.Integer(), nullable=True))
|
||||
op.add_column('metrics', sa.Column('created_on', sa.DateTime(), nullable=True))
|
||||
op.create_foreign_key(None, 'metrics', 'ab_user', ['changed_by_fk'], ['id'])
|
||||
op.create_foreign_key(None, 'metrics', 'ab_user', ['created_by_fk'], ['id'])
|
||||
op.alter_column('slices', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('slices', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('sql_metrics', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('sql_metrics', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('table_columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('table_columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('tables', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('tables', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('url', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('url', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
try:
|
||||
op.alter_column('columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('css_templates', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('css_templates', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dashboards', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dashboards', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'changed_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'created_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=True)
|
||||
op.alter_column('datasources', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dbs', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('dbs', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('slices', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('slices', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('sql_metrics', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('sql_metrics', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('table_columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('table_columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('tables', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('tables', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('url', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.alter_column('url', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=True)
|
||||
op.create_foreign_key(None, 'metrics', 'ab_user', ['changed_by_fk'], ['id'])
|
||||
op.create_foreign_key(None, 'metrics', 'ab_user', ['created_by_fk'], ['id'])
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('url', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('url', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('tables', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('tables', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('table_columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('table_columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('sql_metrics', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('sql_metrics', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('slices', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('slices', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.drop_constraint(None, 'metrics', type_='foreignkey')
|
||||
op.drop_constraint(None, 'metrics', type_='foreignkey')
|
||||
op.drop_column('metrics', 'created_on')
|
||||
op.drop_column('metrics', 'created_by_fk')
|
||||
op.drop_column('metrics', 'changed_on')
|
||||
op.drop_column('metrics', 'changed_by_fk')
|
||||
op.alter_column('dbs', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('dbs', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'created_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'changed_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('dashboards', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('dashboards', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('css_templates', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('css_templates', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
try:
|
||||
op.alter_column('url', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('url', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('tables', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('tables', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('table_columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('table_columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('sql_metrics', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('sql_metrics', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('slices', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('slices', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.drop_constraint(None, 'metrics', type_='foreignkey')
|
||||
op.drop_constraint(None, 'metrics', type_='foreignkey')
|
||||
op.alter_column('dbs', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('dbs', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'created_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('datasources', 'changed_by_fk',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
op.alter_column('dashboards', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('dashboards', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('css_templates', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('css_templates', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('columns', 'created_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
op.alter_column('columns', 'changed_on',
|
||||
existing_type=sa.DATETIME(),
|
||||
nullable=False)
|
||||
except:
|
||||
pass
|
||||
|
|
|
@ -634,13 +634,14 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
|||
db.session.flush()
|
||||
if not dbcol:
|
||||
dbcol = TableColumn(column_name=col.name)
|
||||
|
||||
num_types = ('DOUBLE', 'FLOAT', 'INT', 'BIGINT')
|
||||
datatype = str(datatype).upper()
|
||||
if (
|
||||
str(datatype).startswith('VARCHAR') or
|
||||
str(datatype).startswith('STRING')):
|
||||
dbcol.groupby = True
|
||||
dbcol.filterable = True
|
||||
elif str(datatype).upper() in ('DOUBLE', 'FLOAT', 'INT', 'BIGINT'):
|
||||
elif any([t in datatype for t in num_types]):
|
||||
dbcol.sum = True
|
||||
db.session.merge(self)
|
||||
self.columns.append(dbcol)
|
||||
|
@ -746,7 +747,8 @@ class TableColumn(Model, AuditMixinNullable):
|
|||
|
||||
@property
|
||||
def isnum(self):
|
||||
return self.type in ('LONG', 'DOUBLE', 'FLOAT')
|
||||
types = ('LONG', 'DOUBLE', 'FLOAT', 'BIGINT', 'INT')
|
||||
return any([t in self.type.upper() for t in types])
|
||||
|
||||
|
||||
class DruidCluster(Model, AuditMixinNullable):
|
||||
|
|
Loading…
Reference in New Issue