How to resolve Liquibase changeSet error? - database

I have use Liquibase for my spring hibernate web application. Now I added new change set to update my database. When I try to restart my web application, Liquibase asks to drop database. But in my case I want to update my db schema without drop existing schema. How can I do this?
Thanks in advance
Lakshmi Priya.K

There is a "dropFirst" property on the spring implementation of liquibase:
http://www.liquibase.org/documentation/spring.html
This might be your issue.
Are you sure liquibase is dropping the schema and not just the objects within the schema?
Update
I found more details about the "dropFirst" property (see CORE-964). It is indeed performing a dropAll liquibase action.

Avoiding unused Autowire in the Controllers and specifying the
Liquibase Query in the root-context.xml without any space will solve the issue...
Liquibase works fine without database drop..
Thanks
Lakshmi Priya.K

Related

WordPress database error occur when installing wordpress

enter image description here
This is a problem has occurred when I installing WordPress
Please delete the existing database and create a new or change the table prefix from wp_ to something else. It will resolve your issue.
Actually the issue is your database have already all tables and you are trying to install WordPress using this table.
For the ideal scenario when you install fresh WordPress please use the new database rather than the old database.
So, please create new database and change the name in you wp-config.php file for DB_NAME.
Here I have shared the screens-shot for better understanding.
Screen-shot: https://prnt.sc/12aedo6
I hope it will helpful.

Missing Migration data in SQL when trying to add-migration

I have made use of a backup database and have added a new table using Code First. Now when I tried using add-migration, I got this error:
Unable to generate an explicit migration because the following
explicit migrations are pending
Suggesting that the Migrations in the project do not match which are in the DB, which when I looked, there are NO migrations in the __migration table any more ?
As these tables exist in the DB, how do I get all of these migrations inserted into my SQL DB ? Is there a way I can get them all added, so that the projects migrations and the SQL DB migrations will match, so that I can continue adding/editing tables ?
Thanks in advance for any help.
So I found something that did help! It unfortunately meant that I lost all of my migration files, but thats not the end of the world.
The below is reference from this site: Click here
Remove the _MigrationHistory table from the Database
Remove the individual migration files in your project's Migrations folder
Enable-Migrations in Package Manager Console
Add-migration Initial in PMC
Comment out the code inside of the Up method in the Initial Migration
Update-database in PMC (does nothing but creates Migration Entry)
Remove comments in the Initial method
I hope this helps someone else as well.

how to know the liquibase changesets are safe enough to run on a database

I am trying to develop a web application that upgrades user's database according to the application version the user chooses.I am using liquibase api to do this.Each version has a set of liquibase changeset files. I want to make sure that the changesets that are to be run on user's db are safe. is there any way to verify the changesets against user's db without effecting the db and then update liquibase files? My changesets don't have "rollback" tags.
You can use preConditions for it.
Besides built-in preConditions, of which there are many, there's a sqlCheck, that allows you to check any condition you want. You can check for possible errors and inconsistencies in sqlCheck precondition.
<changeSet id="changesetId" author="changesetAuthor">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="">
<!-- your SQL here -->
</sqlCheck>
</preConditions>
<!-- the rest of the changeSet -->
Check out the liquibase docs for preConditions.

Update Database with Migrations CLI on VS for Mac (DotNet Core 2)

I created the Models of my database on VS for Mac and used terminal for create migrations:
dotnet ef migrations add IntitialMigration
Then, I updated my database:
dotnet ef database update
But after I changed my Models and I created another migration:
dotnet ef migrations add SecondMigration
And tried to update the database:
dotnet ef database update SecondMigration
I received the following error:
There is already an object named 'Emails' in the database.
I've searched and I found a probably solution:
Add-Migration SecondMigration -IgnoreChanges
But this only works at PMC on Windows. I'm using VS for Mac and all the commands are typed on Terminal. Does anybody know how to update a database using Migrations after change the Models?
I found the solution. It seems that on VS 2017 for Windows, when you add a Migration, it is automatically added on the solution. But, on VS for Mac, that doesn't happen. You need to manually add the each new migration to the solution. I created the InitialMigration migration and update it to the database. For some reason I don't know why, I removed the migration from the solution and I created the new SecondMigration migration. That's the reason that all the tables that were on InitialMigration were on SecondMigration too.
If you just run update database it will also try to update with previous migration. (which is why its complains about adding whats already there). You can run an update just for one single migration by adding the name of the migration you want to run after the command.

Liquibase creates log tables with user schema

When implementing liquibase on Sql Server. Below tables are created on USER schema not with DBO schema. Not sure how to fix this.
AMAR.DATABASECHANGELOG
AMAR.DATABASECHANGELOGLOCK
It should be
DBO.DATABASECHANGELOG
DBO.DATABASECHANGELOGLOCK
I don't have any issues on creating table. It always creates on dbo schema. I'm using integratedSecurity and Liquibase version is 3.4.2
You can specify
--liquibaseSchemaName=dbo
as a parameter when running Liquibase from the command line.
I prefer to that into my liquibase.properties file.
This works for me using Liquibase 3.5.3 - don't know about 3.4.2 though
Have a look at changelogSchemaName parameters (http://www.liquibase.org/documentation/maven/generated/updateSQL-mojo.html) to specify schema where Liquibase stores tables.

Resources