Relation "discourse_automation_automations" שחזור מ- 3.3beta1 ל- 3.5beta7

סיכום מבוסס בינה מלאכותית

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.

Trying to restore a database from

    <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’m getting this error:

PG::DuplicateTable: ERROR:  relation "discourse_automation_automations" already exists

Seems like another case of some migration getting checked back in and this site got built during those few commits.

I don’t know what to do, though. Maybe I delete the migration that tries creating this table?

Old database is on 20240122015630 and new is 20250617085536.

I see this in the new source:

db/migrate/20190601000001_create_automations_table.rb:    create_table :discourse_automation_automations do |t|

But somehow this migration doesn’t know not to do that one? That table has the same fields on both. Maybe I just delete that migrations from 2019?

אני חושב ש-3.3beta1 היה לפני שהתוסף שולב בליבה באפריל. האם זה יכול לגרום לבעיות כלשהן — לדוגמה, בגלל שהתוסף משולב כעת בליבה בעודו עדיין מותקן בנפרד דרך app.yml?

זה רעיון טוב, אבל זה לא זה. אני לא כולל את זה שוב. אני תוהה אם אולי הייתי צריך לנסות להוסיף את זה (אבל אני לא רואה את זה במבט מהיר). הרעיון הנוכחי שלי הוא להסיר את כל טבלאות האוטומציות (הן ריקות) באתר הישן, ליצור גיבוי חדש ולנסות לשחזר אותו.

Well, and then it failed because discourse_automations_automations was missing. :person_shrugging:

אז הסרתי את אלה:

20210108134117_add_pending_pms_table.rb
20210512090204_add_timestamps_to_automations.rb
20210530122323_move_triggers_to_fields.rb
20211119103353_adds_discourse_automation_user_global_notice.rb
20230412120414_add_prefers_encrypt_field_to_pending_pms.rb

וכנראה שהייתי צריך להסיר 20190601000001_create_automations_table.rb, אבל במקום זאת הוספתי קוד ‘unless table exists’ (אני חושב שכשהסרתי את זה הייתה לי בעיה אחרת?).

ולבסוף הצלחתי לשחזר את זה.

האם נוכל לסגור את הנושא הזה? או להעביר אותו ל-Dev או Installation > Hosting אם תרצו להשאיר אותו פתוח?

כן. אפשר לסגור את זה. לא ברור לי אם זה יקרה אי פעם למישהו אחר, כך שזה עשוי להיות שימושי או לא.