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.
Related
This one is quite strange.
I am running a very typical Docker container that holds a Rails API. Inside this API, I have an endpoint which takes an upload of a CSV and does some things and stuff.
Here is the exact flow:
vim spec/fixtuers/bid_update.csv
# fill it with some data
# now we call the spec that uses this fixture
docker-compose run --rm web bundle exec rspec spec/requests/bids_spec.rb
# and now the csv is loaded and I can see it as plaintext
However, after creating this, I decided to change the content of the CSV. So I do this, adding a column and respective value to it for each piece.
Now, however, when we run our spec again after saving this it has the old version of the CSV. The one originally used at the breakpoint in the spec.
cat'ing out the CSV shows it clearly should have the new content.
Restarting the VM does nothing. The only solution I've found is to docker-machine rm dev and build a new machine (my main one for this is called dev).
I am entirely perplexed as to what could cause this or a simple means to fix it (building with all those images takes a while).
Ideas? Inform me I'm an idiot and I just had to press 0 for an operator and they would have fixed it?
Any help appreciated :)
I think it could be an issue with how virtualbox shares folders with your environment. More information here https://github.com/mitchellh/vagrant/issues/351#issuecomment-1339640
I started trying to have a peek at grails v3.0.0.M1.
I unpacked and setup and created an app
When creating a script by using folowing command
grails create-script my-script
it creates a script and drops the hyphen - so script is myscript.groovy. Thought it might camel case that. More importantly - how do you run it?
In the grails command line prompt when I go help - the new script is not visible. If you try grails> my-script, it fails with
Error command not found my-script...
Having created a script - how do you run it?
Given a script named myscript.groovy, run it as
grails myscript
I haven't looked at the code, but it seems like a bug that it's dropping the hyphen. You should create an issue at https://jira.grails.org/browse/GRAILS/. It's easy to fix though, just rename the file to my-script.groovy and then you can run
grails my-script
So in my log file of my symfony project I have errors for inexistant files then after a small time I have a big log file > 50 Mb,I don't know what I can do to resolve this problem??I never work with this kind of problem?
php symfony log:rotate [--history="..."] [--period="..."] application env
You can find this documented at:
http://www.symfony-project.org/reference/1_4/en/16-Tasks
On Unix's, you can run this as a cron job, with the same formatting that you would do for any task.
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
Let's say I want to download a Symfony's complete app, for instance, Jobbet
I'll have everything necessary to run the app in my desktop but it wouldn't really work with an empty database. Is there a terminal command to create and fill the database with everything that the app requires?
First, configure your database, either by command line, or editing the "/config/databases.yml" file.
> php symfony configure:database "mysql:host=YOURHOST;dbname=YOURDBNAME" YOURDBUSER YOURDBPASS
Next, if you want to generate everything, forms, filters, models and data, run the following command:
For Doctrine ORM:
php symfony doctrine:build --all --and-load
For Propel ORM:
php symfony propel:build --all --and-load
This should get you up and running. You should definitely look at the tutorial for Jobeet posted on the Symfony Project website for more information on how this project works:
Doctrine: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/
Propel: http://www.symfony-project.org/jobeet/1_4/Propel/en/
You can either edit config/databases.yml file or use configure:database task. For more info run:
./symfony help configure:database