# dropAll fails on RedShift

**URL:** <https://forum.liquibase.org/t/dropall-fails-on-redshift/2882>\
**Category:** General Discussion\
**Created:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882 "2014-02-10T21:26:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![GavrielFleischer](https://avatars.discourse-cdn.com/v4/letter/g/7ea924/32.png) [@GavrielFleischer](https://forum.liquibase.org/u/GavrielFleischer)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/1 "2014-02-10T21:26:00Z")

</div>

Hi,

I would like to execute dropAll on our RedShift DB, and I get this strange error. Unfortunatelly I don’t even see from the debug output what SQL statement is causeing the problem (see below). On one line it states " … 23 more

For more information, use the --logLevel flag

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/2 "2014-02-10T21:26:00Z")

</div>

It appears to be a problem with the postgres driver. Liquibase is calling out to MetaData.getImportedKeys() which calls&nbsp;[https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java#L46-59](https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java#L46-59) and the version that redshift says it is doesn’t match the SQL reshift supports.

It is in the logic to get foreign keys, but redshift doesn’t really support foreign keys, right? Could the whole “get foreign keys” logic be no-op’ed out?  
  
Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/3 "2014-02-10T21:26:00Z")

</div>

The diff uses the snapshot logic to find objects to drop. I committed a change to the extension to make foreign key snapshots a no-op. It fixes the dropAll but it makes diffs between redshift and databases that do support foreign keys think that redshift has no FKs. Probably all we can do until we can figure out how to pull the foreign key info in redshift.

Can you try the code in liquibase-redshift master?  
  
Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/4 "2014-02-10T21:26:00Z")

</div>

It is built with maven, so it uses the pom.xml file in the root of the directory.

I heard from someone else that the fix seems to work, so I created a new build and published it as 1.0 snapshot #5.&nbsp;

Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/5 "2014-02-10T21:26:00Z")

</div>

I think I see the problem. The old foreign key logic was still being called because of a limitation in the extension API in liquibase 3.0.7 which the extension was built on.

I created&nbsp;[https://github.com/liquibase/liquibase-redshift/releases/tag/snapshot-6](https://github.com/liquibase/liquibase-redshift/releases/tag/snapshot-6) that updates support to liquibase 3.1.1 and should replace the standard foreign key snapshot logic.

Could you try the new version?  
  
Nathan

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/6 "2014-02-10T21:26:00Z")

</div>

Good, thanks for the update.&nbsp;

Nathan

---

<div class="post-metadata">

**Author:** ![un1384271115151r4id](https://avatars.discourse-cdn.com/v4/letter/u/4bbf92/32.png) [@un1384271115151r4id](https://forum.liquibase.org/u/un1384271115151r4id)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/7 "2014-02-10T21:26:00Z")

</div>

Yes, foreign keys are informal, only to help the optimizer. So as we’re talking about dropAll, anyway all the tables will be deleted, so,it doesn’t matter in which order you delete them: redshift won’t stop you, as foreign keys are not enforced, and the result will be consistent, when we finish to delete all the tables. You can ignore them IMHO

---

<div class="post-metadata">

**Author:** ![un1384271115151r4id](https://avatars.discourse-cdn.com/v4/letter/u/4bbf92/32.png) [@un1384271115151r4id](https://forum.liquibase.org/u/un1384271115151r4id)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/8 "2014-02-10T21:26:00Z")

</div>

Nathan,

how am I supposed to compile the code? I don’t see any build.gradle or similar config, just the java files.

Until now I only added the liquibase-redshift-1.0-SNAPSHOT.jar to our lib/ directory.

---

<div class="post-metadata">

**Author:** ![un1384271115151r4id](https://avatars.discourse-cdn.com/v4/letter/u/4bbf92/32.png) [@un1384271115151r4id](https://forum.liquibase.org/u/un1384271115151r4id)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/9 "2014-02-10T21:26:00Z")

</div>

It didn’t work:

DEBUG 2/17/14 6:27 PM:liquibase: Connected to innotest@jdbc:postgresql://blabla.redshift.amazonaws.com:5439/test

DEBUG 2/17/14 6:27 PM:liquibase: Setting auto commit to false from true

DEBUG 2/17/14 6:27 PM:liquibase: Executing QUERY database command: select count(\*) from public.databasechangeloglock

DEBUG 2/17/14 6:27 PM:liquibase: Executing QUERY database command: SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1

DEBUG 2/17/14 6:27 PM:liquibase: Lock Database

DEBUG 2/17/14 6:27 PM:liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = ‘galaxy (fe80:0:0:0:800:27ff:fe00:0%4)’, LOCKGRANTED = ‘2014-02-17 18:27:20.394’ WHERE ID = 1 AND LOCKED = FALSE

INFO 2/17/14 6:27 PM:liquibase: Successfully acquired change log lock

INFO 2/17/14 6:27 PM:liquibase: Dropping Database Objects in schema: test.public

DEBUG 2/17/14 6:27 PM:liquibase: Executing QUERY database command: SELECT MD5SUM FROM public.databasechangelog WHERE MD5SUM IS NOT NULL

DEBUG 2/17/14 6:27 PM:liquibase: Executing QUERY database command: select count(\*) from public.databasechangeloglock

DEBUG 2/17/14 6:27 PM:liquibase: Executing QUERY database command: SELECT relname AS SEQUENCE\_NAME FROM pg\_class, pg\_namespace WHERE relkind=‘S’ AND pg\_class.relnamespace = pg\_namespace.oid AND nspname = ‘public’ AND ‘nextval(’‘public.’||relname||’’’::regclass)’ not in (select adsrc from pg\_attrdef where adsrc is not null) AND ‘nextval(’‘public."’||relname||’"’’::regclass)’ not in (select adsrc from pg\_attrdef where adsrc is not null) AND ‘nextval(’’’||relname||’’’::regclass)’ not in (select adsrc from pg\_attrdef where adsrc is not null)AND ‘nextval(’’"’||relname||’"’’::regclass)’ not in (select adsrc from pg\_attrdef where adsrc is not null)

DEBUG 2/17/14 6:27 PM:liquibase: Release Database Lock

DEBUG 2/17/14 6:27 PM:liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1

INFO 2/17/14 6:27 PM:liquibase: Successfully released change log lock

Liquibase dropAll Failed: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.

SEVERE 2/17/14 6:27 PM:liquibase: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.

liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.

… 23 more

---

<div class="post-metadata">

**Author:** ![un1384271115151r4id](https://avatars.discourse-cdn.com/v4/letter/u/4bbf92/32.png) [@un1384271115151r4id](https://forum.liquibase.org/u/un1384271115151r4id)\
**Post date:** [February 10, 2014, 9:26pm UTC](https://forum.liquibase.org/t/dropall-fails-on-redshift/2882/10 "2014-02-10T21:26:00Z")

</div>

it works now, thanks
