getting started with liquibase on snowflake - liquibase

I am trying to get started with liquibase on snowflake.
I think I am almost there with the liquibase.properties file
driver: net.snowflake.client.jdbc.SnowflakeDriver
classpath: ./liquibase-snowflake-1.0.jar
url: jdbc:snowflake://XXXXXX.us-east-1.snowflakecomputing.com
username: YYYYYYYYY
password: ZZZZZZZZZZ
changeLogFile: mySnowflakeChangeLog.xml
Unfortunately, liquibase complains about not having a "current database" when trying to create the tables databasechangelog and/or databasechangeloglock.
Since, I do not have access to the sql script creating these database tables, how do I instruct liquibase which DATABASE to use?

I pinged an internal team here #Snowflake. They recommended:
adding db=mydb database connection parameter to the URL.. or set
default namespace for the user.. alter user mike set
default_namespace=mydb
Hope that helps!

I am not an expert in liquibase, but JDBC standard allows custom connection properties being passed in. If liquibase support that, you can specify database as a custom connection property, and Snowflake JDBC will pass the database information with create connection request sending to the server.

Related

Flywaydb error in kotlin

I want to use flywaydb in Kotlin but I have an error in use
My database is PostgreSQL and my ORM is Kotlin Exposed
Code:
val url = "jdbc:postgresql://127.0.0.1/test1"
Database.connect(url, driver = "org.postgresql.Driver", user = "postgres", password = "123")
var flyway = Flyway()
flyway.setDataSource(url, "postgres", "123")
flyway.migrate()
Error:
Exception in thread "main" org.flywaydb.core.api.FlywayException:
Found non-empty schema(s) "public" without schema history table! Use
baseline() or set baselineOnMigrate to true to initialize the schema
history table. at
org.flywaydb.core.Flyway$1.execute(Flyway.java:1197) at
org.flywaydb.core.Flyway$1.execute(Flyway.java:1168) at
org.flywaydb.core.Flyway.execute(Flyway.java:1655) at
org.flywaydb.core.Flyway.migrate(Flyway.java:1168)
How can I solve it? Where is my code wrong?
Found non-empty schema(s) "public" without schema history table! Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
That error message pretty much says it all. You seem to be running Flyway on a database already populated with tables.
By default, Flyway expects to be run on a brand-new database, in a greenfield project. Flyway installs its own table first, for its internal tracking. This is the “schema history table” mentioned in your error message. After installing its own table, Flyway runs your SQL scripts creating further tables.
If adding Flyway to an existing database, choose either solution:
Recreate your database from scratch, starting with an empty database, running Flyway first, then writing and executing SQL scripts to recreate all the elements of your old database, and finally importing existing data.
Read about Flyway baseline feature, just as the error message suggested.

Location of Liquibase DATABASECHANGELOG Tables

I've seen how to rename the DATABASECHANGELOG tables but what I'm looking to do is to have them created in one database for each server and then deploy to the other databases on that server. We are using Liquibase on MSSQL and Sybase databases and executing via command line.
Thoughts?
I've had the same thought before as well. That's just not how it's done at my current shop :)
You're looking for these options:
--liquibaseCatalogName=<name> The name of the catalog with the
liquibase tables
--liquibaseSchemaName=<name> The name of the schema with the
liquibase tables
Doc here: http://www.liquibase.org/documentation/command_line.html.
However, --liquibaseCatalogName is not documented, but it does appear as an option when checking the command line options via liquibase --help. In your case, I believe "Catalog" equates to a Database in MSSQL and Sybase.

Connect databases to HSQLDB Server

I'm using version hsqldb-1.8 in a stand-alone way. I want to start the server with some databases. I'd like to use the command line from the HSQLDB documentation :
java -cp ../lib/hsqldb.jar org.hsqldb.Server -database.0 file:mydb -dbname.0 xdb
My problem is I have the script of each database I need and this command line creates a new database, without using my script. May the problem comes from one of these points :
The location of my script
The extension of my script which is a SQL-file
Something wrong or missing in the command line
The command line can't do it => If yes, is there any way to do it ?
I'd like to stay in the console to do all that. That way, I'll only have to launch a script to do all the job. Any help will be much appreciated ! Thanks
I found the solution of my issue :)
I've created a server.properties file located in the directory ../hsqldb-1.8.10/hsqldb/ which contains that :
server.database.0=file:mydb;user=test;password=test
server.dbname.0=mydb
I've also created the mydb.script file with that code in it:
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE MEMORY TABLE MYDB(ID BIGINT NOT NULL,VERSION INTEGER NOT NULL,NOM VARCHAR(255))
CREATE USER TEST PASSWORD "TEST"
GRANT DBA TO TEST
SET WRITE_DELAY 10
SET SCHEMA PUBLIC
INSERT INTO MYDB VALUES(1,0,'test')
Then, I launch the HSQLDB Server with this command:
java -cp ../lib/hsqldb.jar org.hsqldb.Server
We can see that the database is successfully created :
[Server#10f0f6ac]: Database [index=0, id=0, db=file:mydb, alias=mydb] opened successfully in 313 ms.
To check if the database really contains my data, I use the HSQLDB DatabaseManager tool with this command:
java -cp ../lib/hsqldb.jar org.hsqldb.util.DatabaseManager
To connect:
URL : jdbc:hsqldb:file:mydb
User : test
Password : test
After that, we are connected to the database. Execute the command SELECT * FROM MYDB; and we can see the line of the database.
Hope that will help ! :)
The easist way to connect with with HSQLDB (IMDB)
Connection String
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:/home/vikask/elmo/db/elmo;" />
<property name="username" value="sa" />
<property name="password" value="" />
In this simple Java project to demonstrate Hibernate, HSQL and Maven using Java Annotations. HSQL database is used to make the project simple, as we can use in-memory database and we would need only a JAR file to be included in our project.
To connect to an embedded HSQLDB database, select the JDBC (HSQLDB Embedded) connection type from the connection type list. Enter any login information if applicable, and then specify whether to use an existing embedded database, or to have HSQLDB create a new embedded database.
If the embedded database already exists, browse to the directory where the database files are located (such as database_name.log, database_name.script, and database_name.properties) and select the database_name.script file.
If the database does not exist, type in or browse to create a new location for the HSQLDB database. HSQLDB will then create the necessary files with the prefixed with the database name typed in. For example, if typing /home/vikask/sample as the location of the database, HSQLDB will create a file called sample.properites, and perhaps sample.log, etc. The actual name of the database is simply sample in this case.
HSQLDB creates a file with the .script extension for its internal use. This is not something that you create.
First run the server and connect to one of the databases. The database will be empty at this point. Then use the utilitly, SQLTool which is in the HSQLDB zip package to execute YOUR script on the database. All the tables and data that are created by your script are persisted in the HSQLDB database.

