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.
Related
Is it possible and what are best practices for generating schema-qualified object names in a Liquibase change log .sql file?
For example, I want the command liquibase generateChangeLog to generate a .sql file where the objects are schema qualified (CREATE TABLE [schema_name].[table_name]...). What I get is something like CREATE TABLE [table_name]... without the schema qualification.
I have tried the schemas and defaultSchema properties and their command-line equivalent w/no success. I have also tried setting the default schema for the liquibase login w/no success.
P.S. - this is for an MSSQL database.
Have you looked into using --includeSchema or --includeCatalog optional arguments with liquibaseGenerateChangeLog command?
Here's the documentation that mentions these optional arguments:
I am new to Liquibase. I am using Liquibase version 4.0 and on Windows 10 Home edition
Starting Liquibase at 23:08:42 (version 4.0.0 #19 built at 2020-07-13 19:45+0000)
Liquibase Version: 4.0.0
Liquibase Community 4.0.0 by Datical
I added one table and SP to DATABASEONE. I also generated diff between two databases and it worked fine.
liquibase diffChangeLog
liquibase.properties
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
classpath=../mssql-jdbc-8.4.0.jre11.jar
url=jdbc:sqlserver://localhost;databaseName=DATABASETWO
username=sa
password=Password123
referenceUrl=jdbc:sqlserver://localhost;databaseName=DATABASEONE
referenceUsername=sa
referencePassword=Password123
changeLogFile=diff.xml
However, Liquibase does not report difference on stored procedures.
How can I get the newly added (or) missing stored procedure information in diffChangeLog ?
EDIT
I used Pro License Key (14-day trial) to generate the diff for Stored Procedures
I also generated liquibase updateSQL > update.sql. Now I want to run 'update.sql' against another database. How can I do that?
Running an update on the update.sql generatated the command liquibase updateSQL > update.sql will return extra stuff that is debug info. Not just straight SQL. You will want to:
use generateChangelog to produce a changelog file (let's call it change.postgresql.xml)
run liuqibase update using the above produced changelog file and url of destination db
Note, if they are different db platforms, like say from postgres->mysql, then you will have to review the generate changelog (in this case change.postgresql.xml) for non spec db objects of the target db (in this example mysql).
Unfortunately, you can't diff stored function / procedure according to diff-changelog document
Additional Functionality with Liquibase Pro
While Liquibase Open Source stores all changesets in a changelog, Liquibase Pro creates a directory called Objects and places the directory at the same level as your changelog. The Objects directory contains a subdirectory for each of the following stored logic types:
checkconstraint
package
packagebody
procedure
function
trigger
synonyms
I'm using Liquibase to generate a DB scheme from existing H2 database.
I use the following:
liquibase --driver=org.h2.Driver --classpath=./h2-1.4.199.jar --changeLogFile=db.schema.sql --url="jdbc:h2:mem:testdb" --username=sa --password= --logLevel=debug generateChangeLog
So, absolutely default values in order to connect to the H2 instance. But the command above generates an empty changelog file (just some basic Liquibase headers).
I tried to use different urls (h2 in file), I tried to set different password and username, I even tried to define defaultSchemaName parameter, but still the same.
Liquibase maven plugin says: No changes found, nothing to do
Liquibase without maven plugin says: Liquibase command 'generateChangeLog' was executed successfully.
I also tried to put invalid credentials (username or password), but still the same.
generateChangeLog command exports data from the specified database. It means that such database should exist and be populated with some data.
There is no point to specify the in-memory embedded URL jdbc:h2:mem:testdb here. Each process have own memory and own in-memory databases. Liquibase will definitely see an empty database here inside its own memory.
You need to create a normal persistent database with your application and use its URL here. I strongly suggest you to specify the absolute database path (without file name extension) in the database URL to be sure that the same database will be used by your application and by Liquibase. Note that you can't use the embedded database by two applications at the same time without additional parameters (auto-server mode), so you need to close the database in your application before you'll launch Liquibase. As an alternative you can start the H2 Server process and use remote URLs or you can use the auto-server mode.
You can also append ;IFEXISTS=TRUE to the database URL for Liquibase only. It will prevent accidental silent creation of a new empty database in it.
I am currently developing a CakePHP 2.4 app and trying to manage changes to my database table schemas with the schema manager. I figured out how to generate the schema and restore it, but is there a way to backup the entire database's schema with it? Seems like should be a method to solve this... Any thoughts?
Of course, use the schema dump command from the Cake Console.
It will write the entire schema to a .sql file and store it in App/Config/Schema.
Example of usage:
Console/cake schema dump --write filename.sql
(change 'filename.sql' to whatever the dump file should be called.)
This can also be find in the cake docs:
http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
There is actually a better way to handle this using the CakeDC Migrations Plugin, this gives you Rails type "migrations" that will help you snapshot your schema, it is an improvement to the cake schema dump method specified above and is actually developed by the CakePHP core team.
CakeDC Migrations
You can dump your schema using cake schema command
First of all you have to set the cake command path
In the windows system you have to set the path of the console/cake
Go to the cmd
Write the command "Console/cake schema generate" from this you can generate schema
After that if you want to dump in to the sql file So, You have to use following command "Console/cake schema dump --write filename.sql"
For more information click on below link
http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html
Hibernate Core: 3.5.6
DB: Oracle 11g
I am using the updateSQL goal to generate alter scripts (SQL files).
The resulting SQL files do not have the schema name (username) prepended. Is there any way this can be achieved?
A create table changeSet will result in
CREATE TABLE FOO ...
What I want is
CREATE TABLE XYZ.FOO ... where XYZ is the default schema name.
I have tried adding defaultSchemaName in the generate-resources
Would appreciate if I can get some help.
Thanks
I used liquibase-maven-plugin 2.0.2 and that resolved it. I was using 2.0.1 earlier.