I have create a very simple Jhipster app and deployed it to Heroku. Everything work fine so I added a new field to my very simple object and redeploy. I got the following error:
2016-09-07T12:32:49.375947+00:00 heroku[router]: at=info method=POST path="/api/tsts?cacheBuster=1473251569324" host=deplyjhip.herokuapp.com request_id=2b7190f7-0301-456d-87a9-7342640aad9d fwd="5.2.192.47" dyno=web.1 connect=0ms service=17ms status=500 bytes=532
2016-09-07T12:32:49.361875+00:00 app[web.1]: 2016-09-07 12:32:49.361 ERROR 3 --- [io-40257-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: column "amend" of relation "tst" does not exist
2016-09-07T12:32:49.361530+00:00 app[web.1]: 2016-09-07 12:32:49.361 WARN 3 --- [io-40257-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42703
I know what happens. When I redeploy using:
./gradlew -Pprod bootRepackage -x test
heroku deploy:jar --jar build/libs/*war
it didn't run ./gradlew liquibaseDiff
How do I run liquibase diff and apply the changes on the heroku DB?
This seems you didn't fully migrated your new field. It looks like you just added the attribute to the Entity class in domain package, but didn't any liquibase migration. You have two option to achieve that:
manual migration
just create a "YYYYMMDDHHmmss_add_field_to_my_entity.xml" in src/main/resources/config/liquibase/changelog directory with a content like
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet id="YYYYMMDDHHmmss" author="you">
<addColumn tableName="your_table">
<column name="column_name" type="??" />
</addColumn>
</changeSet>
</databaseChangeLog>
to make your changes happen. do not edit some changelog file, already been migrated in past!
adding field to your db, and thenn liquibase:diff
Here you can edit your database using tools you know in order to add that column via. SQL, and then run either ./mvnw liquibase:diff or ./gradlew liquibaseDiffChangelog to generate the migration
In order to run ./gradlew liquibaseDiff I set the db connection details in gradle/liquibase.gradle as follows:
args "--username=USERNAME"
args "--password=PASSSWORD"
args "--url=jdbc:postgresql://ec2-BLA.bla.eu-west-1.compute.amazonaws.com:5432/DATABASENAME?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
It doesn't work without: ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
This generated the changelog so I added it to master.xml and redeploy the app (basically step 2 from the David Steiman's answer)
I am having exactly same issue.I used jhipster entity foo added a new attribute, and run ./mvnw liquibase:diff, then I use heroku deploy:jar target/*.war, it give me same error. column "xxx" of relation "xxx" does not exist. I didn't find any solution : ( but remove the database from heroku, then run jhipter heroku
The accepted answer does not really solve the question asked. The question is why jhipster heroku does not run liquidbase migrations scripts even after defining new migrations.
Just add this to the Procfile as a seperate line
release: ./mvnw liquibase:update
Or you can manually run this commannd, in the run console of your app on heroku
./mvnw liquibase:update
Related
Background
I'm currently debugging some old unit tests in my code base, and I found a failing unit test at this point:
$this->seeInDatabase('table', [
'amount' => //some value,
]);
in my phpunit.xml I'm running the tests against my testing env:
<php>
<env name="APP_ENV" value="testing"/>
Question
I would like to check the value that's actually stored on the database in my unittest environment. However, when I put a break point right before the seeInDatabase line, nothing appears at all in the database (the same happens when I try to run tinker like so:
php artisan tinker --env=testing
ideas?
I have the following release phase in my Procfile:
release: bundle exec rake db:migrate
It works great when I merge PR's into my staging and production apps, but it fails when running on a new review app. The Heroku docs say that the release phase is run after a successful build, so I don't know why it can't find bundle.
This is my output
heroku releases:output 9 --app my-app-pr-253
/bin/sh: 1: bundle: not found
For Heroku's review apps, you must specify all buildpacks and ENV vars you need in the app.json file. You can either manually create one, or have Heroku generate one for you.
https://devcenter.heroku.com/articles/github-integration-review-apps#app-json
Confirm that in your app.json you have specified
1) The required buildpacks https://devcenter.heroku.com/changelog-items/670. Since you are using bundle I'm guessing heroku/ruby will be one. Below is an example.
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-ruby.git"
},
2) Also make sure you specify any config variables that you want to inherit from the app off which your review app is being built. https://devcenter.heroku.com/articles/app-json-schema#env Missing one of these could also be causing a build to fail.
If neither of these work, try checking the logs for your heroku app. Watch the ones in the Heroku GUI during the build. Also try to tail the logs in the CLI.
heroku logs -t -a <review_app_name>
I figured out my problem. It was a silly typo:
"buildpacks": [
{
"url": "heroku/ruby",
"url": "https://github.com/guillaume-tgl/heroku-buildpack-ghostscript.git"
}
]
should have been:
"buildpacks": [
{ "url": "heroku/ruby"},
{ "url": "https://github.com/guillaume-tgl/heroku-buildpack-ghostscript.git" }
]
I am using the MeanJS (https://github.com/meanjs/mean) framework, running on Heroku. When I try to run the application I get errors like:
Error: Cannot find module 'eslint-config-airbnb/legacy'
I am running in production mode (NODE_ENV=production).
The question I have is, it seems like gulpfile.js (when running the task prod) calls the task lint which calls the task eslint. But when I look at the packages.json file, I see that eslint-config-airbnb is only included in the devDependancies (and not dependancies). Now I tired to add it to dependancies, but I still get the same error about the missing module.
I'm new to MEAN.js, so I appreciate any help.
I've cloned this repo:
https://github.com/lvillani/quickstart-jekyll-zurb
I got it working locally no problem.
I added a Procfile with the following:
web: bundle exec jekyll serve -P $PORT
Heroku accepts the bundle no problem.
But the server crashes when trying to load a page.
The first problem I had was that it was trying to render a misformated vendor page.
I fixed that by adding this to _config.yml:
exclude:
- "vendor/bundle/ruby
But now my app.scss file can't #import "foundation/settings";.
Here is the relevant portion of the Heroku logs.
"2014-10-16T19:56:05.366451+00:00 app[web.1]: Generating...
2014-10-16T19:56:05.361060+00:00 app[web.1]: Configuration file: /app/_config.yml
2014-10-16T19:56:06.277480+00:00 app[web.1]: Conversion error: There was an error converting 'asset/app.scss'.
2014-10-16T19:56:06.277526+00:00 app[web.1]: jekyll 2.1.1 | Error: File to import not found or unreadable: foundation/settings.
2014-10-16T19:56:06.277529+00:00 app[web.1]: Load path: /app/_vendor/foundation/scss
Everything works fine locally, so I assume this is a Heroku configuration issue but I don't know enough about Heroku to begin to know where to look.
thanks!
Maybe you forgot to run a make setup.
Note that your jekyll is 2.1.1 and current version is 2.4.
I'm trying to connect my application to Shared Database 5MB using grails tutorial. I'm using grails 2.1.0. On my local machine when I run heroku config I can see that DATABASE_URL is set, but after executing git push... my build stops with error:
Error packaging application: Error loading DataSource.groovy: null (Use --stacktrace to see the full trace)
Failed to build app
Heroku push rejected, failed to compile Grails app
So I've added logging to see how environment looks on heroku. I've added println System.env to Datasource.groovy and I cannot find any DATABASE_URL:
.[OLDPWD:/app/tmp/repo.git/.cache, SHELL:/bin/bash, SHLVL:2, GIT_DIR:., JAVA_HOME:/usr/lib/jvm/java-6-openjdk, PATH:/app/tmp/repo.git/.cache/.grails/bin::/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin, SSH_CLIENT:XXX, MAIL:XXX, USER:XXX, LOG_TOKEN:t.9e79a5be-dfa2-446e-9f83-f6b4ebbc4eb7, GRAILS_HOME:/app/tmp/repo.git/.cache/.grails, PWD:XXX, HOME:/app/, LOGNAME:u11846, _:/app/tmp/repo.git/.cache/.grails/bin/grails, SSH_CONNECTION:XXX, LD_LIBRARY_PATH:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64]
I have checked with heroku addons that for my application shared database is installed:
heroku addons
=== XXX Configured Add-ons
shared-database:5mb
and when I execute heroku config
heroku config
=== Config Vars for XXX
DATABASE_URL: postgres://XXX
JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops
SHARED_DATABASE_URL: postgres://XXX
Datasource.groovy:
production {
dataSource {
dbCreate = "update"
driverClassName = "org.postgresql.Driver"
dialect = org.hibernate.dialect.PostgreSQLDialect
println System.env
println System.env.DATABASE_URL
uri = new URI(System.env.DATABASE_URL)
println uri
url = "jdbc:postgresql://" + uri.host + uri.path
username = uri.userInfo.split(":")[0]
password = uri.userInfo.split(":")[1]
}
}
In BuildConfig.groovy I've added
runtime 'postgresql:postgresql:8.4-702.jdbc3'
I can launch application locally with DATABASE_URL set to local postgresql. I'm building war and running it on jetty.
Can anyone tell me what am I missing?
The application environment variables are not available at build time. Your code needs to be able to handle that accordingly. Or you can enable the new user_env_compile Heroku Labs feature that does enable the environment variables to be there at build time: https://devcenter.heroku.com/articles/labs-user-env-compile