<p dir="auto"><strong>Migrated issue, originally created by Wichert Akkerman (<a href="https://github.com/wichert">@wichert</a>)</strong></p>
<p dir="auto">I'm used to metadata.create_all() being very smart and creating everything as needed. I seem to have found a gap in its knowledge though: enum types that are only used in PostgreSQL ARRAY types are not created. The attached test case gives this output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2015-05-29 14:40:08,477 INFO sqlalchemy.engine.base.Engine select version()
2015-05-29 14:40:08,477 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,478 INFO sqlalchemy.engine.base.Engine select current_schema()
2015-05-29 14:40:08,478 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,480 INFO sqlalchemy.engine.base.Engine show standard_conforming_strings
2015-05-29 14:40:08,480 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,481 INFO sqlalchemy.engine.base.Engine select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname=%(name)s
2015-05-29 14:40:08,481 INFO sqlalchemy.engine.base.Engine {'name': 'pizza'}
2015-05-29 14:40:08,482 INFO sqlalchemy.engine.base.Engine 
CREATE TABLE pizza (
	id SERIAL NOT NULL, 
	toppings topping[], 
	PRIMARY KEY (id)
)


2015-05-29 14:40:08,482 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,483 INFO sqlalchemy.engine.base.Engine ROLLBACK
Traceback (most recent call last):
  File &quot;/Users/wichert/Jzoo/backend/lib/python3.4/site-packages/sqlalchemy/engine/base.py&quot;, line 1139, in _execute_context
    context)
  File &quot;/Users/wichert/Jzoo/backend/lib/python3.4/site-packages/sqlalchemy/engine/default.py&quot;, line 442, in do_execute
    cursor.execute(statement, parameters)
psycopg2.ProgrammingError: type &quot;topping[]&quot; does not exist
LINE 4:  toppings topping[], "><pre class="notranslate"><code class="notranslate">2015-05-29 14:40:08,477 INFO sqlalchemy.engine.base.Engine select version()
2015-05-29 14:40:08,477 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,478 INFO sqlalchemy.engine.base.Engine select current_schema()
2015-05-29 14:40:08,478 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1
2015-05-29 14:40:08,479 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,480 INFO sqlalchemy.engine.base.Engine show standard_conforming_strings
2015-05-29 14:40:08,480 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,481 INFO sqlalchemy.engine.base.Engine select relname from pg_class c join pg_namespace n on n.oid=c.relnamespace where pg_catalog.pg_table_is_visible(c.oid) and relname=%(name)s
2015-05-29 14:40:08,481 INFO sqlalchemy.engine.base.Engine {'name': 'pizza'}
2015-05-29 14:40:08,482 INFO sqlalchemy.engine.base.Engine 
CREATE TABLE pizza (
	id SERIAL NOT NULL, 
	toppings topping[], 
	PRIMARY KEY (id)
)


2015-05-29 14:40:08,482 INFO sqlalchemy.engine.base.Engine {}
2015-05-29 14:40:08,483 INFO sqlalchemy.engine.base.Engine ROLLBACK
Traceback (most recent call last):
  File "/Users/wichert/Jzoo/backend/lib/python3.4/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/Users/wichert/Jzoo/backend/lib/python3.4/site-packages/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
psycopg2.ProgrammingError: type "topping[]" does not exist
LINE 4:  toppings topping[], 
</code></pre></div>
<hr>
<p dir="auto">Attachments: <a href="../wiki/imported_issue_attachments/3437/x.py">x.py</a></p>
<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">metadata.create_all do not create work_place_roles if Enum in sqlalchemy.dialects.postgresql.ARRAY</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class WorkPlacement(Base):
    __tablename__ = 'work_placement'

    roles = Column(ARRAY(Enum('manager', 'place_admin', 'carwash_admin',
                                      'parking_admin', 'service_admin', 'tire_admin',
                                      'mechanic', 'carwasher', 'tire_mechanic', name=&quot;work_place_roles&quot;)))"><pre class="notranslate"><code class="notranslate">class WorkPlacement(Base):
    __tablename__ = 'work_placement'

    roles = Column(ARRAY(Enum('manager', 'place_admin', 'carwash_admin',
                                      'parking_admin', 'service_admin', 'tire_admin',
                                      'mechanic', 'carwasher', 'tire_mechanic', name="work_place_roles")))
</code></pre></div>
<p dir="auto">i need do so:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class WorkPlacement(Base):
    __tablename__ = 'work_placement'


    tmp_role = Column(Enum('manager', 'place_admin', 'carwash_admin',
                                      'parking_admin', 'service_admin', 'tire_admin',
                                      'mechanic', 'carwasher', 'tire_mechanic', name=&quot;work_place_roles&quot;))
    roles = Column(ARRAY(Enum(name=&quot;work_place_roles&quot;)))"><pre class="notranslate"><code class="notranslate">class WorkPlacement(Base):
    __tablename__ = 'work_placement'


    tmp_role = Column(Enum('manager', 'place_admin', 'carwash_admin',
                                      'parking_admin', 'service_admin', 'tire_admin',
                                      'mechanic', 'carwasher', 'tire_mechanic', name="work_place_roles"))
    roles = Column(ARRAY(Enum(name="work_place_roles")))
</code></pre></div>