Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Add guards for migrations #2222

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions db/migrate/20200513060858_create_domain_names.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class CreateDomainNames < ActiveRecord::Migration[5.1]
def change
create_table :domain_names do |t|
t.references :account
t.string :cname
t.boolean :is_active, default: true
t.boolean :is_ssl_enabled, default: false
unless table_exists?(:domain_names)
create_table :domain_names do |t|
t.references :account
t.string :cname
t.boolean :is_active, default: true
t.boolean :is_ssl_enabled, default: false

t.timestamps
t.timestamps
end
end
end
end
18 changes: 10 additions & 8 deletions db/migrate/20231215215705_create_hyrax_counter_metrics.hyrax.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
class CreateHyraxCounterMetrics < ActiveRecord::Migration[6.1]
def change
create_table :hyrax_counter_metrics do |t|
t.string :worktype
t.string :resource_type
t.integer :work_id
t.date :date
t.integer :total_item_investigations
t.integer :total_item_requests
unless table_exists?(:hyrax_counter_metrics)
create_table :hyrax_counter_metrics do |t|
t.string :worktype
t.string :resource_type
t.integer :work_id
t.date :date
t.integer :total_item_investigations
t.integer :total_item_requests

t.timestamps
t.timestamps
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class AddIndicesToHyraxCounterMetrics < ActiveRecord::Migration[6.1]
def change
add_index :hyrax_counter_metrics, :worktype
add_index :hyrax_counter_metrics, :resource_type
add_index :hyrax_counter_metrics, :work_id
add_index :hyrax_counter_metrics, :date
add_index :hyrax_counter_metrics, :worktype unless index_exists?(:hyrax_counter_metrics, :worktype)
add_index :hyrax_counter_metrics, :resource_type unless index_exists?(:hyrax_counter_metrics, :resource_type)
add_index :hyrax_counter_metrics, :work_id unless index_exists?(:hyrax_counter_metrics, :work_id)
add_index :hyrax_counter_metrics, :date unless index_exists?(:hyrax_counter_metrics, :date)
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class AddFieldsToCounterMetric < ActiveRecord::Migration[6.1]
def change
add_column :hyrax_counter_metrics, :title, :string
add_column :hyrax_counter_metrics, :year_of_publication, :integer, index: true
add_column :hyrax_counter_metrics, :publisher, :string, index: true
add_column :hyrax_counter_metrics, :author, :string, index: true
add_column :hyrax_counter_metrics, :title, :string unless column_exists?(:hyrax_counter_metrics, :title)
add_column :hyrax_counter_metrics, :year_of_publication, :integer, index: true unless column_exists?(:hyrax_counter_metrics, :year_of_publication)
add_column :hyrax_counter_metrics, :publisher, :string, index: true unless column_exists?(:hyrax_counter_metrics, :publisher)
add_column :hyrax_counter_metrics, :author, :string, index: true unless column_exists?(:hyrax_counter_metrics, :author)
end
end
Loading