Wolfbergen
Wolfbergen4mo ago

Migrating from cockroach to postgres

Hi, I want to switch my database backend from cockroach to postrges but I'm facing an error when I launch the setup command (see below). The migration attempts to alter a table that doesn't exist if I'm guessing right. Can someone help me to solve this ? Thanks !
6 Replies
Wolfbergen
WolfbergenOP3mo ago
Can someone have a look into this please ? I tried in version 2.69.3, 2.70.0, 2.70.1, 2.71.0, 2.71.1 and the latest 2.71.2 but all tries failed at the same step.
Rajat Singh
Rajat Singh3mo ago
Hi @Wolfbergen raising it internally, maybe some oe can help
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Rajat Singh
Rajat Singh3mo ago
hi @Wolfbergen we are having some issues with our migration and here's the PR for the same, its already a WIP https://github.com/zitadel/zitadel/pull/9509 As a tip, try running zitadel setup on the destination server too.
GitHub
fix(cmd): ensure proper working of mirror by adlerhurst · Pull Requ...
This PR fixes issues to ensure the mirror command functions correctly by updating the projections configuration and related database settings. Additional Changes mirror doesn't output the ...
Wolfbergen
WolfbergenOP3mo ago
Thanks @Rajat Singh and @dweeves for your answers ! I don't know why the migration is stuck with postgresql at this step, because I see that the sql request is 'ALTER TABLE IF EXISTS ...' and it should work as intended without throwing an error for non-existent tables... I'm running the latest postgresql version 17.4. I didn't want to modify the source code but I see this morning that I can do :
DO $$
BEGIN
ALTER TABLE IF EXISTS ...
EXCEPTION
WHEN undefined_table THEN
RAISE NOTICE 'Table does not exist. Skipping alteration.';
END $$;
DO $$
BEGIN
ALTER TABLE IF EXISTS ...
EXCEPTION
WHEN undefined_table THEN
RAISE NOTICE 'Table does not exist. Skipping alteration.';
END $$;
So I compile the code with this change and a second on another sql migration script (50.sql) and it works so I can run my migration without throwing an error. This works for postgresql but I don't know if it works for cockroach, I didn't test it
Rajat Singh
Rajat Singh3mo ago
Nice! Happy that it worked:))

Did you find this page helpful?