I have a migration where I exchange the primary key from being a number to a nanoid. I have registered the postgres-nanoid method in my database. As the migration is executed in a shadow database, I don't have access to my nanoid method:
ALTER TABLE "Label" ADD COLUMN "new_id" CHAR(21) NOT NULL DEFAULT nanoid();
I tried to define viascom/nanoid-postgres inside the migration, but there I cannot activate the crypto postgres extension.
Is there a way to use nanoid() or other user defined postgres functions inside migrations?
The error message during migration:
Migration `20231008101221_nanoid_and_version_for_label` failed to apply cleanly to the shadow database.
Error:
db error: ERROR: function nanoid() does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
0: sql_schema_connector::validate_migrations
with namespaces=None
at schema-engine/connectors/sql-schema-connector/src/lib.rs:312
1: schema_core::state::DevDiagnostic
at schema-engine/core/src/state.rs:270