Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot perform CREATE TABLE using Liquibase update for Snowflake as this session does not have a current database?

I am trying to run Snowflake update using Liquibase as the following command which has fully qualified name of the server, database and the schema.

liquibase --username=myusername --password=mypassword --url="jdbc:snowflake://myserver-name-europe.azure.snowflakecomputing.com/?db=mydb&schema=public" --changelog-file=/samplechangelog.snowflake.sql update

But it just gives me error that I didn't specify the database which I did. Also, the same command work with other Snowflake account? I just even copy and paste it from other project, it's just the name of the server URL and DB is the different.

Here is the error message:

Unexpected error running Liquibase: Cannot perform CREATE TABLE. This session does not have a current database. Call 'USE DATABASE', or use a qualified name. [Failed SQL: (90105) CREATE TABLE DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP_NTZ, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))]

enter image description here

like image 209
Mohamed.Radwan -MVP Avatar asked Jan 19 '26 17:01

Mohamed.Radwan -MVP


1 Answers

Yes, the issue was in the permissions for the current user that I am trying to use to connect to the Snowflake, here what I did:

ALTER USER myuser SET DEFAULT_ROLE=SYSADMIN

This lead to another error as there is no active warehouse, so I set the whorehouse in the connection string of the JDBC driver as the following:

liquibase --username=myusername --password=mypassword --url="jdbc:snowflake://myserver-name-europe.azure.snowflakecomputing.com/?&warehouse=COMPUTE_WH&db=mydb&schema=public"--changelog-file=/samplechangelog.snowflake.sql update

So, I can send any values in the connection string for the JDBC as the following:

jdbc:snowflake://myorganization-myaccount.snowflakecomputing.com/?user=peter&warehouse=mywh&db=mydb&schema=public

Here is the page for more info about JDBC driver connection string:

JDBC connection string to Snowflake

like image 60
Mohamed.Radwan -MVP Avatar answered Jan 22 '26 15:01

Mohamed.Radwan -MVP



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!