PNixx / clickhouse-activerecord

A Ruby database ActiveRecord driver for ClickHouse
MIT License
192 stars 96 forks source link

db:schema:load is not idempotent #130

Open AlexKichkailo opened 5 months ago

AlexKichkailo commented 5 months ago

If you try to run db:schema:load multiple times, an error is thrown

DB::Exception: Table <DB>.ar_internal_metadata already exists. **(TABLE_ALREADY_EXISTS)**

It appears that the clickhouse_structure.sql file generated by the clickhouse-activerecord adapter is missing DROP TABLE IF EXISTS statements.

In Rails, db:schema:load is supposed to be idempotent so it could be used to reset the DB in a test or dev environment.