-
Notifications
You must be signed in to change notification settings - Fork 84
Refactoring for 2.0 #197
Comments
I think |
@lowjoel yeah will go with just Re
Though I'm stumped as to what names to give them. |
I'm mixed on this one too. I think for now, the initial grouping proposed at the top of the PR is already modular enough. I don't think there's significant benefit in breaking the I'm starting to be a little concerned about the things we do for Postgres though. Maybe that needs to be factored out? Or we expose high-level features, and implement adapters for each of the database servers? |
@lowjoel yeah, could maybe factor out Postgres. But that's back to arguing for Re whether ...though whether a "single-purpose" would be "enums" or "postgresql enums" is unclear... @donv, @lowjoel, @dimonzozo, @methodmissing, @tovodeverett, @bacrossland (or anyone else!) -- any thoughts on all this? BTW it's looking like there's one more gem that doesn't fit in with the original grouping:
|
@ronen What about supporting PostgreSQL check constraints? Take a look at this gem: https://github.com/take-five/postgresql-check. It is not much popular but seems to work fine. Until now, I ever had to use (I don't know if MySQL or SQLite support checks.) |
@andreynering as far as I know MySQL does't and SQLite does. So, since more than one dbms already supports it, in terms of this refactoring discussion, that'd argue for a generic gem As to whether to actually go ahead and make one -- I'm hoping that once this refactor is done, the In this particular case, if https://github.com/take-five/postgresql-check already works, there might not be any particular reason to write another one. (Unless the that gem's monkey patching and schema_plus's monkey patching collide, which could happen.) BTW there's a long-standing request for check constraints (#92), and @adymo started implementing it (#128) a while back. Unfortunately he ran into difficulty and asked for help which I realize now I never responded to (sigh, I suck -- sorry @adymo). Again I'm hoping that once I get all this installed, it'll be a lot easier to make a small gem to do it. [For more discussion specific to check constraints, let's move it back to #92 or open a new issue; I'd like to keep this issue focused on general architectural issues of how to best organize the refactor.] Thanks! |
FYI my latest thought is that it'd be good to have a reasonable consistent naming scheme. Here's my proposal:
|
Sounds good to me. |
👍 |
Thanks for the feedback. FYI I've pushed out the first two feature gems:
I've also pushed out https://github.com/SchemaPlus/schema_monkey but it's still entirely undocumented, and doesn't even have specs :( Will need to address that soon. And there's plenty more to add to it, I'll be doing that incrementally as I peel out more feature gems from the refactor branch. |
FYI, I've pushed out schema_plus 2.0.0.pre4. Some major refactoring and cleanup: schema_monkey has been split into four(!) gems.
All are documented, all have specs with 100% coverage. schema_plus itself still has a grabbag of the feature-gems-to-be; many of them do some monkey-patching that should move into schema_plus_core. But it's getting cleaner and easier to do. |
FYI pushed out schema_plus 2.0.0.pre5, with support for views pulled out into a feature gem: |
Great going, @ronen ! |
FYI pushed out schema_plus 2.0.0.pre6 and schema_plus_columns |
(Oh it also includes the bug fix for #203 pulled over from the 1.x branch) |
FYI pushed out schema_plus 2.0.0.pre7 and schema_plus_tables |
pushed out schema_plus 2.0.0.pre8 -- no longer includes now-unneccessary schema_monkey_rails. (also some other changes on the way towards pulling out auto-fk) |
pushed out schema_plus 2.0.0.pre9 and schema_plus_enums |
released schema_plus 2.0.0.pre10 which support AR 4.2.1 as well as 4.2.0 |
released schema_plus 2.0.0.pre11 and schema_plus_db_default |
released schema_plus 2.0.0.pre12 and schema_plus_default_expr |
releases 2.0.0.pre13, .pre14, and .pre15 were bug fixes. now released schema_plus 2.0.0.pre16 and schema_plus_foreign_keys |
extracted schema_auto_foreign_keys... ...and released version 2.0.0 finally. whew. |
Hi all, I'm putting this out for feedback before I start creating new gems.
The
refactor
branch is coming along nicely, roughly along the lines proposed in #168 and #188 . Below the line I've listed all the new gems. (They are all currently living under 'lib/')I'm open to suggestions for better gem names, for different partitioning of the functionality, anything else...?
schema_monkey
This monkey-patches AR to create a bunch of internal-api hooks, using a 'middleware' style, thanks to the mitchellh/middleware gem. Not everything can currently be done using the middleware hooks; but quite a fair bit can. And I'm continuing to update schema_monkey as this refactor goes on and I observe new patterns. The goal is that a gem might need to add new methods to AR classes, but shouldn't (a) redefine existing AR methods nor (b) call AR internal methods. It's getting pretty close.
It also does a bunch of configuration based on convention; so each individual feature gem only needs to do
SchemaMonkey.register(FeatureGemModule)
and everything gets set up and inserted into rails automatically.(Sorry, not documented yet.)
schema_db_default
Adds the ability to do
record.update_attributes(attr: ActiveRecord::DB_DEFAULT)
to update the attribute to the default value specified in the db schema.schema_default_expr
Adds the ability to specify an SQL expression for
t.column :foo, default: { expr: "an SQL expression" }
, and also a shorthanddefault: :now
for timestamp columns. [Or does AR4.2 already support default expressions?]schema_index_plus.rb
[Better name?] Adds shorthands to the migration DSL. e.g.
index: true
,index: :unique
. Also adds multi-column indexes viaindex: { with: ['other', 'columns'] }. Also adds things like
:if_exists` to drop_index, and more consistent behavior for duplicate. Plus, for postgresql it adds support for expressions, operator classes, and case-insensitive. [It's feeling a bit like a bit of a grab-bag. Maybe pull the postgresql enhancements into a separate gem?]schema_pg_enums
Adds support for postgresql enums. [Or name it just
schema_enums
. It'll only support posgresql for now, but who knows, maybe later...]schema_views
Adds support for create_view etc.
schema_foreign_keys
[Not yet teased out from the schema_plus code, not yet cleaned up to use schema_monkey for all monkey patching] The foreign key DSL additions and behavior.
schema_plus
This will just include all(?) the others and deprecate
SchemaPlus.config
in favor ofSchemaForeignKeys.config
Thanks for any comments!
The text was updated successfully, but these errors were encountered: