title: Alembic ignore specific tables
body: <p>I'm using alembic to manage database migrations as per user defined sqlalchemy models. My challenge is that <em><strong>I'd like for alembic to ignore any creation, deletion, or changes to a specific set of tables.</strong></em></p>
  <p><strong>Note:</strong> My Q is similar to this question <a href="https://stackoverflow.com/questions/54978681/ignoring-a-model-when-using-alembic-autogenerate">Ignoring a model when using alembic autogenerate</a> but is different in that I want to control alembic from outside the model definition.</p>
  <p>Here's a sample table I want to ignore:</p>
  <pre><code>from sqlalchemy import MetaData
  from sqlalchemy.ext.declarative import declarative_base
  Base = declarative_base(metadata=MetaData())
  
  class Ignore1(Base):
      &quot;&quot;&quot;
      Signed in to the account...
      &quot;&quot;&quot;
      __tablename__ = 'ignore_1'
      __table_args__ = {
          'info':{'skip_autogenerate':True}
          }
      id = Column(Integer, primary_key=True)
      foo = Column(String(20), nullable=True)
  </code></pre>
  <p>Example code (which does not solve my issue): <br>
  <strong>In <code>alembic/env.py</code></strong></p>
  <pre class="lang-py prettyprint-override"><code># Ideally this is stored in my actual database, but for now, let's assume we have a list...
  IGNORE_TABLES = ['ignore_1', 'ignore_2']
  
  def include_object(object, name, type_, reflected, compare_to):
      &quot;&quot;&quot;
      Should you include this table or not?
      &quot;&quot;&quot;
  
      if type_ == 'table' and (name in IGNORE_TABLES or object.info.get(&quot;skip_autogenerate&quot;, False)):
          return False
  
      elif type_ == &quot;column&quot; and object.info.get(&quot;skip_autogenerate&quot;, False):
          return False
  
      return True
  
  # Then add to config
  context.configure(
      ...
      include_object=include_object,
      ...
      )
  </code></pre>