A user attempts to restore a Discourse database from version 3.3.0.beta1 to 3.5.0.beta7 but encounters a PG::DuplicateTable error for the discourse_automation_automations table. The issue arises because a migration from 2019 (create_automations_table.rb) is being re-applied, even though the table already exists. The user tries various solutions, including deleting migrations, skipping them, and manually inserting entries into schema_migrations, but none resolve the problem. The user eventually restores the original database and concludes the issue may not be common, suggesting the topic can be closed. pfaffman discusses the challenge, while Moin raises a potential plugin conflict, which is dismissed. tobiaseigen suggests closing the topic.
<meta name="generator" content="Discourse 3.3.0.beta1-dev - https://github.com/discourse/discourse version a4022f69f31af611bc0e21258b0ccb77dec38ba3">
to current. I copied the same app.yml and am restoring (new VM and trying to sidestep the pg upgrade, though maybe I should try that instead of the restore)
I think 3.3beta1 was before the plugin was included in core in April. Could this lead to any issues - for example, due to the plugin now being included in core while still also being installed separately via app.yml?
That’s a good idea, but that’s not it. I’m not including it again. I wonder if maybe I should have tried adding it (but I don’t see it in a quick look). My current idea is to drop all of the automations tables (they are empty) on the old site, make a new backup and trying restoring that.
and probably should have removed 20190601000001_create_automations_table.rb, but instead I added unless table exists code (I think when I deleted it I had another problem?).
And I finally got it to restore.
And when I rebuild, I get the same errors when the database tries to migrate.
So somehow I guess I need to convince rails that these migrations have, uh, run already. So then I tried this:
INSERT INTO schema_migrations(version) VALUES
('20190601000001'),
('20210108134117'),
('20210512090204'),
('20210530122323'),
('20211119103353'),
('20230412120414');
And that didn’t work either.
I think maybe it’s just those ones frrom 2021 I need to skip? Or maybe 202105?
But the version that’s running is from January 2024.
I was able to restore the first database (before I’d mucked with the schema_migrations) on the old server, so at least I’m back where I started. I guess I need to know how to look at the commits and migrations in some ways that I don’t.