Skip to content

Conversation

@Flamefork
Copy link
Contributor

@Flamefork Flamefork commented Aug 20, 2025

This fixes the issue of using a generated schema.sql with ClickHouse in Docker.
The ClickHouse entrypoint runs every .sql file in /docker-entrypoint-initdb.d during server startup, but it executes them against the default database.

It works if the schema dump was created from the default database, but it fails otherwise:

/entrypoint.sh: running /docker-entrypoint-initdb.d/schema.sql
Received exception from server (version 25.3.6):
Code: 60. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Table default.schema_migrations does not exist. Maybe you meant my_database_name.schema_migrations?. (UNKNOWN_TABLE)

This fix prefixes migrations_table_name with db_name. in the generated schema, making it consistent with the table creation statements and with other drivers.


Note

Ensures ClickHouse schema dumps are fully qualified with the database name and consistently quoted.

  • Use quotedDatabaseName() in CreateDatabase and schema generation; add helper for quoting the current database
  • Change schemaDump to derive the database name internally (remove param)
  • Prefix migrations INSERT with db.table in schemaMigrationsDump
  • Update tests to expect qualified table names and revised schema output

Written by Cursor Bugbot for commit 9bdd3f9. This will update automatically on new commits. Configure here.

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

Successfully merging this pull request may close these issues.

1 participant