Oracle SQL Developer copy database step by step

I'm having big trouble in copying an Oracle DB to the same server but with another name, to use as a development DB.
I'm used to SQL Server, I'm new to Oracle (11g).
I wanted to use the 'Database copy' from SQL Developer, but I'm getting errors all the way. First it was about missing tablespaces.
Then when I manually created them in my new empty DB the errors were about missing users.
I wanted to create the users manually, but then I first needed to create missing roles.
When all that was done, it failed on missing indexes...
How do I copy everything I need with 'Database copy'?
Any advice is greatly appreciated!
SQL Developer copy will only copy objects between schemas. Do you want to just make a copy of a schema? Or a whole new database, including all schemas?
Judging by your question, I'm assuming the latter. If so, RMAN "database duplication" may help you.
See http://www.oracle-base.com/articles/11g/duplicate-database-using-rman-11gr2.php at Tim Hall's excellent site.
The best way for you is to create a new user :
Launch MSDOS Shell Connect to your database using system manager
account
sqlplus / as sysdba
Then write these sequences:
CREATE USER user2 IDENTIFIED BY user2password;
GRANT ALL PRIVILEGE TO user2 WITH ADMIN OPTION;
GRANT CONNECT TO user2;
GRANT DBA TO user2;
exit oracle prompt
In MSDOS Shell again, export your current user1 like this :
exp user1/password
or
exp user1/password#connectString
if you have a connection string specified in tnsnames.ora
Answer all the questions by default, give a name to your export file, and specify that you want to export only the user user1
Then proceed to the importation of the dump in your new user2 like this :
imp user2/password2 fromuser=user1 touser=user2
Answer all the questions by default, give the name to your export file (if you don't change the default folder of CmdShell you will not have to specify the complete folder)
An interesting link on this from Oracle documentation:
http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmdupdb.htm#BRADV010

wso2 api mgr: oauth not working

after install of wso2 mgr and a small change in the jdbi to use our mysql server everything "seems" to work except oauth.
In carbon web UI, when i click on the left menu on "oauth" i get an error message saying
System Error Occurred - Error occurred while reading OAuth application data
I looked at other post and saw this. i looked at ${WSO2_IS_HOME}/repository/conf/identity.xml where i saw that i had an entry <skipdbschemacreation>true</skipdbschemacreation>
I try to change it to false and no change...
Anybody had this problem with wso2 apu mgr ?
Any idea how to setup oauth in api mgr ?
Do i have to install wso2 identity manager ?
----update1 ------
it seems that changing to false this flag is creating a problem with our db as we get now an error message. When you reset this flag to true, the db error is still there ...
the error message says
[2012-08-19 15:40:13,649] ERROR - JDBCResourceDAO Failed to delete the resource with id 688. Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
and later the wso2 launch script said :
[2012-08-19 15:40:13,654] FATAL - CarbonServerManager WSO2 Carbon initialization Failed
org.wso2.carbon.registry.core.exceptions.RegistryException: Failed to delete the resource with id 688. Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
little bit later in the same launch script we have
org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
The skipdbschemacreation property was specifically introduced after the introduction of the WSO2 APIManager. This was because the WSO2 APIManager has a seperate sql script to create all the required tables (including the OAuth2.0 related tables). Therefore it was necessary to skip the schema creation step of the OAuth component on server startup. Thus it is correct that this property is set to 'true' by default in the WSO2 APIManager and to false in WSO2 Identity Server.
The problem you are facing should be because your configurations that point to your MySQL database are incorrect. If you are using a MySQL database, the place where you should configure its settings is {WSO2_APIMANAGER_HOME}/repository/conf/datasources/master-datasources.xml. Change the setting of the datasource whose name is WSO2AM_DB. This is the datasource which has the OAuth2.0 related tables.
E.g.
<datasource>
<name>WSO2AM_DB</name>
<description>The datasource used for API Manager database</description>
<jndiConfig>
<name>jdbc/WSO2AM_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://localhost:3306/wso2am_db</url>
<username>admin</username>
<password>admin#123</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource>
I presume you've already created the required database schema by running the mysql.sql script provided in {WSO2_APIMANAGER_HOME}/dbscripts/apimgt/mysql.sql.
To create a MySQL database schema for WSO2 APIManager:
Navigate to the location where you have the mysql script for creating the WSO2AM_DB.
Open a command prompt from that location and login to mysql from cmd prompt
mysql -u root -p
Create a database. Create user and grant access.
create database apimgt;
GRANT ALL ON apimgt.* TO admin#localhost IDENTIFIED BY "admin";
Run the mysql.sql script. This will configure the database.
use apimgt;
source mysql.sql;