I just installed the database-migration plugin for a Grails 1.3.7 application that already contains about 100 domains. I ran the initial dbm-generate-gorm-changelog which generated a changelog.groovy that looks alright.
I added a single domain with 3 properties and then ran:
dbm-gorm-diff testing.groovy
What I expected was a changelog that would create my new domain. What I got was a changelog with 1260 lines of changeSets. Now, it does contain my new domain. But it also contains most (not all) of my other domains, which didn't change in the 60 seconds between scripts. Am I understanding how this works incorrectly? Or am I running the wrong command?
You need to "run" the first migration to get it into the Liquibase table, so when you run a second it does a diff. You just generated two independent files.
See "Typical initial workflow" at http://grails-plugins.github.com/grails-database-migration/docs/manual/guide/2%20Getting%20Started.html
Related
I am trying to setup aNimble on Windows following this article.
I have setup the Java and MySQL (xampp) on Windows and both are working properly.
Now, as the final step I need to execute
grails prod execute-database-scripts-all
but I am getting cannot find the specified path. Even when I type grails only I get the same error. I have zero experience in Grails, but it seems that I need to install Grails first on the PC. Until I do this, I want to know is there anything else that I need to do this to successfully execute this command.
What are the three portions of this command grails, prod and execute-database-scripts-all
This error means that Windows is unable to find grails executable anywhere it looks (in any paths specified in PATH system property) when you typing grails command. You may have to follow this guide in order to install grails application framework properly in your system (also, make sure you are installing a correct version of grails compatible with your distribution of aNimble) and then retry.
Grails is a web application framework and which provides a set of tools to develop, build and run web applications like aNimble, prod is a command line option for grails telling it to run in a production mode and execute-database-scripts-all is aNimble-specific command to initialize it's database.
Started a brand new project based on grails 2.3.8 (groovy 2.2.2) and I can't figure out what happened to 'generate-all' command. I have a domain class set up, i was able to create the controller but it beats me to find how views get crated now.
I've gone through the crate-app step and crated 1 domain class. Am I missing a plugin or something? When I look at tutorials they sure refer to the 'geneate-all' command.
Have things changed that much?
Typically in 2.3.x when you first create the project "generate-all" needs to have a series of Grails compile, clean, clean-all and refresh-dependency. Failing that, exit the project and restart. Then it will show as a valid command.
The reason for this is in 2.3.x scaffolding was moved into a plugin and it needs to be compiled first before the command is available.
I have an example Grails application (from Grails in Action) that was created a while ago under version 1.1.1 on a different PC.
I am now loading Grails 1.2.0 and want to revisit the app. However, when I try to run it I get this message:
Application expects grails version [1.1.1], but GRAILS_HOME is version [1.2.0] - use the correct Grails version or run 'grails upgrade' if this Grails version is newer than the version your application expects.
After reading around a bit I cleared out the 1.2.0 folder under .grails in my home directory (from previous attempts while exploring the issue), ran "grails clean" and "grails upgrade" (answering "y" where prompted).
However, I consistently get "Invalid duplicate class definition" conflicts between classes in \grails\qotd\src\java and \grails\qotd\grails-app{controllers,services,conf}.
Are there any additional manual steps that I need to perform?
I understood your problem.
The solution is just modify the grails vesion to 1.2.0 in application.properties file in your application
If, as you pointed out in the comments, your /src/java contains .groovy files - that could definitely cause unexpected behavior. I haven't hit your particular issue, but any time I had a .groovy file mismatched with the class name inside it, I'd get strange compilation issues - so I guess you could be having a similar issue.
If you have files / classes with the same names in two locations, that's the likely culprit. If you have .groovy files in /src/java, that's another potential source.
Also, putting BootStrap, Config, DataSource and URLMappings into /src/java, that's another potential source of issues. I'd clear out your /src/java by making sure all the files are in their appropriate places under grails-app.
You can upgrade grails version with 5 steps
Project -> Clean
application.properties -> Change app.grails.version
Your project -> Properties -> Grails -> Change grails installation
to new grails version.
Your project -> Grails tools -> Refresh Dependencies
I think this may be help you
Anyone knows how to fix this ?
It works fine on my env (Me being the developer) and doesn't work on my colleagues machine who unzips the whole
Welcome to Grails null - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\abc\products\grails-1.1
Base Directory: C:\abc\products\foo\bar
Running script C:\abc\products\grails-1.1\scripts\RunApp.groovy
Environment set to development
Application expects grails version [1.1], but GRAILS_HOME is version [null] - us
e the correct Grails version or run 'grails upgrade' if this Grails version is n
ewer than the version your application expects.
Some clarifications
1) There has been no Grails version change , either on my machine or my colleagues machine. In fact some of them are installing for the first time
2) Under C:\Documents and Settings\myfriend.grails I can see a folder called 'null'
I tried removing this folder - but it gets created he runs my application
3) The way I am giving him the release is- I unzip the whole folder and he unzips it
SO there are three steps
A_ grails create-app to create the APp
B_ Unzip my folder to replace the generated folder
C_ Grails run-app
Things are fine after the step A- but degenerate after Step C
It appears that his Grails installation is corrupted or not set up correctly. I would have him reinstall a fresh copy of Grails - http://www.grails.org/Installation and try again.
The error that you are getting is telling us that the application that you are trying to run is identified as version 1.1 and I assume that this is correct. The fact that Grails is not able to identify what version is installed makes me point to a corrupted or mis-configured Grails installation
If he types 'grails' at the command line what does he see?
I found the problem.
This was because I had added a file- build.properties
And since the file was there- it was expecting it to have certain properties defined in it
Once I renamed it to something else- it started to work
I have a Liquibase migration that I manually run to load seed data from several CSV files into my database. I would like to run this migration each time I run grails run-app.
I think I have two questions in one:
How to I integrate the migrate
command into my grails run-app ?
How do I clear the DATABASECHANGELOG
to allow me to run the same
migration over and over?
Or, is there a better way to load a lot of data into a DB from CSV files?
Question 1 - To integrate migrate command into run-app, you should listen for events thrown in run-app scripts. This is explained here, and a more complete article is here.
Question 2 - For clearing the database, perhaps you can write a migration that clears the db for you? The way I do it is use a little script I wrote that just drops and creates a db. It's for MySQL:
target(dropdb: "The description of the script goes here!") {
def x = 'mysql -u root --password=XXXX -e "drop database yourdb; create database yourdb default character set utf8; " '.execute();
x.waitFor()
println "Exit Value ${x.exitValue()}"
}
setDefaultTarget(dropdb)
Question #2: If you have particular changeSets you want to run every time, there is an "alwaysRun" attribute you can set on the changeSet tag.
For my money, it's easier to read the Liquibase Gant scripts and replicate what they do. They're simple and you'll have more insight into what's happening.
You should use the autobase plugin. It will run your migrations when the application starts.
It has a script to convert from an xml changelog to a groovy one as well so you don't have to manually convert it.