Is there an app or a script that is available that will allow me to auto generate grails domain classes based on the tables in an existing database?
Found it... Grails Application Generator available on sourceforge. http://sourceforge.net/projects/grag/
Related
I have a grails 3 application that makes heavy use of plugins. Some of these plugins provide domain classes. My application will not start unless every plugin has the same gorm version. This is an annoyance for locally developed plugins, but can be a significant problem for using third-party plugins.
There are more details in the stacktrace, but the relevant parts appear to be:
Caused by: org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class (my class name)
at grails.core.ArtefactHandlerAdapter.isArtefact(ArtefactHandlerAdapter.java:129)
at grails.core.DefaultGrailsApplication.addOverridableArtefact(DefaultGrailsApplication.java:772)
at org.grails.plugins.AbstractGrailsPluginManager.registerProvidedArtefacts(AbstractGrailsPluginManager.java:310)
I am currently using Grails 3.2.8 with GORM 6.1.3.RELEASE, but this happens with other non-matching versions for gorm as well.
If there is a better way to accomplish the bigger-picture goal, my big-picture goal is to use the grails ehcache plugin (currently at 3.0.0.M1) which requires gorm 6.1.x as a minimum. Per conversations on that plugin github site, there is no problem using gorm 6.1 with grails 3.2.x, though this is not the default.
Is there any way to run a grails 3 application, using plugins which provide domain objects, in which these plugins have different minor versions of gorm?
In case anyone else comes across this, the answer was basically "no".
The longer answer is "not as long as the groovy version is changing in non-backwards-compatible ways", and apparently that happens a lot.
There are some comments from Graeme here: https://github.com/grails/grails-core/issues/10693 but to summarize: you have to use the same version of gorm across plugins, and also make sure any third-party plugins you rely on are on the same version. This is only required for plugins that provide domain objects, at least!
Grails schema-export does a great job of generating the DDL to create database schemas for a particular database. However what I would like to do, is have grails just output the DDL for updates to an already created schema, not the DDL to create it from scratch.
I'm thinking it should be possible, as grails does have the ability to actually update schemas if you specificy dbCreate = "update" in your datasource.
But I just want grails to spit out what it would run, not actually do it, so I can execute it myself through a SQL tool in a controlled manner.
As #GreyBeardedGeek pointed out in a comment, the Database Migration Plugin (which is included by default now) can generate the "schema diff" that you are looking for, and it does substantially more than what the vanilla dbCreate = "update" does, since Grails' native db updating relies only on what Hibernate provides, and it's very conservative in the updates it can do.
In particular, the part of the Database Migration plugin that you are looking for is the dbm-update-sql script, which will give you the SQL that it would run to update the DB to the current schema version.
In general, I would strongly advise using a tool like the Database Migration plugin, since it bundles your DB schema in with your application code and you can easily version them together, and it also includes lots of tooling so that running the updates is much less painful, and allows for rollbacks and custom scripts to massage things as needed.
I have symfony 1.4 installed and had setup my own user model (table). Now, in order to use sfFacebookConnectPlugin, it asks to use sfGuard plugin, so it can easily integrate existing users with facebook account.
Is there a way to use sfGuardPlugin with existing user model ?
OR
is there a better way to implement facebook connect, such that it recognizes the same user (by email), if exists, or creates a new user in the user table with the fb email id and also creates the session.
Thx !
You can use sfGuardPlugin with an existing model, the schema file will be loaded from the plugin's folder and the table names are namespaced in a way that prevents naming collisions.
All you have to do is install the plugin as per its installation instructions and then build your model. To deploy to production you can either copy the SQL that propel generates (in data/sql) and execute it or use a program like Toad for MySQL to generate diff sql upgrade scripts.
Have you tried and failed? I hope I've addressed your concerns.
I am using Ruby on Rails 3 and I am planning to create an "extendible" application. That is, to have a main application for\in which I can add ("un-invasive") plugins without modify the main application at all. These plugins must interact with the main application accordly to its database\code structure.
How can I handle this issue in designing and planning my application database structure (primary\foreign keys, ...) and thinking at the application code implementation?
I can recommend you Rails::Engine. Nice example of this are Refinery CMS or Spree projects.
You can write migrations in engine and copy them to application db/migrate with generator for example.
Could you please suggest a service or plugin which generate the corresponding XML Schema for a given Domaing Class or for all Domain Classes of Grails project.
This plugin does exactly what you're asking.
http://grails.org/plugin/domain-schemagen
You just need to type the following command shell from your project root directory:
> grails schema-export
See schema-export documentation for further details
It will generate a DDL file.
From there, you need to convert it into XML (if you really want XML).
I recommend using a database migration to control all the schema generation and to manage future changes. We use Liquibase, it's very easy to use and flexible and there is already a Grails plug in for it. All the changes in Liquibase are managed in XML format.
Also, if I am not mistaken database migrations are going to be integrated in Grails core for version 1.4 so you will be able to use schema migrations without having to install any plug in and I think with this you would be able to manage your changes using DSL as well.