Skip to content

Commit

Permalink
Merge pull request #323 from scientist-softserv/add-guard-clause-arou…
Browse files Browse the repository at this point in the history
…nd-migrations

🧹 Add table_exists? guard clauses to migrations
  • Loading branch information
jeremyf authored Jan 24, 2024
2 parents 81180a3 + cb5aa73 commit dadebca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
class CreateIiifPrintDerivativeAttachments < ActiveRecord::Migration[5.0]
def change
create_table :iiif_print_derivative_attachments do |t|
t.string :fileset_id
t.string :path
t.string :destination_name
unless table_exists?(:iiif_print_derivative_attachments)
create_table :iiif_print_derivative_attachments do |t|
t.string :fileset_id
t.string :path
t.string :destination_name

t.timestamps
t.timestamps
end
add_index :iiif_print_derivative_attachments, :fileset_id
end
add_index :iiif_print_derivative_attachments, :fileset_id
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class CreateIiifPrintIngestFileRelations < ActiveRecord::Migration[5.0]
def change
create_table :iiif_print_ingest_file_relations do |t|
t.string :file_path
t.string :derivative_path
unless table_exists?(:iiif_print_ingest_file_relations)
create_table :iiif_print_ingest_file_relations do |t|
t.string :file_path
t.string :derivative_path

t.timestamps
t.timestamps
end
add_index :iiif_print_ingest_file_relations, :file_path
end
add_index :iiif_print_ingest_file_relations, :file_path
end
end
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class CreateIiifPrintPendingRelationships < ActiveRecord::Migration[5.1]
def change
create_table :iiif_print_pending_relationships do |t|
t.string :child_title, null: false
t.string :parent_id, null: false
t.string :child_order, null: false
t.timestamps
unless table_exists?(:iiif_print_pending_relationships)
create_table :iiif_print_pending_relationships do |t|
t.string :child_title, null: false
t.string :parent_id, null: false
t.string :child_order, null: false
t.timestamps
end
add_index :iiif_print_pending_relationships, :parent_id
end
add_index :iiif_print_pending_relationships, :parent_id
end
end

0 comments on commit dadebca

Please sign in to comment.