Skip to content

Migrating from Mariadb/MySQL to PostgreSQL fails #5728

@gzsombor

Description

@gzsombor
  • Gitea version (or commit ref): HEAD
  • Git version:
  • Operating system:
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

When generating sql dump from MariaDB/MySQL for PostgreSQL there are a couple of subtle errors in the output:

  • it seems, that the boolean fields are returned as 'reflect.Slice', as byte('0') or byte('1') - which looks strange, and these values are outputted as 0/1, instead of what expected by PostgreSQL: false/true
  • The sequences are initialized with this:
SELECT setval('table_id_seq', COALESCE((SELECT MAX(id) FROM "user"), 1), false);
SELECT setval('table_id_seq', COALESCE((SELECT MAX(id) FROM "public_key"), 1), false);
SELECT setval('table_id_seq', COALESCE((SELECT MAX(id) FROM "access_token"), 1), false);
SELECT setval('table_id_seq', COALESCE((SELECT MAX(id) FROM "repository"), 1), false);
  • which is wrong, because 'table_id_seq' is not a valid sequence name
  • with this initalization, the next call to nextval('action_id_seq') will return an ID which equals to the current maximum value, which cause index violations, and transaction rollback

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions