Hello everyone. I'm getting this error on my Heroku app:
Cannot use database previously used with a newer version of graphql-engine (expected a catalog version <=36, but the current version is 37
graphql-engine version: v1.3.0
Postgress DB version: v12.3
I did open an issue on the graphql-engine-heroku (link: https://github.com/hasura/graphql-engine-heroku/issues/84), but I'm opening an issue in here for reasons explained down below.
When version 1.3.0 got released, it broke my Hasura app console on Heroku. I managed to fix the problem by running the following commands:
```bash
git pull #Get the latest Docker Image
heroku git:remote -a
heroku stack:set container -a
git push heroku master
But yet again, (since Friday 31/7/2020), the same problem occurred, and this time, I'm having zero luck fixing this issue.
The problem is that with every release, my Heroku app keeps breaking because of my catalog version (which I don't even touch at all), and I'm sure that's not the expected behaviour. Soo that's why I think it's worth opening an issue in here.
I tried migrating, but whenever I try to access the API, it spills out that error, soo in result, I can't do anything through the Hasura CLI, which eliminates any other solution that can be done with the Hasura CLI.
Complete error:
```logs
{"kind":"db_migrate","info":{"path":"$","error":"Cannot use database previously used with a newer version of graphql-engine (expected a catalog version <=36, but the current version is 37).","code":"not-supported"}}}
I don't even know why it is using version 37, I didn't touch a single thing.
Thanks! I reported this issue on Discord as well, and it appears to be that I'm not the only one who went through the same problems since v1.3.0 release.
Heroku's message whenever I try to access the console:

@LuisDev99 Did you point your DB to a Hasura Cloud project? Or did you run some PR build on the same database?
Catalog version 37 was introduced in master after v1.3.0 (which is at 36) and your database getting migrated to catalog version 37 means that some newer version of Hasura was run on the same database.
To fix this, we can send you a SQL to downgrade manually from 37 to 36 and then v1.3.0 will be compatible with your database state again.
Hi @tirumaraiselvan
I'm pretty sure I didn't do anything on the DB nor on the Hasura console itself, my Heroku app simply stopped working (on Friday), and this has happened twice already.
I'm guessing maybe Heroku pulled down the Docker image from the hasura/graphql-engine-heroku and updated the Hasura metadata with that new image (by itself), which then cause the catalog version to be updated to 37, but that just a wild guess.
The SQL will be greatly appreciated. Thanks!
Update: I followed the Hasura downgrade steps listed here: https://hasura.io/docs/1.0/graphql/manual/deployment/downgrading.html#downgrade-hge
But it didn't work for me.
Something is odd here (did you check cloud.hasura.io? ). The image here: hasura/graphql-engine-heroku is not ahead of v1.3.0 hence it seems unlikely that it may have pulled and deployed a newer version.
Downgrade will not work because catalog 37 is ahead of v1.3.0 and hence it doesn't know how to downgrade.
Anyway, here is the sql to update your catalog to 36. Then v1.3.0 should run safely:
BEGIN;
CREATE OR REPLACE FUNCTION
hdb_catalog.insert_event_log(schema_name text, table_name text, trigger_name text, op text, row_data json)
RETURNS text AS $$
DECLARE
id text;
payload json;
session_variables json;
server_version_num int;
BEGIN
id := gen_random_uuid();
server_version_num := current_setting('server_version_num');
IF server_version_num >= 90600 THEN
session_variables := current_setting('hasura.user', 't');
ELSE
BEGIN
session_variables := current_setting('hasura.user');
EXCEPTION WHEN OTHERS THEN
session_variables := NULL;
END;
END IF;
payload := json_build_object(
'op', op,
'data', row_data,
'session_variables', session_variables
);
INSERT INTO hdb_catalog.event_log
(id, schema_name, table_name, trigger_name, payload)
VALUES
(id, schema_name, table_name, trigger_name, payload);
RETURN id;
END;
$$ LANGUAGE plpgsql;
UPDATE hdb_catalog.hdb_version SET version = 36;
COMMIT;
I would again make sure to check cloud.hasura.io for any project. Hasura Cloud runs with catalog 37 and hence that seems the mostly likely source of this upgrade.
Omg yes! The SQL worked!
It wasn't working at first because I had to restart the dyno.
Something is odd here (did you check cloud.hasura.io? ).
Nope, anything. My Hasura console on Heroku simply stopped working. No administration nor configuration was done on either the console or the DB.
The first time this same exact problem happened was during the v1.3.0 release, and later on, this past Friday. I noticed that on Friday (31/7/2020), commits were done to master, which is exactly by the time in which my console stopped working.
Maybe a regression was introduced? I don't really know. But I do know that the catalog shouldn't be ahead of it's intended working version every time something gets released or change. Again, it's weird because no configurations were done on my end. Didn't even use the console during those days, soo something is definitely off.
Wait, you are right @tirumaraiselvan.
I remembered trying out the Hasura cloud about a month or two, and out of curiosity, I just went ahead and log in, and I'm seeing that my Heroku Postgres DB is being used by the project I created on the Hasura cloud, which is strange because I don't remember configuring the DB in there lol.
Soo, in other words, I created a project on the Hasura cloud, which was using the same DB as my app on Heroku (not good), which was causing all of these catalog version errors. Hope this helps!
Thank you very much @tirumaraiselvan
I confirm the script fixes the issue! 馃帀
Just a small thing, the last line should use semicolon COMMIT; instead of a colon :
I also tried out Hasura Cloud and broke the console on Heroku. Thanks for the fix!
This has now been fixed with v1.3.1. You can use Heroku and Hasura Cloud on the same DB.
Most helpful comment
Something is odd here (did you check cloud.hasura.io? ). The image here: hasura/graphql-engine-heroku is not ahead of
v1.3.0hence it seems unlikely that it may have pulled and deployed a newer version.Downgrade will not work because catalog 37 is ahead of
v1.3.0and hence it doesn't know how to downgrade.Anyway, here is the sql to update your catalog to 36. Then
v1.3.0should run safely:I would again make sure to check cloud.hasura.io for any project. Hasura Cloud runs with catalog 37 and hence that seems the mostly likely source of this upgrade.