Revert "FIX: Redo migrations such that tables are dropped in a safe manner. (#55)"

Revert “FIX: Redo migrations such that tables are dropped in a safe manner. (#55)”

This method of creating a table does not include any indexes, so we need to create them manually. Reverting temporarily.

This reverts commit 17b0147ccb3dedf46c8820404cf59826f311ac88.

diff --git a/db/migrate/20200409102643_rename_tables_to_discourse_post_event.rb b/db/migrate/20200409102643_rename_tables_to_discourse_post_event.rb
deleted file mode 100644
index 395ecfb..0000000
--- a/db/migrate/20200409102643_rename_tables_to_discourse_post_event.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-require 'migration/table_dropper'
-
-class RenameTablesToDiscoursePostEvent < ActiveRecord::Migration[6.0]
-  def up
-    unless table_exists?(:discourse_post_event_events)
-      Migration::TableDropper.read_only_table(:discourse_calendar_post_events)
-
-      execute <<~SQL
-      CREATE TABLE discourse_post_event_events
-      AS TABLE discourse_calendar_post_events
-      WITH NO DATA;
-      SQL
-
-      execute <<~SQL
-      INSERT INTO discourse_post_event_events
-      SELECT *
-      FROM discourse_calendar_post_events
-      SQL
-    end
-
-    unless table_exists?(:discourse_post_event_invitees)
-      Migration::TableDropper.read_only_table(:discourse_calendar_invitees)
-
-      execute <<~SQL
-      CREATE TABLE discourse_post_event_invitees
-      AS TABLE discourse_calendar_invitees
-      WITH NO DATA;
-      SQL
-
-      execute <<~SQL
-      INSERT INTO discourse_post_event_invitees
-      SELECT *
-      FROM discourse_calendar_invitees
-      SQL
-    end
-  end
-
-  def down
-    raise ActiveRecord::IrrelversibleMigration
-  end
-end
diff --git a/db/post_migrate/20200409102643_rename_tables_to_discourse_post_event.rb b/db/post_migrate/20200409102643_rename_tables_to_discourse_post_event.rb
new file mode 100644
index 0000000..ee7f779
--- /dev/null
+++ b/db/post_migrate/20200409102643_rename_tables_to_discourse_post_event.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class RenameTablesToDiscoursePostEvent < ActiveRecord::Migration[6.0]
+  def up
+    rename_table :discourse_calendar_post_events, :discourse_post_event_events
+    rename_table :discourse_calendar_invitees, :discourse_post_event_invitees
+  end
+
+  def down
+    rename_table :discourse_post_event_events, :discourse_calendar_post_events
+    rename_table :discourse_post_event_invitees, :discourse_calendar_invitees
+  end
+end
diff --git a/db/post_migrate/20200805073343_drop_old_discourse_calendar_tables.rb b/db/post_migrate/20200805073343_drop_old_discourse_calendar_tables.rb
deleted file mode 100644
index 9b69281..0000000
--- a/db/post_migrate/20200805073343_drop_old_discourse_calendar_tables.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# frozen_string_literal: true
-
-require 'migration/table_dropper'
-
-class DropOldDiscourseCalendarTables < ActiveRecord::Migration[6.0]
-  def up
-    if table_exists?(:discourse_calendar_post_events)
-      Migration::TableDropper.execute_drop(:discourse_calendar_post_events)
-    end
-
-    if table_exists?(:discourse_calendar_invitees)
-      Migration::TableDropper.execute_drop(:discourse_calendar_invitees)
-    end
-  end
-
-  def down
-    raise ActiveRecord::IrrelversibleMigration
-  end
-end

GitHub sha: b82b80fb