patch rails 4 schema.rb generation to include sharded tables

When rails generates db/schema.rb, it previously did not include any sharded tables. This adds an additional `ActiveRecord::Schema.define` block populated with the sharded tables. The sharded database will receive its own `schema_migrations` table when running `rake db:schema:load`.

This behavior currently only occurs on Rails 4+ / Ruby 2+

I prefer the indented, makes the code less ugly to my eyes, but either way
is fine ;)


On Tue, Jul 8, 2014 at 5:04 PM, Gabe Martin-Dempesy <
notifications@github.com> wrote:

> In lib/active_record_shards/schema_dumper_extension.rb:
>
> > +          extensions(stream)
> > +          tables(stream)
> > +          shard_trailer(stream)
> > +        end
> > +      end
> > +
> > +      stream
> > +    ensure
> > +      @connection = original_connection
> > +    end
> > +
> > +
> > +    def shard_header(stream)
> > +      define_params = @version ? "version: #{@version}" : ""
> > +
> > +      stream.puts <<HEADER
>
> FWIW, it's a copy straight from ActiveRecord:
> https://github.com/rails/rails/blob/master/activerecord/lib/active_record/schema_dumper.rb#L59
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/zendesk/active_record_shards/pull/24/files#r14687676>.
>