I am getting a "table already exists" error from Liquibase when I run my Jhipster project:
[ERROR] liquibase - classpath:config/liquibase/master.xml: classpath:config/liquibase/changelog/db-changelog-001.xml::1::jhipster: Change Set classpath:config/liquibase/changelog/db-changelog-001.xml::1::jhipster failed. Error: Error executing SQL CREATE TABLE fc.T_USER (login VARCHAR(50) NOT NULL, .....: Table 't_user' already exists
I have generated the Liquibase changelog file into config\liquibase\changelog directory using
liquibase --driver=com.mysql.jdbc.Driver ^
--classpath=C:\Users\Greg\.IntelliJIdea13\config\jdbc-drivers\mysql-connector-java-5.1.31-bin.jar ^
--changeLogFile=db-changelog-001.xml ^
--url="jdbc:mysql://localhost/fc" ^
--username=root ^
generateChangeLog
So something is tricking Liquibase into trying to re-create the database when the changelog, I thought, was setting a baseline of the existing database.
Jhipster version: When I yo jhipster -v is says 1.2. When I nmp update jhipster is says I am on the latest = 17.2
Liquibase version tried 3.0, 3.1 and 3.2
Mysql database from XAMP
2 tables are created in Mysql - databasechangelog and databasechangeloglock
databasechangelog remains empty and databasechangeloglock has a record added when Jhipster app is run
This process was working but not since move to new computer. When it was working I saw databasechangelog had a couple of records in it as well as 1 in databasechangeloglock
Tips on how to debug as welcome as an answer. Thanks.
Running generateChangeLog as described above, and then changeLogSync in situ, results in the field [FILENAME] in the databasechangelog table having the value db-changelog-001.xml.
What it needs to be is the full address from where liquibase is run. When in a Jhipster app I am seeing classpath:config/liquibase/changelog/db-changelog-001.xml. So it does not seem to be using only ID as the row identifier, as I was expecting.
Related
We have been using Liquibase successfully for about six months. I'm moving to a new CI/CD pipeline using CircleCI and running into an error when running liquibase update over SSH.
Here's the command (after many iterations and much exploration of Liquibase documentation):
ssh $SSH_USER#$TEST_JOB_SSH_HOST "cd /var/www/html/liquibase ; liquibase --url=jdbc:$TEST_DB_URL/$TEST_DB_SCHEMA?user=$TEST_DB_USERNAME --username=$TEST_DB_USERNAME --password="\""$TEST_DB_PASSWORD"\"" --changelog-file=cl-main.xml --search-path=.,./ update --log-level 1"
The result:
However, the file does exist and can be seen here:
It was successfully executed several months ago using our old approach. Now I think Liquibase is just parsing files and somehow failing, likely because it's running from a different directory.
Here's a snippet from the changeset file:
<sqlFile dbms="mysql, mariadb"
encoding="UTF-8"
endDelimiter=";"
path="/../data/regional_integration_details-ingest_day-01.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
I think the issue is the leading slash.
The command I pasted above was based on reviewing this help document: https://docs.liquibase.com/concepts/changelogs/how-liquibase-finds-files.html
I'm struggling with the proper syntax to include in the --search-path parameter -- if that's even the correct parameter -- to make this work.
The nuclear option (yet to be tested) is to update all of our changesets, removing the leading slash. I'd prefer not to go that route.
Suggestions?
Edit 1
Updating to mention that the first four changesets are parsed successfully. They have path values like ../dirname/sqlscript_00.sql. Liquibase chokes on the first script with /../dirname/sqlscript_01.sql.
Also, we have no problems running Liquibase in local development, when we cd to /var/www/html/liquibase in our Docker containers and execute the liquibase update command.
Edit 2
Having CircleCI SSH directly into the server doesn't work, as it doesn't carry the variables over with it.
Passing the commands via SSH preserves those variables.
Liquibase removed support for absolute paths in v4.x.
We were upgrade our liquibase from 1.9.0.0 to 3.6.3. When running migration MD5SUM for 3.6.3 was updated but it was trying to re-run the previously executed changesets which were executed with liquibase 1.9.0.0. How do i run only updating checksum with without re-running the statements.
Thanks.
Liquibase has Command Line Interface. And the CLI has clearCheckSums command.
clearCheckSums clears all checksums and nullifies the MD5SUM column of
the DATABASECHANGELOG table so they will be re-computed on the next
database update.
changesets that have been deployed will have their checksums
re-computed, and pending changesets will be deployed.
Posting a link to the answer on liquibase forums for other users if they encounter the same query ever in future.
what could be causing the error below when listing databases in PostgreSQL.
I have 2 clusters running on the same machine under different ports and different data directories. The command works fine when I connect to one of them but fails when I connect to the other.
One cluster is using the PostgreSQL database community version while the other is using the EnterpriseDB Advanced Server 12.1.2 postgres platform but seated on the same machine though different directories.
My psql client version is psql (EnterpriseDB) 12.1.2 and the database version is PostgreSQL 12.1, compiled by Visual C++ build 1914, 64-bit
Error being experienced is:
postgres=# \l
ERROR: column d.daticu does not exist
LINE 6: d.daticu as "ICU",
^
HINT: Perhaps you meant to reference the column "d.datacl".
Your server is open source PostgreSQL, while psql is EnterpriseDB's fork.
EnterpriseDB must have hacked up their pg_database to include an additional column, and the query run for \l references that column. Now open source PostgreSQL doesn't have that column, so the query fails.
Use psql from the same distribution as the server for best results.
who knows how to start migrations from scratch?
I'am running my migrations as usual, with command
**java -jar yourService.jar db migrate -i dev --dry-run dev**
But instead of running migrations - I receive
**Error: relation "MyScheme.databasechangelog" does not exist**
Who knows what can be the problem ?
Do I need to add databasechangelog and databasechangeloglock manually ?It's strange for me, because when I use liquibase separatelly from other frameworks, it generates this tables for me.
I needed to run my service with following command:
**java -jar yourService.jar db migrate -i dev dev**
Anyway, if someone will reach similar problem - feel free to use command above.
I am running Spring 1.2.1.RELEASE with Liquibase in IntelliJ 14:
build.grade
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
compile('org.liquibase:liquibase-core')
I have a project/config/application.properties that I use to tell Liquibase to create the database and insert data:
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=xxx
spring.datasource.password=xxx
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.database=POSTGRESQL
spring.jpa.hibernate.hbm2ddl.auto=none
spring.jpa.hibernate.disableConnectionTracking=true
spring.jpa.hibernate.default_schema=xxx
liquibase.change-log:classpath:/db/changelog/db.changelog-master.xml
liquibase.check-change-log-location=true
If I run from the command line:
gradle clean build
I will get all my tables and seed data in my database as expected. But if I run my main SpringBoot Application class from within IntelliJ no tables are created. I have a logging file that shows liquibase being used from the command line, but when I run from within IntelliJ, there is not mention of Liquibase in that log file. Just to be sure, I have a duplicate application.properites under project/src/resources.
Here is how my project looks i IntelliJ:
Any ideas on how to get the properties file used from within IntelliJ?