title: Postgresql 9.6 with multi-tenancy - INHERIT says child table has column with different data type but it doesn't
body: <p>I've been working with a legacy rails app that has had the same "inherit" migration that has run plenty of times in the past but suddenly is complaining that one of the child tables has a column of different type than the parent table in the public schema, but when I inspect things in the database, that doesn't appear to be true. See code examples below</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Apartment::Tenant.switch("child_schema")
  
  # local variable assigned in a looping array of table names...
  table = "categories"
  ActiveRecord::Base.connection.execute("ALTER TABLE #{table} INHERIT public.#{table}")
  
  -- ERROR:
  
  ActiveRecord::StatementInvalid: PG::DatatypeMismatch: ERROR:  child table "categories" has different type for column "name"
  : ALTER TABLE categories INHERIT public.categories
  
  from /var/bundle/ruby/2.3.0/gems/activerecord-4.2.11.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
  </code></pre>
  
  <p><strong>Inspection</strong></p>
  
  <pre><code>&gt; ActiveRecord::Base.connection.execute("select column_name,data_type from information_schema.columns where table_schema = 'child_schema' AND table_name = 'categories';").to_a
  
   =&gt; [{"column_name"=&gt;"id", "data_type"=&gt;"integer"}, {"column_name"=&gt;"name", "data_type"=&gt;"character varying"}] 
  
  
  &gt; ActiveRecord::Base.connection.execute("select column_name,data_type from information_schema.columns where table_schema = 'public' AND table_name = 'categories';").to_a
  
  =&gt; [{"column_name"=&gt;"id", "data_type"=&gt;"integer"}, {"column_name"=&gt;"name", "data_type"=&gt;"character varying"}] 
  </code></pre>
  
  <p>I'm really at a loss here for what to do, I have tried searching google and SO, looking over postgresql INHERIT docs, rooting around for rails / apartment issues, and cannot find any information.</p>
  
  <p><strong>Update</strong></p>
  
  <p>It looks like if I do this:</p>
  
  <pre><code>&gt; Category.connection.columns('public.categories')
  &gt; Category.connection.columns('child_schema.categories')
  </code></pre>
  
  <p>I get a difference in column types now:</p>
  
  <pre><code># Public parent table:
  =&gt; [#&lt;ActiveRecord::ConnectionAdapters::PostgreSQLColumn: #...
  @name="name", #...
  @sql_type="character varying(255)" #...
  
  # child_schema child table:
  =&gt; [#&lt;ActiveRecord::ConnectionAdapters::PostgreSQLColumn: #...
  @name="name", #...
  @sql_type="character varying" #...
  </code></pre>
  
  <p>Alright, so... anyone have a clue how I might find out why the child schema table got a slightly different type?</p>
  
  <p>I can't find that there is any migration to adjust the column type / length, and the tenant creation code just runs apartment's tenant create method with the tenant name. </p>