On Dec 13, 12:06 am, coolesting <[email protected]> wrote: > Hi, jerreny, thanks your answer, > > REFERENCE BEGIN >>> > Assuming your modules were independent, you could start with an empty > database, run just the particular module's migration files on it, and > then dump the schema of the result. But that's not the case. > > >>> REFERENCE END > > As you said , that is the case, but not start with an empty database, > any modules will use the same connect of database. When we install the > CORE module, it will initailizes the database, the CORE module is > depended by any modules. > > Assuming, my app has one core module and two module, the tree of > directory structure as the following, > > /myapp > /myapp/db > /myapp/config.ru > /myapp/readme.rdoc > /myapp/Gemfile > /myapp/public > /... > /myapp/modules > /... > /myapp/modules/core > /myapp/modules/core/app > /myapp/modules/core/views > /myapp/modules/core/migrations > /... > /myapp/modules/blog > /myapp/modules/blog/app > /myapp/modules/blog/views > /myapp/modules/blog/migrations > /... > /myapp/modules/forums > /myapp/modules/forums/app > /myapp/modules/forums/views > /myapp/modules/forums/migrations > /... > /myapp/modules/wiki > /myapp/modules/wiki/app > /myapp/modules/wiki/views > /myapp/modules/wiki/migrations > /... > /... other modules > /... > > As you see, the migrations directory of CORE module stores the > migration that created the USER table. And the migration of BLOG > module will denpends the USER table, it also alters some columns of > the USER table. (such as, add a ADDRESS field to USER table) > Similarly, the FORUMS and others modules will depends the CORE module > for the USER table. > > Now, we need to packup the BLOG module and commit to the module > repository for someone using it again. We need packup any operations > of migration of database to the installing package of module. > > So, we how to export the schema to a migration that has ever operated > the database. Or anyelse we can do as the better way > to packup the database operation.
You can't export the "schema" in this case. The other "modules" like wiki/forums/blog modify tables they do not create. Therefore, the term "schema" is ambiguous, as you don't have a defined starting point. You may be asking how to combine multiple migrations into a single migration. But you haven't explained why you need that (hint: you probably don't). Maybe what you are asking for is how to keep track of each module's migrations separately. You can do that using a separate database migration column per module (Sequel's migrator already supports that if you use the API). But that doesn't require combining multiple migrations into a single migration. Read the migration extension source code and hopefully it will become clear how to do so (hint: search for :column). If you want more help, you are going to need to define what you mean by "packup". Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
