Repository: getredash/redash

Issue:
Migration Error(0017_add_organization.py)
Migration Error with current master branch.

```
$ vagrant@vagrant-ubuntu-trusty-64:/opt/redash/current$ export PYTHONPATH=. && bin/run python migrations/0017_add_organization.py
```
### output

```
[2016-01-05 09:38:42,746][PID:1822][WARNING][redash.query_runner] Oracle query runner enabled but not supported, not registering. Either disable or install missing dependencies.
Traceback (most recent call last):
  File "migrations/0017_add_organization.py", line 12, in <module>
    Organization.SETTING_GOOGLE_APPS_DOMAINS: settings.GOOGLE_APPS_DOMAIN
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4001, in create
    inst.save(force_insert=True)
  File "/opt/redash/current/redash/models.py", line 93, in save
    super(BaseModel, self).save(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4148, in save
    pk_from_cursor = self.insert(**field_dict).execute()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2858, in execute
    cursor = self._execute()
  File "/opt/redash/current/redash/metrics/database.py", line 50, in metered_execute
    result = real_execute(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2370, in _execute
    sql, params = self.sql()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2832, in sql
    return self.compiler().generate_insert(self)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1733, in generate_insert
    return self.build_query(clauses, alias_map)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1542, in build_query
    return self.parse_node(Clause(*clauses), alias_map)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1503, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1478, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1406, in _parse_clause
    node.nodes, alias_map, conv, node.glue)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1520, in parse_node_list
    node_sql, node_params = self.parse_node(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1503, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1478, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1406, in _parse_clause
    node.nodes, alias_map, conv, node.glue)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1520, in parse_node_list
    node_sql, node_params = self.parse_node(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1503, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1478, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1406, in _parse_clause
    node.nodes, alias_map, conv, node.glue)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1520, in parse_node_list
    node_sql, node_params = self.parse_node(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1503, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1478, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 1394, in _parse_param
    params = [node.conv(node.value)]
  File "/opt/redash/current/redash/models.py", line 68, in db_value
    return json.dumps(value)
  File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: set([]) is not JSON serializable
```



Discussion:

Resolving patch:
diff --git a/migrations/0017_add_organization.py b/migrations/0017_add_organization.py
--- a/migrations/0017_add_organization.py
+++ b/migrations/0017_add_organization.py
@@ -9,7 +9,7 @@
         Organization.create_table()
 
         default_org = Organization.create(name="Default", slug='default', settings={
-            Organization.SETTING_GOOGLE_APPS_DOMAINS: settings.GOOGLE_APPS_DOMAIN
+            Organization.SETTING_GOOGLE_APPS_DOMAINS: list(settings.GOOGLE_APPS_DOMAIN)
         })
 
         column = Group.org


Test patch: