Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity columns sequences were not migrated #5

Open
Matthias64 opened this issue Apr 23, 2024 · 0 comments
Open

Identity columns sequences were not migrated #5

Matthias64 opened this issue Apr 23, 2024 · 0 comments

Comments

@Matthias64
Copy link

Matthias64 commented Apr 23, 2024

Hello,

I just want to give the information to whoever that could help.
I was trying to use DMS for Postgres to Postgres migration and even after migrating the sequences with the provided script, I was missing a few sequences. It took me quite a long time to find out that they were not migrated.

I did not figure out fully why they behave differently but I think this is because they are linked to identity columns.

I modified the query to use pg_class instead of information_schema.sequences and that indeed gave me a few more sequences to update :

SELECT d.refobjid::regclass as schema, a.attname as field, seq.relname as sequence_name
FROM pg_depend d
     INNER JOIN pg_attribute a ON a.attrelid = d.refobjid AND a.attnum = d.refobjsubid
     INNER JOIN  pg_class as seq ON seq.relkind = 'S' and d.objid = ('"' || seq.relnamespace::regnamespace::text || '"."' || seq.relname || '"')::regclass
WHERE d.refobjsubid > 0
  AND d.classid = 'pg_class'::regclass
ORDER BY seq.relname ;

The ALTER table does not work with these identity columns but the setval is still required.

Hope this can help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant