To be clear, I think this is exactly what I'm proposing with an NHibernate.Migrations library. To be clear my pull request is in regards to some extra methods on Dialect that are needed to support that.
That said, I would be concerned if the proposed NHibernate.Migrations library produced sql significantly different from the schema generation tools in NHibernate.Tool.hbm2ddl. More over, there don't seem to be adequate test cases around the existing schema generation. So, my proposal goes like this: Work up a low level ddl generation framework in NHibernate proper with tests which is able to support both the existing tools and NHibernate.Migrations. Rework the existing hbm2ddl tools to utilize this framework. Create the NHibernate.Migrations framework which exposes a DSL over top of the underlying framework, handles versioning, and other higher level concerns like DB creation. I dont really have a preference for where the system for calcuating deltas lives so long as its able to support taking the difference between two Configurations as well as working off db metadata. Basically the existing system never generates drop statements. Partially because of the degree of automation but also because its generating its deltas off dbmetadata which might contain tables outside NHibernate's knowledge. By using mappings as a source for this information we can more accurately account for drops. On Sunday, July 13, 2014 10:59:36 AM UTC-4, Alexander Zaytsev wrote: > > I think that you are trying from the wrong end. > > IMO nhibernate should only provide info about what is missed, needs to be > added, or changed. And other tool should consume this info and generate > migrations in DSL for particular migrator (fluent-migrator or other) > > Best Regards, > Alexander > 12.07.2014 21:57 пользователь "Jeffrey Becker" <jeffrey....@gmail.com > <javascript:>> написал: > >> I'd want to talk the architecture through a lot more before proposing >> that. If people are interested in a NHibernate branded project and are >> willing to have some discussion of how it works, sure. >> On Jul 12, 2014 11:38 AM, "Ricardo Peres" <rjp...@gmail.com <javascript:>> >> wrote: >> >>> What about starting NHibernate.Migrations? >>> ;-) >>> >>> RP >>> >>> On Saturday, July 12, 2014 1:53:12 AM UTC+1, Jeffrey Becker wrote: >>>> >>>> Ultimately I intend to drive my ddl off calculating the difference >>>> between two mappings much like EF where as Schema update bases its ddl on >>>> database metadata. I'm sure that both mechanisms could utilize a common >>>> set of underlying classes to encapsulate their ddl generation. However, >>>> the existing schema generation code has all of like 3 unit tests against >>>> it >>>> all of them as a result of someone finding a bug. I'd be much more >>>> comfortable building up a good suite of tests outside Nhibernate before >>>> even considering trying that. >>>> >>>> On Friday, July 11, 2014 7:35:27 PM UTC-4, Darren Kopp wrote: >>>>> >>>>> Oh ok, that's good, I thought you were planning on using this >>>>> functionality in the SchemaUpdate class >>>>> <https://github.com/nhibernate/nhibernate-core/blob/master/src/NHibernate/Tool/hbm2ddl/SchemaUpdate.cs>. >>>>> >>>>> I actually think this functionality would be useful in that class as >>>>> well, >>>>> but opt-in, which is what I was referring to. >>>>> >>>>> On Friday, July 11, 2014 3:21:18 PM UTC-6, Jeffrey Becker wrote: >>>>>> >>>>>> Yes, I fully agree that any migration behavior needs to be completely >>>>>> opt-in. To be clear I'm not proposing to rewrite any of the current Sql >>>>>> generation code. I proposed to implement this as a library *separate >>>>>> library outside NHibernate* proper which implements a workflow with >>>>>> the two-step process and customizable migration. All I'm asking for >>>>>> here >>>>>> is some decorator methods on Dialect which provide the necessary chunks >>>>>> of >>>>>> sql and flags to make stuff sql-flavor independent. >>>>>> >>>>>> For example, when altering column definitions: >>>>>> Sql Server uses "Alter [Table] Alter [Column]...", Oracle uses"Alter >>>>>> [Table] Modify [Column]", Firebird and SQLite don't support altering >>>>>> columns. One of the commits in the pull request adds 2 properties to >>>>>> Dialect, *SupportsAlterColumn* and *AlterColumnString* >>>>>> >>>>>> I'm sure the DDL generation functionality could be rewritten to use >>>>>> the underlying model that a script is a series of operations which is in >>>>>> turn a series of statements, but why bother? It seems to work but there >>>>>> aren't unit tests around it now so I wouldn't feel safe proposing >>>>>> changes. >>>>>> >>>>>> The pull request is here: >>>>>> https://github.com/nhibernate/nhibernate-core/pull/282 >>>>>> >>>>>> On Friday, July 11, 2014 4:46:11 PM UTC-4, Darren Kopp wrote: >>>>>>> >>>>>>> You need to make this behavior opt-in, otherwise people will upgrade >>>>>>> and possibly lose data because something may not be referenced in the >>>>>>> model >>>>>>> anymore (or perhaps multiple types mapped to same table returning >>>>>>> different >>>>>>> things). Entity framework is a two-step process and you can customize >>>>>>> the >>>>>>> migration, which mitigates this issue, but schema migration is not >>>>>>> customizable and thus should not have this behavior enabled by default. >>>>>>> >>>>>>> On Friday, July 11, 2014 8:33:01 AM UTC-6, Jeffrey Becker wrote: >>>>>>>> >>>>>>>> Ok, pull request is submitted. >>>>>>> >>>>>>> -- >>> >>> --- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "nhibernate-development" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/nhibernate-development/ACTD62W3eo0/unsubscribe >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> nhibernate-development+unsubscr...@googlegroups.com <javascript:>. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> >> --- >> You received this message because you are subscribed to the Google Groups >> "nhibernate-development" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to nhibernate-development+unsubscr...@googlegroups.com >> <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- --- You received this message because you are subscribed to the Google Groups "nhibernate-development" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-development+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.