Applied migrations we shouldn't have with discourse-ai

Hi,

We are using discourse 3.3.0, and i have the job Jobs::EmbeddingsBackfill which fails with :
Job exception: PG::UndefinedTable: ERROR: relation "ai_topic_embeddings_8_1" does not exist

I can see i have the table “ai_topic_embeddings”, but none of the ai_topic_embeddings_8_1, ai_topic_embeddings_6_1…

When running rake db:migrate:status i can see the migrations are up, and most of the ai features are working.

Any idea on what went wrong ?

1 Like

Just saw there’s a migration called 20240611170905_move_embeddings_to_single_table_per_type
which indicate that we applied migrations we shouldn’t have by using the wrong plugin version.

I have multiple migrations like this, which refer to the one that shouldn’t be done i think :
up 20240807150605 ********** NO FILE **********
up 20240809162837 ********** NO FILE **********
up 20240809163303 ********** NO FILE **********

Is there a way to rollback them ? If there’s a way to just remove everything from discourse-ai on my instance and start fresh that’s good too

1 Like

Managed to fix my problem by reverting the migrations manualy with sql.

For anyone doing the same mistake, after you set the plugin to the right commit, execute this : rake db:migrate:status
this will show you lines without files : up 20240809163303 ********** NO FILE **********
for each of them find the associated migration file on the plugin github (try to search on the whole discourse org so it’s faster)
then if there’s no down option, just remove it from sql : delete from schema_migrations where version = '........'; and rollback it manualy with sql

1 Like