From f56551dddf58482392aff378be2556bf9e07124d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sede=C3=B1o?= Date: Thu, 19 Oct 2023 20:17:11 +0200 Subject: [PATCH] Remove old and unused migrations. #1 --- db/migrate/20140616132153_create_targets.rb | 14 ----- db/migrate/20140623100942_create_visits.rb | 52 ------------------- .../20140623101032_create_ahoy_events.rb | 19 ------- ...ation20140801080705_add_users_to_events.rb | 52 ------------------- ...visit_id_type_of_ahoy_events_to_integer.rb | 7 --- ...312100045_create_ahoy_visits_and_events.rb | 11 ---- db/migrate/20181009000259_drop_ahoy_events.rb | 15 ------ 7 files changed, 170 deletions(-) delete mode 100644 db/migrate/20140616132153_create_targets.rb delete mode 100644 db/migrate/20140623100942_create_visits.rb delete mode 100644 db/migrate/20140623101032_create_ahoy_events.rb delete mode 100644 db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb delete mode 100644 db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb delete mode 100644 db/migrate/20180312100045_create_ahoy_visits_and_events.rb delete mode 100644 db/migrate/20181009000259_drop_ahoy_events.rb diff --git a/db/migrate/20140616132153_create_targets.rb b/db/migrate/20140616132153_create_targets.rb deleted file mode 100644 index 3f5e4b7e7b..0000000000 --- a/db/migrate/20140616132153_create_targets.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -class CreateTargets < ActiveRecord::Migration - def change - create_table :targets do |t| - t.integer :conference_id - t.integer :campaign_id - t.date :due_date - t.integer :target_count - t.string :unit - t.timestamps - end - end -end diff --git a/db/migrate/20140623100942_create_visits.rb b/db/migrate/20140623100942_create_visits.rb deleted file mode 100644 index 49d409b641..0000000000 --- a/db/migrate/20140623100942_create_visits.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -class CreateVisits < ActiveRecord::Migration - def change - create_table :visits do |t| - t.uuid :visitor_id - - # the rest are recommended but optional - # simply remove the columns you don't want - - # standard - t.string :ip - t.text :user_agent - t.text :referrer - t.text :landing_page - - # user - t.integer :user_id - # add t.string :user_type if polymorphic - - # traffic source - t.string :referring_domain - t.string :search_keyword - - # technology - t.string :browser - t.string :os - t.string :device_type - - # location - t.string :country - t.string :region - t.string :city - - # utm parameters - t.string :utm_source - t.string :utm_medium - t.string :utm_term - t.string :utm_content - t.string :utm_campaign - - # native apps - # t.string :platform - # t.string :app_version - # t.string :os_version - - t.timestamp :started_at - end - - add_index :visits, [:user_id] - end -end diff --git a/db/migrate/20140623101032_create_ahoy_events.rb b/db/migrate/20140623101032_create_ahoy_events.rb deleted file mode 100644 index 63db8ba7ed..0000000000 --- a/db/migrate/20140623101032_create_ahoy_events.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class CreateAhoyEvents < ActiveRecord::Migration - def change - create_table :ahoy_events do |t| - t.uuid :visit_id - # user - t.integer :user_id - # add t.string :user_type if polymorphic - t.string :name - t.text :properties - t.timestamp :time - end - - add_index :ahoy_events, :visit_id - add_index :ahoy_events, :user_id - add_index :ahoy_events, :time - end -end diff --git a/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb b/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb deleted file mode 100644 index db2d1bb8b3..0000000000 --- a/db/migrate/20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -class UndoWrongMigration20140801080705AddUsersToEvents < ActiveRecord::Migration - class TempEvent < ActiveRecord::Base - self.table_name = 'events' - end - - class TempUser < ActiveRecord::Base - self.table_name = 'users' - end - - class TempEventUser < ActiveRecord::Base - self.table_name = 'event_users' - belongs_to :temp_event - belongs_to :temp_user - end - - class Version < ActiveRecord::Base - self.table_name = 'versions' - end - - def up - if ActiveRecord::Migrator.get_all_versions.include? 20140801080705 - user_deleted = TempUser.find_by(email: 'deleted@localhost.osem') - - TempEvent.all.each do |event| - whodunnit = Version.find_by(item_type: 'Event', item_id: event.id, event: 'create').whodunnit - original_user = TempUser.find_by(id: whodunnit) - - if original_user.blank? - original_submitter = user_deleted - else - original_submitter = original_user - end - - # Substitute submitter record - submitter = TempEventUser.find_by(event_id: event.id, event_role: 'submitter') - submitter.user_id = original_submitter.id - submitter.save! - - # Substitute speaker record - speaker = TempEventUser.find_by(event_id: event.id, event_role: 'speaker') - speaker.user_id = original_submitter.id - speaker.save! - end - end - end - - def down - raise ActiveRecord::IrreversibleMigration.new('Cannot reverse migration.') - end -end diff --git a/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb b/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb deleted file mode 100644 index 58b0860982..0000000000 --- a/db/migrate/20171118113113_change_visit_id_type_of_ahoy_events_to_integer.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class ChangeVisitIdTypeOfAhoyEventsToInteger < ActiveRecord::Migration[5.0] - def change - change_column :ahoy_events, :visit_id, :integer, limit: nil - end -end diff --git a/db/migrate/20180312100045_create_ahoy_visits_and_events.rb b/db/migrate/20180312100045_create_ahoy_visits_and_events.rb deleted file mode 100644 index a975dbf9e7..0000000000 --- a/db/migrate/20180312100045_create_ahoy_visits_and_events.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class CreateAhoyVisitsAndEvents < ActiveRecord::Migration[5.0] - def change - add_column :visits, :visit_token, :string - add_column :visits, :visitor_token, :string - - add_index :visits, [:visit_token], unique: true - add_index :ahoy_events, [:name, :time] - end -end diff --git a/db/migrate/20181009000259_drop_ahoy_events.rb b/db/migrate/20181009000259_drop_ahoy_events.rb deleted file mode 100644 index dbf7462675..0000000000 --- a/db/migrate/20181009000259_drop_ahoy_events.rb +++ /dev/null @@ -1,15 +0,0 @@ -class DropAhoyEvents < ActiveRecord::Migration[5.0] - def up - remove_index :visits, [:visit_token] - remove_index :ahoy_events, [:name, :time] - - drop_table :targets - drop_table :campaigns - drop_table :visits - drop_table :ahoy_events - end - - def down - raise ActiveRecord::IrreversibleMigration - end -end