Skip to content

db:schema:load fails if a user defined function already exists #145

@danielwestendorf

Description

@danielwestendorf

In a rails app, with existing Clickhouse schema w/a function defined, a rails db:schema:load will not always succeed; this is because the function may already exist.

Code: 609. DB::Exception: User-defined function 'uuid7ToDateTime' already exists. (FUNCTION_ALREADY_EXISTS) (version 23.9.6.20 (official build))

This can be addressed in at least two ways:

  1. Guard the CREATE FUNCTION statement with IF NOT EXISTS; this would prevent trying to create the function, however, it also does not guarantee that the function is up-to-date with the schema
  2. Use CREATE OR REPLACE FUNCTION instead. This has the benefit of ensuring the function is up-to-date with the schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions